* code taken from https://github.com/LineageOS/android_hardware_samsung_slsi-cm_exynos7420/tree/lineage-15.1/mobicore
Change-Id: I4de9a50d7aeeab0956bf33480c2a63b1ebdccdec
-# Some things are specific to Android 6.0 and later (use stlport absence as indicator)
-ifneq ($(wildcard external/stlport/libstlport.mk),)
-# Up to Lollipop
-TRUSTONIC_ANDROID_LEGACY_SUPPORT = yes
-else
-# Since Marshmallow
-TRUSTONIC_ANDROID_LEGACY_SUPPORT =
-endif
-
-include $(call all-subdir-makefiles)
+# =============================================================================
+#
+# Makefile pointing to all makefiles within the project.
+#
+# =============================================================================
+MOBICORE_PROJECT_PATH := $(call my-dir)
+# Setup common variables
+COMP_PATH_MobiCore := $(MOBICORE_PROJECT_PATH)/common/MobiCore
+COMP_PATH_MobiCoreDriverMod := $(MOBICORE_PROJECT_PATH)/include
+
+
+# Application wide Cflags
+GLOBAL_INCLUDES := bionic \
+ $(COMP_PATH_MobiCore)/inc \
+ $(COMP_PATH_MobiCoreDriverMod)/Public \
+ $(COMP_PATH_MobiCore)/inc/TlCm \
+ $(COMP_PATH_MobiCore)/inc/GP \
+ $(MOBICORE_PROJECT_PATH)/common/DrSecureStorage
+
+LOCAL_CXX_STL := libstlport
+
+# Include the Daemon
+include $(MOBICORE_PROJECT_PATH)/daemon/Android.mk
+
+MC_INCLUDE_DIR := \
+ $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include \
+ $(COMP_PATH_MobiCore)/inc \
+ $(COMP_PATH_MobiCore)/inc/GP \
+ $(COMP_PATH_MobiCore)/inc/TlCm \
+ $(COMP_PATH_MobiCore)/inc/TlCm/2.0 \
+ $(MOBICORE_PROJECT_PATH)/daemon/ClientLib/public \
+ $(MOBICORE_PROJECT_PATH)/daemon/Registry/Public
+
+MC_DEBUG := _DEBUG
+SYSTEM_LIB_DIR=/system/lib
+GDM_PROVLIB_SHARED_LIBS=libMcClient
+# Include the provisioning lib
+include $(MOBICORE_PROJECT_PATH)/provlib/Android.mk
+
+LOCAL_ADDITIONAL_DEPENDENCIES += \
+ $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+MOBICORE_DIR_INC := $(MC_INCLUDE_DIR) $(MOBICORE_PROJECT_PATH)/common/curl/include
+include $(MOBICORE_PROJECT_PATH)/rootpa/Code/Android/app/jni/Android.mk
+include $(MOBICORE_PROJECT_PATH)/rootpa/Code/Android/lib/Android.mk
+include $(MOBICORE_PROJECT_PATH)/rootpa/Code/Android/app/Android.mk
--- /dev/null
+# Copyright (C) 2007 The Android Open Source Project
+#
+# 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.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/ssltest_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/ssltest_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/ssltest_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/ssltest_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/ssltest_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libssl_static_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libcrypto_static_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/*ssl*_intermediates $(PRODUCT_OUT)/obj/*/libssl_*intermediates $(PRODUCT_OUT)/obj/*/libcrypto_*intermediates)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+++ /dev/null
-LOCAL_PATH := $(call my-dir)
-
-ifndef TRUSTONIC_ANDROID_LEGACY_SUPPORT
-
-# Proxy server lib
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libMcProxy
-LOCAL_MODULE_TAGS := eng
-
-LOCAL_CFLAGS := -fvisibility=hidden
-LOCAL_CFLAGS += -DTBASE_API_LEVEL=5
-LOCAL_CFLAGS += -Wall -Wextra
-LOCAL_CFLAGS += -std=c++11
-LOCAL_CFLAGS += -DLOG_ANDROID
-LOCAL_CFLAGS += -DGOOGLE_PROTOBUF_NO_RTTI
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/include/GP \
- external/protobuf/src
-
-ifeq ($(APP_PROJECT_PATH),)
-LOCAL_SHARED_LIBRARIES := \
- liblog \
- libprotobuf-cpp-lite
-else
-LOCAL_C_INCLUDES += \
- ${COMP_PATH_AndroidProtoBuf}/Bin/host/include
-
-LOCAL_STATIC_LIBRARIES := \
- libprotobuf-cpp-lite
-endif
-
-LOCAL_SRC_FILES := \
- src/driver_client.cpp \
- src/proxy_server.cpp \
- src/mc.pb.cpp
-
-LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDES)
-
-include $(BUILD_STATIC_LIBRARY)
-
-endif # !TRUSTONIC_ANDROID_LEGACY_SUPPORT
-
-# Client lib
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libMcClient
-LOCAL_MODULE_TAGS := eng
-
-LOCAL_CFLAGS := -fvisibility=hidden
-LOCAL_CFLAGS += -DTBASE_API_LEVEL=5
-LOCAL_CFLAGS += -Wall -Wextra
-LOCAL_CFLAGS += -std=c++11
-LOCAL_CFLAGS += -DLOG_ANDROID
-ifndef TRUSTONIC_ANDROID_LEGACY_SUPPORT
-LOCAL_CFLAGS += -DGOOGLE_PROTOBUF_NO_RTTI
-else # !TRUSTONIC_ANDROID_LEGACY_SUPPORT
-LOCAL_CFLAGS += -DWITHOUT_PROXY
-endif # TRUSTONIC_ANDROID_LEGACY_SUPPORT
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/include/GP
-
-ifeq ($(APP_PROJECT_PATH),)
-LOCAL_SHARED_LIBRARIES := \
- liblog
-
-ifdef TRUSTONIC_ANDROID_LEGACY_SUPPORT
-include external/stlport/libstlport.mk
-
-LOCAL_C_INCLUDES += \
- external/stlport/stlport
-
-LOCAL_SHARED_LIBRARIES += \
- libstlport
-else # TRUSTONIC_ANDROID_LEGACY_SUPPORT
-LOCAL_C_INCLUDES += \
- external/protobuf/src
-
-LOCAL_SHARED_LIBRARIES += \
- libprotobuf-cpp-lite
-endif # !TRUSTONIC_ANDROID_LEGACY_SUPPORT
-else # !NDK
-LOCAL_LDLIBS := -llog
-
-LOCAL_CFLAGS += -static-libstdc++
-
-LOCAL_C_INCLUDES += \
- ${COMP_PATH_AndroidProtoBuf}/Bin/host/include
-
-LOCAL_STATIC_LIBRARIES := \
- libprotobuf-cpp-lite
-endif # NDK
-
-LOCAL_SRC_FILES := \
- src/common_client.cpp \
- src/driver_client.cpp \
- src/mc_client_api.cpp \
- src/tee_client_api.cpp
-
-ifndef TRUSTONIC_ANDROID_LEGACY_SUPPORT
-LOCAL_SRC_FILES += \
- src/proxy_client.cpp \
- src/mc.pb.cpp
-endif # !TRUSTONIC_ANDROID_LEGACY_SUPPORT
-
-LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDES)
-
-include $(BUILD_SHARED_LIBRARY)
-
-# Static version of the client lib for recovery
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libMcClient_static
-LOCAL_MODULE_TAGS := eng
-
-LOCAL_CFLAGS := -fvisibility=hidden
-LOCAL_CFLAGS += -DTBASE_API_LEVEL=5
-LOCAL_CFLAGS += -Wall -Wextra
-LOCAL_CFLAGS += -std=c++11
-LOCAL_CFLAGS += -DLOG_ANDROID
-LOCAL_CFLAGS += -DWITHOUT_PROXY
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/include/GP
-
-ifdef TRUSTONIC_ANDROID_LEGACY_SUPPORT
-include external/stlport/libstlport.mk
-
-LOCAL_C_INCLUDES += \
- external/stlport/stlport
-
-LOCAL_SHARED_LIBRARIES += \
- libstlport
-endif # TRUSTONIC_ANDROID_LEGACY_SUPPORT
-
-LOCAL_SRC_FILES := \
- src/common_client.cpp \
- src/driver_client.cpp \
- src/mc_client_api.cpp \
- src/tee_client_api.cpp
-
-LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/include/GP
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDES)
-
-include $(BUILD_STATIC_LIBRARY)
-
-# =============================================================================
-
-# adding the root folder to the search path appears to make absolute paths
-# work for import-module - lets see how long this works and what surprises
-# future developers get from this.
-$(call import-add-path,/)
-$(call import-module,$(COMP_PATH_AndroidProtoBuf))
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This header file corresponds to V1.0 of the GlobalPlatform
- * TEE Client API Specification
- */
-#ifndef __TEE_CLIENT_API_H__
-#define __TEE_CLIENT_API_H__
-
-#include "tee_client_types.h"
-#include "tee_client_error.h"
-
-#if TBASE_API_LEVEL >= 3
-#include "tee_client_api_imp.h"
-
-#if (!defined(TEEC_EXPORT)) && defined(__cplusplus)
-#define TEEC_EXPORT extern "C"
-#else
-#define TEEC_EXPORT
-#endif // __cplusplus
-
-/* The header tee_client_api_imp.h must define implementation-dependent
- types, constants and macros.
-
- The implementation-dependent types are:
- - TEEC_Context_IMP
- - TEEC_Session_IMP
- - TEEC_SharedMemory_IMP
- - TEEC_Operation_IMP
-
- The implementation-dependent constants are:
- - TEEC_CONFIG_SHAREDMEM_MAX_SIZE
- The implementation-dependent macros are:
- - TEEC_PARAM_TYPES
-*/
-
-typedef struct {
- uint32_t a;
- uint32_t b;
-} TEEC_Value;
-
-/* Type definitions */
-typedef struct TEEC_Context {
- TEEC_Context_IMP imp;
-} TEEC_Context;
-
-typedef struct TEEC_Session {
- TEEC_Session_IMP imp;
-} TEEC_Session;
-
-typedef struct TEEC_SharedMemory {
- void *buffer;
- size_t size;
- uint32_t flags;
- TEEC_SharedMemory_IMP imp;
-} TEEC_SharedMemory;
-
-typedef struct {
- void *buffer;
- size_t size;
-} TEEC_TempMemoryReference;
-
-typedef struct {
- TEEC_SharedMemory *parent;
- size_t size;
- size_t offset;
-} TEEC_RegisteredMemoryReference;
-
-
-
-typedef union {
- TEEC_TempMemoryReference tmpref;
- TEEC_RegisteredMemoryReference memref;
- TEEC_Value value;
-} TEEC_Parameter;
-
-typedef struct TEEC_Operation {
- volatile uint32_t started;
- uint32_t paramTypes;
- TEEC_Parameter params[4];
- TEEC_Operation_IMP imp;
-} TEEC_Operation;
-
-
-#define TEEC_ORIGIN_API 0x00000001
-#define TEEC_ORIGIN_COMMS 0x00000002
-#define TEEC_ORIGIN_TEE 0x00000003
-#define TEEC_ORIGIN_TRUSTED_APP 0x00000004
-
-#define TEEC_MEM_INPUT 0x00000001
-#define TEEC_MEM_OUTPUT 0x00000002
-
-#define TEEC_NONE 0x0
-#define TEEC_VALUE_INPUT 0x1
-#define TEEC_VALUE_OUTPUT 0x2
-#define TEEC_VALUE_INOUT 0x3
-#define TEEC_MEMREF_TEMP_INPUT 0x5
-#define TEEC_MEMREF_TEMP_OUTPUT 0x6
-#define TEEC_MEMREF_TEMP_INOUT 0x7
-#define TEEC_MEMREF_WHOLE 0xC
-#define TEEC_MEMREF_PARTIAL_INPUT 0xD
-#define TEEC_MEMREF_PARTIAL_OUTPUT 0xE
-#define TEEC_MEMREF_PARTIAL_INOUT 0xF
-
-#define TEEC_LOGIN_PUBLIC 0x00000000
-#define TEEC_LOGIN_USER 0x00000001
-#define TEEC_LOGIN_GROUP 0x00000002
-#define TEEC_LOGIN_APPLICATION 0x00000004
-#define TEEC_LOGIN_USER_APPLICATION 0x00000005
-#define TEEC_LOGIN_GROUP_APPLICATION 0x00000006
-
-#define TEEC_TIMEOUT_INFINITE 0xFFFFFFFF
-
-#pragma GCC visibility push(default)
-
-TEEC_EXPORT TEEC_Result TEEC_InitializeContext(
- const char *name,
- TEEC_Context *context);
-
-TEEC_EXPORT void TEEC_FinalizeContext(
- TEEC_Context *context);
-
-TEEC_EXPORT TEEC_Result TEEC_RegisterSharedMemory(
- TEEC_Context *context,
- TEEC_SharedMemory *sharedMem);
-
-TEEC_EXPORT TEEC_Result TEEC_AllocateSharedMemory(
- TEEC_Context *context,
- TEEC_SharedMemory *sharedMem);
-
-TEEC_EXPORT void TEEC_ReleaseSharedMemory (
- TEEC_SharedMemory *sharedMem);
-
-TEEC_EXPORT TEEC_Result TEEC_OpenSession (
- TEEC_Context *context,
- TEEC_Session *session,
- const TEEC_UUID *destination,
- uint32_t connectionMethod,
- const void *connectionData,
- TEEC_Operation *operation,
- uint32_t *returnOrigin);
-
-TEEC_EXPORT void TEEC_CloseSession (
- TEEC_Session *session);
-
-TEEC_EXPORT TEEC_Result TEEC_InvokeCommand(
- TEEC_Session *session,
- uint32_t commandID,
- TEEC_Operation *operation,
- uint32_t *returnOrigin);
-
-TEEC_EXPORT void TEEC_RequestCancellation(
- TEEC_Operation *operation);
-
-#pragma GCC visibility pop
-
-#endif /* TBASE_API_LEVEL */
-
-#endif /* __TEE_CLIENT_API_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * This header file defines the implementation-dependent types,
- * constants and macros for all the Trusted Foundations implementations
- * of the TEE Client API
- */
-#ifndef __TEE_CLIENT_API_IMP_H__
-#define __TEE_CLIENT_API_IMP_H__
-
-#if TBASE_API_LEVEL >= 3
-
-#include <pthread.h>
-
-#define TEEC_MEM_INOUT (TEEC_MEM_INPUT | TEEC_MEM_OUTPUT)
-
-typedef struct {
- uint32_t reserved;
-} TEEC_Context_IMP;
-
-typedef struct {
- uint32_t sessionId;
- TEEC_Context_IMP context;
- void *tci;
- bool active;
- pthread_mutex_t mutex_tci; //mutex to serialize CA requests
-} TEEC_Session_IMP;
-
-typedef struct {
- bool implementation_allocated;
-} TEEC_SharedMemory_IMP;
-
-typedef struct {
- TEEC_Session_IMP *session;
-} TEEC_Operation_IMP;
-
-/* There is no natural, compile-time limit on the shared memory, but a specific
- implementation may introduce a limit (in particular on TrustZone) */
-#define TEEC_CONFIG_SHAREDMEM_MAX_SIZE ((size_t)0xFFFFFFFF)
-
-#define TEEC_PARAM_TYPES(entry0Type, entry1Type, entry2Type, entry3Type) \
- ((entry0Type) | ((entry1Type) << 4) | ((entry2Type) << 8) | ((entry3Type) << 12))
-
-#endif /* TBASE_API_LEVEL >= 3 */
-
-#endif /* __TEE_CLIENT_API_IMP_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __TEE_CLIENT_ERROR_H__
-#define __TEE_CLIENT_ERROR_H__
-
-#define TEEC_SUCCESS ((TEEC_Result)0x00000000)
-
-/**
- * Generic error code : Generic error
- **/
-#define TEEC_ERROR_GENERIC ((TEEC_Result)0xFFFF0000)
-
-/**
- * Generic error code : The underlying security system denies the access to the
- * object
- **/
-#define TEEC_ERROR_ACCESS_DENIED ((TEEC_Result)0xFFFF0001)
-
-/**
- * Generic error code : The pending operation is cancelled.
- **/
-#define TEEC_ERROR_CANCEL ((TEEC_Result)0xFFFF0002)
-
-/**
- * Generic error code : The underlying system detects a conflict
- **/
-#define TEEC_ERROR_ACCESS_CONFLICT ((TEEC_Result)0xFFFF0003)
-
-/**
- * Generic error code : Too much data for the operation or some data remain
- * unprocessed by the operation.
- **/
-#define TEEC_ERROR_EXCESS_DATA ((TEEC_Result)0xFFFF0004)
-
-/**
- * Generic error code : Error of data format
- **/
-#define TEEC_ERROR_BAD_FORMAT ((TEEC_Result)0xFFFF0005)
-
-/**
- * Generic error code : The specified parameters are invalid
- **/
-#define TEEC_ERROR_BAD_PARAMETERS ((TEEC_Result)0xFFFF0006)
-
-/**
- * Generic error code : Illegal state for the operation.
- **/
-#define TEEC_ERROR_BAD_STATE ((TEEC_Result)0xFFFF0007)
-
-/**
- * Generic error code : The item is not found
- **/
-#define TEEC_ERROR_ITEM_NOT_FOUND ((TEEC_Result)0xFFFF0008)
-
-/**
- * Generic error code : The specified operation is not implemented
- **/
-#define TEEC_ERROR_NOT_IMPLEMENTED ((TEEC_Result)0xFFFF0009)
-
-/**
- * Generic error code : The specified operation is not supported
- **/
-#define TEEC_ERROR_NOT_SUPPORTED ((TEEC_Result)0xFFFF000A)
-
-/**
- * Generic error code : Insufficient data is available for the operation.
- **/
-#define TEEC_ERROR_NO_DATA ((TEEC_Result)0xFFFF000B)
-
-/**
- * Generic error code : Not enough memory to perform the operation
- **/
-#define TEEC_ERROR_OUT_OF_MEMORY ((TEEC_Result)0xFFFF000C)
-
-/**
- * Generic error code : The service is currently unable to handle the request;
- * try later
- **/
-#define TEEC_ERROR_BUSY ((TEEC_Result)0xFFFF000D)
-
-/**
- * Generic communication error
- **/
-#define TEEC_ERROR_COMMUNICATION ((TEEC_Result)0xFFFF000E)
-
-/**
- * Generic error code : security violation
- **/
-#define TEEC_ERROR_SECURITY ((TEEC_Result)0xFFFF000F)
-
-/**
- * Generic error code : the buffer is too short
- **/
-#define TEEC_ERROR_SHORT_BUFFER ((TEEC_Result)0xFFFF0010)
-
-/**
- * Error of communication: The target of the connection is dead
- **/
-#define TEEC_ERROR_TARGET_DEAD ((TEEC_Result)0xFFFF3024)
-
-/**
- * File system error code: not enough space to complete the operation.
- **/
-#define TEEC_ERROR_STORAGE_NO_SPACE ((TEEC_Result)0xFFFF3041)
-
-/*------------------------------------------------------------------------------
- Implementation-specific errors
-------------------------------------------------------------------------------*/
-#define TEEC_TBASE_ERROR_STORAGE_ITEM_EXISTS ((TEEC_Result)0x80000000)
-#define TEEC_TBASE_ERROR_STORAGE_CORRUPTED ((TEEC_Result)0x80000001)
-#define TEEC_TBASE_ERROR_STORAGE_UNREACHABLE ((TEEC_Result)0x80000002)
-#define TEEC_TBASE_ERROR_NO_MORE_HANDLES ((TEEC_Result)0x80000003)
-#define TEEC_TBASE_ERROR_ITEM_EXISTS ((TEEC_Result)0x80000004)
-
-#endif /* __TEE_CLIENT_ERROR_H__ */
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __TEE_CLIENT_TYPES_H__
-#define __TEE_CLIENT_TYPES_H__
-
-#include <limits.h>
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stddef.h>
-
-#ifndef NULL
-# ifdef __cplusplus
-# define NULL 0
-# else
-# define NULL ((void *)0)
-# endif
-#endif
-
-#define IN
-#define OUT
-
-typedef uint32_t TEEC_Result;
-
-/** Definition of an UUID (from RFC 4122 http://www.ietf.org/rfc/rfc4122.txt) */
-typedef struct TEE_UUID {
- uint32_t timeLow;
- uint16_t timeMid;
- uint16_t timeHiAndVersion;
- uint8_t clockSeqAndNode[8];
-} TEE_UUID;
-typedef TEE_UUID TEEC_UUID;
-
-/** Type definition for a TEE Identity */
-typedef struct TEE_Identity {
- uint32_t login;
- TEE_UUID uuid;
-} TEE_Identity;
-
-#endif /* __TEE_CLIENT_TYPES_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef _GP_TCI_H_
-#define _GP_TCI_H_
-
-typedef struct {
- uint32_t a;
- uint32_t b;
-} TEE_Value;
-
-typedef struct {
- uint32_t sVirtualAddr; /**< The virtual address of the Bulk buffer regarding the address space of the Trustlet, already includes a possible offset! */
- uint32_t sVirtualLen; /**< Length of the mapped Bulk buffer */
- uint32_t outputSize;
-} _TEEC_MemoryReferenceInternal;
-
-typedef union {
- TEE_Value value;
- _TEEC_MemoryReferenceInternal memref;
-} _TEEC_ParameterInternal;
-
-typedef enum {
- _TA_OPERATION_OPEN_SESSION = 1,
- _TA_OPERATION_INVOKE_COMMAND = 2,
- _TA_OPERATION_CLOSE_SESSION = 3,
-} _TEEC_TCI_type;
-
-typedef struct {
- _TEEC_TCI_type type;
- uint32_t commandId;
- uint32_t paramTypes;
- _TEEC_ParameterInternal params[4];
- bool isCancelled;
-} _TEEC_OperationInternal;
-
-typedef struct {
- char header[8];// = "TCIGP000"`: version indicator (to support future format changes)
- TEEC_UUID destination;
- _TEEC_OperationInternal operation; //the data of the ongoing operation (if any)
- uint32_t ready;
- // The following fields are set by the secure world (in a future version, they may also be set by the normal world communication layer):
- uint32_t returnOrigin;
- uint32_t returnStatus;
-} _TEEC_TCI;
-
-/**
- * Termination codes
- */
-#define TA_EXIT_CODE_PANIC (300)
-#define TA_EXIT_CODE_TCI (301)
-#define TA_EXIT_CODE_PARAMS (302)
-#define TA_EXIT_CODE_FINISHED (303)
-#define TA_EXIT_CODE_SESSIONSTATE (304)
-#define TA_EXIT_CODE_CREATEFAILED (305)
-
-#endif // _GP_TCI_H_
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MCP_H_
-#define MCP_H_
-
-
-#include "mcUuid.h"
-#include "mcLoadFormat.h"
-#include "mcVersionInfo.h"
-#include "stdbool.h"
-
-#define FLAG_RESPONSE (1U << 31) /**< Flag to indicate that this is the response to a MCP command. */
-
-#define MCP_MAP_MAX_BUF 4 /** Maximum number of buffers that can be mapped at once */
-
-/** MobiCore Return Code Defines.
- * List of the possible MobiCore return codes.
- */
-typedef enum {
- MC_MCP_RET_OK = 0, /**< Memory has successfully been mapped. */
- MC_MCP_RET_ERR_INVALID_SESSION = 1, /**< The session ID is invalid. */
- MC_MCP_RET_ERR_UNKNOWN_UUID = 2, /**< The UUID of the Trustlet is unknown. */
- MC_MCP_RET_ERR_UNKNOWN_DRIVER_ID = 3, /**< The ID of the driver is unknown. */
- MC_MCP_RET_ERR_NO_MORE_SESSIONS = 4, /**< No more session are allowed. */
- MC_MCP_RET_ERR_CONTAINER_INVALID = 5, /**< The container is invalid. */
- MC_MCP_RET_ERR_TRUSTLET_INVALID = 6, /**< The Trustlet is invalid. */
- MC_MCP_RET_ERR_ALREADY_MAPPED = 7, /**< The memory block has already been mapped before. */
- MC_MCP_RET_ERR_INVALID_PARAM = 8, /**< Alignment or length error in the command parameters. */
- MC_MCP_RET_ERR_OUT_OF_RESOURCES = 9, /**< No space left in the virtual address space of the session. */
- MC_MCP_RET_ERR_INVALID_WSM = 10, /**< WSM type unknown or broken WSM */
- MC_MCP_RET_ERR_UNKNOWN = 11, /**< unknown error. */
- MC_MCP_RET_ERR_INVALID_MAPPING_LENGTH = 12, /**< Lenght of map invalid */
- MC_MCP_RET_ERR_MAPPING_TARGET = 13, /**< Map can only be applied to Trustlet session */
- MC_MCP_RET_ERR_OUT_OF_CRYPTO_RESSOURCES = 14, /**< Couldn't open crypto session. */
- MC_MCP_RET_ERR_SIGNATURE_VERIFICATION_FAILED = 15, /**< System Trustlet signature verification failed. */
- MC_MCP_RET_ERR_WRONG_PUBLIC_KEY = 16, /**< System Trustlet public key is wrong. */
- MC_MCP_RET_ERR_CONTAINER_TYPE_MISMATCH = 17, /**< Wrong containter type(s). */
- MC_MCP_RET_ERR_CONTAINER_LOCKED = 18, /**< Container is locked (or not activated). */
- MC_MCP_RET_ERR_SP_NO_CHILD = 19, /**< SPID is not registered with root container. */
- MC_MCP_RET_ERR_TL_NO_CHILD = 20, /**< UUID is not registered with sp container. */
- MC_MCP_RET_ERR_UNWRAP_ROOT_FAILED = 21, /**< Unwrapping of root container failed. */
- MC_MCP_RET_ERR_UNWRAP_SP_FAILED = 22, /**< Unwrapping of service provider container failed. */
- MC_MCP_RET_ERR_UNWRAP_TRUSTLET_FAILED = 23, /**< Unwrapping of Trustlet container failed. */
- MC_MCP_RET_ERR_CONTAINER_VERSION_MISMATCH = 24, /**< Container version mismatch. */
- MC_MCP_RET_ERR_SP_TL_DECRYPTION_FAILED = 25, /**< Decryption of service provider trustlet failed. */
- MC_MCP_RET_ERR_SP_TL_HASH_CHECK_FAILED = 26, /**< Hash check of service provider trustlet failed. */
- MC_MCP_RET_ERR_LAUNCH_TASK_FAILED = 27, /**< Activation/starting of task failed. */
- MC_MCP_RET_ERR_CLOSE_TASK_FAILED = 28, /**< Closing of task not yet possible, try again later. */
- MC_MCP_RET_ERR_SERVICE_BLOCKED = 29, /**< Service is blocked and a session cannot be opened to it. */
- MC_MCP_RET_ERR_SERVICE_LOCKED = 30, /**< Service is locked and a session cannot be opened to it. */
- MC_MCP_RET_ERR_SERVICE_KILLED = 31, /**< Service was forcefully killed (due to an administrative command). */
-
- // used for command verification
- MC_MCP_RET_ERR_UNKNOWN_COMMAND = 50, /**< The command is unknown. */
- MC_MCP_RET_ERR_INVALID_DATA = 51 /**< The command data is invalid. */
-} mcpResult_t;
-
-/** Possible MCP Command IDs
- * Command ID must be between 0 and 0x7FFFFFFF.
- */
-typedef enum {
- MC_MCP_CMD_ID_INVALID = 0x00000000, /**< Invalid command ID. */
- // Session commands
- MC_MCP_CMD_OPEN_SESSION = 0x00000001, /**< Open a session to a service. */
- MC_MCP_CMD_CLOSE_SESSION = 0x00000003, /**< Close an existing service session. */
- MC_MCP_CMD_MAP = 0x00000004, /**< Map a block of WSM to a session. */
- MC_MCP_CMD_UNMAP = 0x00000005, /**< Unmap a block of WSM from a session. */
- MC_MCP_CMD_SUSPEND = 0x00000006, /**< Prepare MobiCore for suspend. */
- MC_MCP_CMD_RESUME = 0x00000007, /**< Resume MobiCore from suspension. */
- // obsolete: MC_MCP_CMD_DONATE_RAM = 0x00000008,
- MC_MCP_CMD_GET_MOBICORE_VERSION = 0x00000009, /**< Get MobiCore version information. */
- MC_MCP_CMD_CLOSE_MCP = 0x0000000A, /**< Close MCP and unmap MCI. */
- MC_MCP_CMD_LOAD_TOKEN = 0x0000000B, /**< Load token for device attestation */
- MC_MCP_CMD_CHECK_LOAD_TA = 0x0000000C, /**< Check that TA can be loaded */
- MC_MCP_CMD_MULTIMAP = 0x0000000D,
- MC_MCP_CMD_MULTIUNMAP = 0x0000000E,
-} mcpCmdId_t;
-
-
-/** Types of WSM known to the MobiCore.
- */
-typedef uint32_t wsmType_t;
-
-#define WSM_TYPE_MASK 0xFF
-#define WSM_INVALID 0 /**< Invalid memory type */
-#define WSM_CONTIGUOUS 1 /**< Reference to WSM points to a contiguous region of pages. */
-#define WSM_L2 2 /**< Reference to WSM points to an L2 table describing the memory region to share */
-#define WSM_L1 3 /**< Reference to WSM points to an L1 table describing the memory region to share */
-#define WSM_WSM_UNCACHED 0x100 /**< Bitflag indicating that WSM should be uncached */
-#define WSM_L2_UNCACHED 0x100 /**< Bitflag indicating that L2 table should be uncached */
-
-/** Magic number used to identify if Open Command supports GP client authentication. */
-#define MC_GP_CLIENT_AUTH_MAGIC 0x47504131 /* "GPA1" */
-
-/** Initialisation values flags. */
-#define MC_IV_FLAG_IRQ (1 << 0) /* Set if IRQ is present */
-#define MC_IV_FLAG_TIME (1 << 1) /* Set if GP TIME API is supported */
-
-typedef struct {
- uint32_t flags; /**< Flags to know what data to expect. */
- uint32_t irq; /**< IRQ number to use. */
- uint32_t timeOffset;/**< Offset from MCI base address of mcTime struct. */
- uint32_t timeLen;/**< Length of mcTime struct. */
-} initValues_t;
-
-/** Command header.
- * It just contains the command ID. Only values specified in mcpCmdId_t are allowed as command IDs.
- * If the command ID is unspecified the MobiCore returns an empty response with the result set to MC_MCP_RET_ERR_UNKNOWN_COMMAND .
- */
-typedef struct {
- mcpCmdId_t cmdId; /**< Command ID of the command */
-} commandHeader_t, *commandHeader_ptr;
-
-/** Response header.
- * MobiCore will reply to every MCP command with an MCP response. Like the MCP command the response consists of a
- * header followed by response data. The response is written to the same memory location as the MCP command.
- */
-typedef struct {
- uint32_t rspId; /**< Command ID | FLAG_RESPONSE. */
- mcpResult_t result; /**< Result informs about the execution result of the command associated with the response. */
-} responseHeader_t, *responseHeader_ptr;
-
-
-
-/** @defgroup CMD MCP Commands
- * @{ */
-
-/** @defgroup ASMCMD Administrative Commands
- * @{ */
-
-/** @defgroup MCPGETMOBICOREVERSION GET_MOBICORE_VERSION
- * Get MobiCore version info.
- *
- * @{ */
-
-/** Get MobiCore Version Command. */
-typedef struct {
- commandHeader_t cmdHeader; /** Command header. */
-} mcpCmdGetMobiCoreVersion_t, *mcpCmdGetMobiCoreVersion_ptr;
-
-/** Get MobiCore Version Command Response. */
-typedef struct {
- responseHeader_t rspHeader; /** Response header. */
- mcVersionInfo_t versionInfo; /** MobiCore version info. */
-} mcpRspGetMobiCoreVersion_t, *mcpRspGetMobiCoreVersion_ptr;
-
-/** @} */// End MCPGETMOBICOREVERSION
-
-/** @} */// End ASMCMD
-
-
-/** @defgroup POWERCMD Power Management Commands
- * @{ */
-
-/** @defgroup MCPSUSPEND SUSPEND
- * Prepare MobiCore suspension.
- * This command allows MobiCore and MobiCore drivers to release or clean resources and save device state.
- *
- * @{ */
-
-/** Suspend Command */
-typedef struct {
- commandHeader_t cmdHeader; /**< Command header. */
-} mcpCmdSuspend_t, *mcpCmdSuspend_ptr;
-
-/** Suspend Command Response */
-typedef struct {
- responseHeader_t rspHeader; /**< Response header. */
-} mcpRspSuspend_t, *mcpRspSuspend_ptr;
-/** @} */// End MCPSUSPEND
-
-
-/** @defgroup MCPRESUME RESUME
- * Resume MobiCore from suspension.
- * This command allows MobiCore and MobiCore drivers to reinitialize hardware affected by suspension.
- *
- * @{ */
-
-/** Resume Command */
-typedef struct {
- commandHeader_t cmdHeader; /**< Command header. */
-} mcpCmdResume_t, *mcpCmdResume_ptr;
-
-/** Resume Command Response */
-typedef struct {
- responseHeader_t rspHeader; /**< Response header. */
-} mcpRspResume_t, *mcpRspResume_ptr;
-
-/** @} */// End MCPRESUME
-
-/** @} */// End POWERCMD
-
-
-
-/** @defgroup SESSCMD Session Management Commands
- * @{ */
-
-/** @defgroup MCPOPEN OPEN
- * Load and open a session to a Trustlet.
- * The OPEN command loads Trustlet data to the MobiCore context and opens a session to the Trustlet.
- * If wsmTypeLoadData is WSM_INVALID MobiCore tries to start a pre-installed Trustlet
- * associated with the uuid passed.
- * The uuid passed must match the uuid contained in the load data (if available).
- * On success, MobiCore returns the session ID which can be used for further communication.
- * @{ */
-
-/** GP client authentication data */
-typedef struct {
- uint32_t mclfMagic; /**< ASCII "GPA1" if GP client authentication is supported,
- "MCLF" otherwise. */
- mcIdentity_t mcIdentity; /**< GP identity information: login method and data */
-} cmdOpenData_t;
-
-/** Open Command */
-typedef struct {
- commandHeader_t cmdHeader; /**< Command header. */
- mcUuid_t uuid; /**< Byte array containing the service UUID. */
- uint8_t pad1[4]; /**< Padding to be 64-bit aligned */
- uint64_t adrTciBuffer; /**< Physical address of the TCI */
- uint64_t adrLoadData; /**< Physical address of the data to load. */
- uint32_t ofsTciBuffer; /**< Offset to the data. */
- uint32_t lenTciBuffer; /**< Length of the TCI. */
- wsmType_t wsmTypeTci; /**< Type of WSM used for the TCI */
- wsmType_t wsmTypeLoadData; /**< Type of the memory containing the data to load. */
- uint32_t ofsLoadData; /**< Offset to the data. */
- uint32_t lenLoadData; /**< Length of the data to load. */
- union {
- cmdOpenData_t cmdOpenData; /**< Magic number and login info for GP client authentication. */
- mclfHeader_t tlHeader; /**< Service header */
- };
- uint32_t is_gpta; /**< true if looking for an SD/GP-TA */
-} mcpCmdOpen_t, *mcpCmdOpen_ptr;
-
-/** Open Command Response */
-typedef struct {
- responseHeader_t rspHeader; /**< Response header. */
- uint32_t sessionId; /**< Session ID used for further communication. */
-} mcpRspOpen_t, *mcpRspOpen_ptr;
-
-/** TA Load Check Command */
-typedef struct {
- commandHeader_t cmdHeader; /**< Command header. */
- mcUuid_t uuid; /**< Byte array containing the service UUID. */
- uint8_t pad1[4]; /**< Padding to be 64-bit aligned */
- uint64_t adrLoadData; /**< Physical address of the data to load. */
- wsmType_t wsmTypeLoadData; /**< Type of the memory containing the data to load. */
- uint32_t ofsLoadData; /**< Offset to the data. */
- uint32_t lenLoadData; /**< Length of the data to load. */
- mclfHeader_t tlHeader; /**< Service header. */
-} mcpCmdCheckLoad_t, *mcpCmdCheckLoad_ptr;
-
-/** TA Load Check Response */
-typedef struct {
- responseHeader_t rspHeader; /**< Response header. */
-} mcpRspCheckLoad_t, *mcpRspCheckLoad_ptr;
-
-
-/** @} */// End MCPOPEN
-
-
-/** @defgroup MCPCLOSE CLOSE
- * Close an existing session to a Trustlet.
- * The CLOSE command terminates a session and frees all resources in the MobiCore system which
- * are currently occupied by the session. Before closing the session, the MobiCore runtime
- * management waits until all pending operations, like calls to drivers, invoked by the Trustlet
- * have been terminated.
- * Mapped memory will automatically be unmapped from the MobiCore context. The NWd is responsible for
- * processing the freed memory according to the Rich-OS needs.
- *
- * @{ */
-
-/** Close Command */
-typedef struct {
- commandHeader_t cmdHeader; /**< Command header. */
- uint32_t sessionId; /**< Session ID. */
-} mcpCmdClose_t, *mcpCmdClose_ptr;
-
-/** Close Command Response */
-typedef struct {
- responseHeader_t rspHeader; /**< Response header. */
-} mcpRspClose_t, *mcpRspClose_ptr;
-
-/** @} */// End MCPCLOSE
-
-
-/** @defgroup MCPMAP MAP
- * Map a portion of memory to a session.
- * The MAP command provides a block of memory to the context of a service.
- * The memory then becomes world-shared memory (WSM).
- * The only allowed memory type here is WSM_L2.
- * @{ */
-
-/** Map Command */
-typedef struct {
- commandHeader_t cmdHeader; /**< Command header. */
- uint32_t sessionId; /**< Session ID of a valid session */
- wsmType_t wsmType; /**< Type of WSM used of the memory*/
- uint32_t ofsBuffer; /**< Offset to the payload. */
- uint64_t adrBuffer; /**< Physical address of the memory */
- uint32_t lenBuffer; /**< Length of the buffer. */
- uint8_t pad1[4]; /**< Padding to be 64-bit aligned */
-} mcpCmdMap_t, *mcpCmdMap_ptr;
-
-#define MCP_MAP_MAX 0x100000 /**< Maximum allowed length for MCP map. */
-
-/** Map Command Response */
-typedef struct {
- responseHeader_t rspHeader; /**< Response header. */
- uint32_t secureVirtualAdr; /**< Virtual address in the context of the service the WSM is mapped to, already includes a possible offset! */
-} mcpRspMap_t, *mcpRspMap_ptr;
-
-/** @} *///End MCPMAP
-
-
-/** @defgroup MCPUNMAP UNMAP
- * Unmap a portion of world-shared memory from a session.
- * The UNMAP command is used to unmap a previously mapped block of
- * world shared memory from the context of a session.
- *
- * Attention: The memory block will be immediately unmapped from the specified session.
- * If the service is still accessing the memory, the service will trigger a segmentation fault.
- * @{ */
-
-/** Unmap Command */
-typedef struct {
- commandHeader_t cmdHeader; /**< Command header. */
- uint32_t sessionId; /**< Session ID of a valid session */
- wsmType_t wsmType; /**< Type of WSM used of the memory*/
- uint32_t secureVirtualAdr; /**< Virtual address in the context of the service the WSM has been mapped to, already includes a possible offset! */
- uint32_t lenVirtualBuffer; /**< Length of the virtual buffer. */
-} mcpCmdUnmap_t, *mcpCmdUnmap_ptr;
-
-/** Unmap Command Response */
-typedef struct {
- responseHeader_t rspHeader; /**< Response header. */
-} mcpRspUnmap_t, *mcpRspUnmap_ptr;
-
-/** @} */// End MCPUNMAP
-
-/** @defgroup MCPMULTIMAP MULTIMAP
- * Map up to MCP_MAP_MAX_BUF portions of memory to a session.
- * The MULTIMAP command provides MCP_MAP_MAX_BUF blocks of memory to the context of a service.
- * The memory then becomes world-shared memory (WSM).
- * The only allowed memory type here is WSM_L2.
- * @{ */
-
-/** NWd physical buffer description
- *
- * Note: Information is coming from NWd kernel. So it should not be trusted more than NWd kernel is trusted.
- */
-typedef struct {
- uint64_t adrBuffer; /**< Physical address, for buffer or for L2 table (1K) */
- uint32_t ofsBuffer; /**< Offset of buffer */
- uint32_t lenBuffer; /**< Length of buffer */
- wsmType_t wsmType; /**< Type of address */
- uint8_t pad1[4]; /**< Padding to be 64-bit aligned */
-} mcpBufferMap_t;
-
-/** Multimap Command */
-typedef struct {
- commandHeader_t cmdHeader; /**< Command header. */
- uint32_t sessionId; /** Session ID */
- mcpBufferMap_t buffers[MCP_MAP_MAX_BUF];
-} mcpCmdMultimap_t, *mcpCmdMultimap_ptr;
-
-/** Multimap Command Response */
-typedef struct {
- responseHeader_t rspHeader; /**< Response header. */
- uint64_t secureVirtAdr[MCP_MAP_MAX_BUF]; /**< Virtual address in the context of the service the WSM is mapped to, already includes a possible offset! */
-} mcpRspMultimap_t, *mcpRspMultimap_ptr;
-
-/** @} *///End MCPMULTIMAP
-
-/** @defgroup MCPMULTIUNMAP MULTIUNMAP
- * Unmap up to MCP_MAP_MAX_BUF portions of world-shared memory from a session.
- * The MULTIUNMAP command is used to unmap MCP_MAP_MAX_BUF previously mapped blocks of
- * world shared memory from the context of a session.
- *
- * Attention: The memory blocks will be immediately unmapped from the specified session.
- * If the service is still accessing the memory, the service will trigger a segmentation fault.
- * @{ */
-
-/** NWd mapped buffer description
- *
- * Note: Information is coming from NWd kernel. So it should not be trusted more than NWd kernel is trusted.
- */
-typedef struct {
- uint64_t secureVirtAdr; /**< Physical address, for buffer or for L2 table (1K) */
- uint32_t lenBuffer; /**< Length of buffer - unused */
- uint8_t pad1[4]; /**< Padding to be 64-bit aligned */
-} mcpBufferUnmap_t;
-
-/** Multiunmap Command */
-typedef struct {
- commandHeader_t cmdHeader; /**< Command header. */
- uint32_t sessionId; /** Session ID */
- mcpBufferUnmap_t buffers[MCP_MAP_MAX_BUF]; /* For len and sva */
-} mcpCmdMultiunmap_t, *mcpCmdMultiunmap_ptr;
-
-/** Multiunmap Command Response */
-typedef struct {
- responseHeader_t rspHeader; /**< Response header. */
-} mcpRspMultiunmap_t, *mcpRspMultiunmap_ptr;
-
-/** @} */// End MCPMULTIUNMAP
-
-/** @} */// End SESSCMD
-
-/** @defgroup MCPLOADTOKEN
- * Load a token from the normal world and share it with <t-base
- * If something fails, the device attestation functionality will be disabled
- * @{ */
-
-/** Load Token */
-typedef struct {
- commandHeader_t cmdHeader; /**< Command header. */
- wsmType_t wsmTypeLoadData; /**< Type of the memory containing the data to load. */
- uint64_t adrLoadData; /**< Physical address of the data to load. */
- uint64_t ofsLoadData; /**< Offset to the data to load. */
- uint64_t lenLoadData; /**< Length of the data to load. */
-} mcpCmdLoadToken_t, *mcpCmdLoadToken_ptr;
-
-/** Load Token Command Response */
-typedef struct {
- responseHeader_t rspHeader; /**< Response header. */
-} mcpRspLoadToken_t, *mcpRspLoadToken_ptr;
-
-/** @} *///End MCPLOADTOKEN
-
-/** @} */// End CMD
-
-/** Structure of the MCP buffer. */
-typedef union {
- initValues_t initValues; /**< initialization values. */
- commandHeader_t cmdHeader; /**< Command header. */
- responseHeader_t rspHeader; /**< Response header. */
- mcpCmdOpen_t cmdOpen; /**< Load and open service. */
- mcpRspOpen_t rspOpen; /**< Response to load and open service. */
- mcpCmdClose_t cmdClose; /**< Close command. */
- mcpRspClose_t rspClose; /**< Response to close command. */
- mcpCmdMap_t cmdMap; /**< Map WSM to service context. */
- mcpRspMap_t rspMap; /**< Response to MAP command. */
- mcpCmdUnmap_t cmdUnmap; /**< Unmap WSM from service context. */
- mcpRspUnmap_t rspUnmap; /**< Response to UNMAP command. */
- mcpCmdSuspend_t cmdSuspend; /**< Suspend MobiCore. */
- mcpRspSuspend_t rspSuspend; /**< Response to SUSPEND command. */
- mcpCmdResume_t cmdResume; /**< Resume MobiCore. */
- mcpRspResume_t rspResume; /**< Response to RESUME command. */
- mcpCmdGetMobiCoreVersion_t cmdGetMobiCoreVersion; /**< Get MobiCore Version command. */
- mcpRspGetMobiCoreVersion_t rspGetMobiCoreVersion; /**< Response to GET_MOBICORE_VERSION command. */
- mcpCmdLoadToken_t cmdLoadToken;
- mcpRspLoadToken_t rspLoadToken;
- mcpCmdCheckLoad_t cmdCheckLoad; /**< TA load check command. */
- mcpRspCheckLoad_t rspCheckLoad; /**< Response to TA load check. */
- mcpCmdMultimap_t cmdMultimap; /**< Map a list of WSM to service context. */
- mcpRspMultimap_t rspMultimap; /**< Response to MULTIMAP command. */
- mcpCmdMultiunmap_t cmdMultiunmap; /**< Map a list of WSM to service context. */
- mcpRspMultiunmap_t rspMultiunmap; /**< Response to MULTIMAP command. */
-} mcpMessage_t, *mcpMessage_ptr;
-
-
-#define MIN_MCP_LEN sizeof(mcpMessage_t) /**< Minimum MCP buffer length (in bytes). */
-
-#define MC_FLAG_NO_SLEEP_REQ 0
-#define MC_FLAG_REQ_TO_SLEEP 1
-
-#define MC_STATE_NORMAL_EXECUTION 0
-#define MC_STATE_READY_TO_SLEEP 1
-
-typedef struct {
- uint16_t SleepReq;
- uint16_t ReadyToSleep;
-} mcSleepMod_t, *mcSleepMod_ptr;
-
-/** MobiCore status flags */
-typedef struct {
- uint32_t schedule; /**< Scheduling hint: if <> MC_FLAG_SCHEDULE_IDLE, MobiCore should be scheduled by the NWd */
- mcSleepMod_t sleepMode; /**< */
- uint32_t timeout; /**< Secure-world timeout: when t-base goes to sleep, its next deadline is written here */
- uint32_t RFU3; /**< Reserved for future use: Must not be interpreted */
-} mcFlags_t, *mcFlags_ptr;
-
-#define MC_FLAG_SCHEDULE_IDLE 0 /**< MobiCore is idle. No scheduling required. */
-#define MC_FLAG_SCHEDULE_NON_IDLE 1 /**< MobiCore is non idle, scheduling is required. */
-
-
-
-/** MCP buffer structure */
-typedef struct {
- mcFlags_t mcFlags; /**< MobiCore Flags */
- mcpMessage_t mcpMessage; /**< MCP message buffer */
-} mcpBuffer_t, *mcpBuffer_ptr;
-
-/** @} */
-#endif /* MCP_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NQ_H_
-#define NQ_H_
-
-/** \name NQ Size Defines
- * Minimum and maximum count of elements in the notification queue.
- * @{ */
-#define MIN_NQ_ELEM 1 /**< Minimum notification queue elements. */
-#define MAX_NQ_ELEM 64 /**< Maximum notification queue elements. */
-/** @} */
-
-/** \name NQ Length Defines
- * Note that there is one queue for NWd->SWd and one queue for SWd->NWd
- * @{ */
-#define NQ_SIZE(n) (2*(sizeof(notificationQueueHeader_t) + (n)*sizeof(notification_t)))
-#define MIN_NQ_LEN NQ_SIZE(MIN_NQ_ELEM) /**< Minimum size for the notification queue data structure */
-#define MAX_NQ_LEN NQ_SIZE(MAX_NQ_ELEM) /**< Maximum size for the notification queue data structure */
-/** @} */
-
-/** \name Session ID Defines
- * Standard Session IDs.
- * @{ */
-#define SID_MCP 0 /**< MCP session ID is used when directly communicating with the MobiCore (e.g. for starting and stopping of trustlets). */
-#define SID_INVALID 0xffffffff /**< Invalid session id is returned in case of an error. */
-/** @} */
-
-/** Notification data structure. */
-typedef struct{
- uint32_t sessionId; /**< Session ID. */
- int32_t payload; /**< Additional notification information. */
-} notification_t;
-
-/** Notification payload codes.
- * 0 indicated a plain simple notification,
- * a positive value is a termination reason from the task,
- * a negative value is a termination reason from MobiCore.
- * Possible negative values are given below.
- */
-typedef enum {
- ERR_INVALID_EXIT_CODE = -1, /**< task terminated, but exit code is invalid */
- ERR_SESSION_CLOSE = -2, /**< task terminated due to session end, no exit code available */
- ERR_INVALID_OPERATION = -3, /**< task terminated due to invalid operation */
- ERR_INVALID_SID = -4, /**< session ID is unknown */
- ERR_SID_NOT_ACTIVE = -5, /**< session is not active */
- ERR_SESSION_KILLED = -6, /**< session was force-killed (due to an administrative command). */
-} notificationPayload_t;
-
-/** Declaration of the notification queue header.
- * layout as specified in the data structure specification.
- */
-typedef struct {
- uint32_t writeCnt; /**< Write counter. */
- uint32_t readCnt; /**< Read counter. */
- uint32_t queueSize; /**< Queue size. */
-} notificationQueueHeader_t;
-
-/** Queue struct which defines a queue object.
- * The queue struct is accessed by the queue<operation> type of
- * function. elementCnt must be a power of two and the power needs
- * to be smaller than power of uint32_t (obviously 32).
- */
-typedef struct {
- notificationQueueHeader_t hdr; /**< Queue header. */
- notification_t notification[MIN_NQ_ELEM]; /**< Notification elements. */
-} notificationQueue_t;
-
-#endif /** NQ_H_ */
-
-/** @} */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef MCDRIVER_H_
-#define MCDRIVER_H_
-
-#if (!defined(__MC_CLIENT_LIB_API)) && defined(__cplusplus)
-#define __MC_CLIENT_LIB_API extern "C"
-#else
-#define __MC_CLIENT_LIB_API
-#endif // __cplusplus
-
-
-#include <stdint.h>
-#ifndef WIN32
-#include <stdbool.h>
-#endif
-
-#include "mcUuid.h"
-#include "mcSpid.h"
-#include "mcVersionInfo.h"
-
-/*
- * MobiCore driver API error codes.
- * MAJOR part of error code is stable.
- * MCP part contains MCP result code. See MCI/mcimcp.h
- * DETAIL part may be used in testing for specific error code.
- *
- * Detail error codes may change in different releases
- * Please do not test DETAIL part when comparing error codes.
- */
-#define MC_DRV_ERROR_MAJOR(ecode) ((ecode) & 0xFF) /**< Get MAJOR part of error code. */
-#define MC_DRV_ERROR_MCP(ecode) (((ecode)>>8) & 0xFF) /**< Get MCP part of error code. */
-#define MC_DRV_ERROR_DETAIL(ecode) (((ecode)>>16) & 0x0FFF) /**< Get detail part of error code. */
-
-typedef uint32_t mcResult_t;
-/**
- * Return values of MobiCore driver functions.
- */
-#define MC_DRV_OK 0x00000000 /**< Function call succeeded. */
-#define MC_DRV_NO_NOTIFICATION 0x00000001 /**< No notification available. */
-#define MC_DRV_ERR_NOTIFICATION 0x00000002 /**< Error during notification on communication level. */
-#define MC_DRV_ERR_NOT_IMPLEMENTED 0x00000003 /**< Function not implemented. */
-#define MC_DRV_ERR_OUT_OF_RESOURCES 0x00000004 /**< No more resources available. */
-#define MC_DRV_ERR_INIT 0x00000005 /**< Driver initialization failed. */
-#define MC_DRV_ERR_UNKNOWN 0x00000006 /**< Unknown error. */
-#define MC_DRV_ERR_UNKNOWN_DEVICE 0x00000007 /**< The specified device is unknown. */
-#define MC_DRV_ERR_UNKNOWN_SESSION 0x00000008 /**< The specified session is unknown. */
-#define MC_DRV_ERR_INVALID_OPERATION 0x00000009 /**< The specified operation is not allowed. */
-#define MC_DRV_ERR_INVALID_RESPONSE 0x0000000a /**< The response header from the MC is invalid. */
-#define MC_DRV_ERR_TIMEOUT 0x0000000b /**< Function call timed out. */
-#define MC_DRV_ERR_NO_FREE_MEMORY 0x0000000c /**< Can not allocate additional memory. */
-#define MC_DRV_ERR_FREE_MEMORY_FAILED 0x0000000d /**< Free memory failed. */
-#define MC_DRV_ERR_SESSION_PENDING 0x0000000e /**< Still some open sessions pending. */
-#define MC_DRV_ERR_DAEMON_UNREACHABLE 0x0000000f /**< MC daemon not reachable */
-#define MC_DRV_ERR_INVALID_DEVICE_FILE 0x00000010 /**< The device file of the kernel module could not be opened. */
-#define MC_DRV_ERR_INVALID_PARAMETER 0x00000011 /**< Invalid parameter. */
-#define MC_DRV_ERR_KERNEL_MODULE 0x00000012 /**< Error from Kernel Module, see DETAIL for errno. */
-#define MC_DRV_ERR_BULK_MAPPING 0x00000013 /**< Error during mapping of additional bulk memory to session. */
-#define MC_DRV_ERR_BULK_UNMAPPING 0x00000014 /**< Error during unmapping of additional bulk memory to session. */
-#define MC_DRV_INFO_NOTIFICATION 0x00000015 /**< Notification received, exit code available. */
-#define MC_DRV_ERR_NQ_FAILED 0x00000016 /**< Set up of NWd connection failed. */
-
-#define MC_DRV_ERR_DAEMON_VERSION 0x00000017 /**< Wrong daemon version. */
-#define MC_DRV_ERR_CONTAINER_VERSION 0x00000018 /**< Wrong container version. */
-
-// those should become MCP or even detail codes on top of MC_DRV_ERR_MCP_ERROR
-#define MC_DRV_ERR_WRONG_PUBLIC_KEY 0x00000019 /**< System Trustlet public key is wrong. */
-#define MC_DRV_ERR_CONTAINER_TYPE_MISMATCH 0x0000001a /**< Wrong container type(s). */
-#define MC_DRV_ERR_CONTAINER_LOCKED 0x0000001b /**< Container is locked (or not activated). */
-#define MC_DRV_ERR_SP_NO_CHILD 0x0000001c /**< SPID is not registered with root container. */
-#define MC_DRV_ERR_TL_NO_CHILD 0x0000001d /**< UUID is not registered with sp container. */
-#define MC_DRV_ERR_UNWRAP_ROOT_FAILED 0x0000001e /**< Unwrapping of root container failed. */
-#define MC_DRV_ERR_UNWRAP_SP_FAILED 0x0000001f /**< Unwrapping of service provider container failed. */
-#define MC_DRV_ERR_UNWRAP_TRUSTLET_FAILED 0x00000020 /**< Unwrapping of Trustlet container failed. */
-
-// use separate numbers for those in the future
-#define MC_DRV_ERR_DEVICE_ALREADY_OPEN MC_DRV_ERR_INVALID_OPERATION /** < Device is already open. */
-#define MC_DRV_ERR_SOCKET_CONNECT MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket not reachable. */
-#define MC_DRV_ERR_SOCKET_WRITE MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket write error. */
-#define MC_DRV_ERR_SOCKET_READ MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket read error. */
-#define MC_DRV_ERR_SOCKET_LENGTH MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket read error. */
-#define MC_DRV_ERR_DAEMON_SOCKET MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon had problems with socket. */
-#define MC_DRV_ERR_DEVICE_FILE_OPEN MC_DRV_ERR_INVALID_DEVICE_FILE /**< The device file of the kernel module could not be opened. */
-#define MC_DRV_ERR_NULL_POINTER MC_DRV_ERR_INVALID_PARAMETER /**< Null pointer passed as parameter. */
-#define MC_DRV_ERR_TCI_TOO_BIG MC_DRV_ERR_INVALID_PARAMETER /**< Requested TCI length is too high. */
-#define MC_DRV_ERR_WSM_NOT_FOUND MC_DRV_ERR_INVALID_PARAMETER /**< Requested TCI was not allocated with mallocWsm(). */
-#define MC_DRV_ERR_TCI_GREATER_THAN_WSM MC_DRV_ERR_INVALID_PARAMETER /**< Requested TCI length is bigger than allocated WSM. */
-#define MC_DRV_ERR_TRUSTLET_NOT_FOUND MC_DRV_ERR_INVALID_DEVICE_FILE /** < Trustlet could not be found. */
-#define MC_DRV_ERR_TRUSTED_APPLICATION_NOT_FOUND MC_DRV_ERR_TRUSTLET_NOT_FOUND /** < Trusted Application could not be found. */
-#define MC_DRV_ERR_DAEMON_KMOD_ERROR MC_DRV_ERR_DAEMON_UNREACHABLE /**< Daemon cannot use Kernel module as expected. */
-#define MC_DRV_ERR_DAEMON_MCI_ERROR MC_DRV_ERR_DAEMON_UNREACHABLE /**< Daemon cannot use MCI as expected. */
-#define MC_DRV_ERR_MCP_ERROR MC_DRV_ERR_DAEMON_UNREACHABLE /**< MobiCore Control Protocol error. See MC_DRV_ERROR_MCP(). */
-#define MC_DRV_ERR_INVALID_LENGTH MC_DRV_ERR_NO_FREE_MEMORY /**< Invalid length. */
-#define MC_DRV_ERR_KMOD_NOT_OPEN MC_DRV_ERR_NO_FREE_MEMORY /**< Device not open. */
-#define MC_DRV_ERR_BUFFER_ALREADY_MAPPED MC_DRV_ERR_BULK_MAPPING /**< Buffer is already mapped to this Trusted Application. */
-#define MC_DRV_ERR_BLK_BUFF_NOT_FOUND MC_DRV_ERR_BULK_UNMAPPING /**< Unable to find internal handle for buffer. */
-
-#define MC_DRV_ERR_DAEMON_DEVICE_NOT_OPEN 0x00000021 /**< No device associated with connection. */
-#define MC_DRV_ERR_DAEMON_WSM_HANDLE_NOT_FOUND MC_DRV_ERR_WSM_NOT_FOUND /**< Daemon could not find WSM handle. */
-#define MC_DRV_ERR_DAEMON_UNKNOWN_SESSION MC_DRV_ERR_UNKNOWN_SESSION /**< The specified session is unknown to Daemon. */
-
-#if TBASE_API_LEVEL >= 3
-// Installation errors
-#define MC_DRV_ERR_TA_ATTESTATION_ERROR 0x00000022 /**< TA blob attestation is incorrect. */
-#endif /* TBASE_API_LEVEL */
-
-#define MC_DRV_ERR_INTERRUPTED_BY_SIGNAL 0x00000023 /**< Interrupted system call. */
-
-#if TBASE_API_LEVEL >= 5
-/**
- * Do we call these RESERVED_1, _2 etc? (as this file is public, or do we wash it?)
- */
-#define MC_DRV_ERR_SERVICE_BLOCKED 0x00000024 /**< Service is blocked and opensession is thus not allowed. */
-#define MC_DRV_ERR_SERVICE_LOCKED 0x00000025 /**< Service is locked and opensession is thus not allowed. */
-#define MC_DRV_ERR_SERVICE_KILLED 0x00000026 /**< Service was killed by the TEE (due to an administrative command). */
-#define MC_DRV_ERR_NO_FREE_INSTANCES 0x00000027 /**< All permitted instances to the service are used */
-
-#endif /* TBASE_API_LEVEL >= 5 */
-
-#if TBASE_API_LEVEL >= 3
-// Installation errors
-#define MC_DRV_ERR_TA_HEADER_ERROR 0x00000028 /**< TA blob header is incorrect. */
-#endif /* TBASE_API_LEVEL */
-
-#define MAKE_MC_DRV_MCP_ERROR(mcpCode) (MC_DRV_ERR_MCP_ERROR | ((mcpCode&0x000FFFFF)<<8))
-#define MAKE_MC_DRV_KMOD_WITH_ERRNO(theErrno) (MC_DRV_ERR_KERNEL_MODULE| (((theErrno)&0x0000FFFF)<<16))
-
-/** Structure of Session Handle, includes the Session ID and the Device ID the Session belongs to.
- * The session handle will be used for session-based t-base communication.
- * It will be passed to calls which address a communication end point in the t-base environment.
- */
-typedef struct {
- uint32_t sessionId; /**< t-base session ID */
- uint32_t deviceId; /**< Device ID the session belongs to */
-} mcSessionHandle_t;
-
-/** Information structure about additional mapped Bulk buffer between the Client Application (NWd) and
- * the Trusted Application (SWd). This structure is initialized from a Client Application by calling mcMap().
- * In order to use the memory within a Trusted Application the Client Application has to inform the Trusted Application with
- * the content of this structure via the TCI.
- */
-
-typedef struct {
-#if ( __WORDSIZE == 64 )
- uint32_t sVirtualAddr; /**< The virtual address of the Bulk buffer regarding the address space of the Trusted Application, already includes a possible offset! */
-#else
- void *sVirtualAddr;
-#endif
- uint32_t sVirtualLen; /**< Length of the mapped Bulk buffer */
-} mcBulkMap_t;
-
-
-
-#define MC_DEVICE_ID_DEFAULT 0 /**< The default device ID */
-#define MC_INFINITE_TIMEOUT ((int32_t)(-1)) /**< Wait infinite for a response of the MC. */
-#define MC_INFINITE_TIMEOUT_INTERRUPTIBLE ((int32_t)(-2)) /**< Wait infinite for a response of the MC, exit on signal. */
-#define MC_NO_TIMEOUT 0 /**< Do not wait for a response of the MC. */
-#define MC_MAX_TCI_LEN 0x100000 /**< TCI/DCI must not exceed 1MiB */
-
-#ifndef WIN32
-/* Mark only the following functions for export */
-#pragma GCC visibility push(default)
-#endif
-
-/** Open a new connection to a t-base device.
- *
- * mcOpenDevice() initializes all device specific resources required to communicate
- * with an t-base instance located on the specified device in the system. If the device
- * does not exist the function will return MC_DRV_ERR_UNKNOWN_DEVICE.
- *
- * @param [in] deviceId Identifier for the t-base device to be used. MC_DEVICE_ID_DEFAULT refers to the default device.
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_ERR_INVALID_OPERATION if device already opened.
- * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when deviceId is unknown.
- * @return MC_DRV_ERR_INVALID_DEVICE_FILE if kernel module under /dev/mobicore cannot be opened
- */
-__MC_CLIENT_LIB_API mcResult_t mcOpenDevice(
- uint32_t deviceId
-);
-
-/** Close the connection to a t-base device.
- * When closing a device, active sessions have to be closed beforehand.
- * Resources associated with the device will be released.
- * The device may be opened again after it has been closed.
- *
- * @param [in] deviceId Identifier for the t-base device. MC_DEVICE_ID_DEFAULT refers to the default device.
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
- * @return MC_DRV_ERR_SESSION_PENDING when a session is still open.
- * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
- *
- * Uses a mutex.
- */
-__MC_CLIENT_LIB_API mcResult_t mcCloseDevice(
- uint32_t deviceId
-);
-
-/** Open a new session to a Trusted Application. The Trusted Application with the given UUID has to be available in the flash filesystem.
- *
- * Write MCP open message to buffer and notify t-base about the availability of a new command.
- * Waits till t-base responds with the new session ID (stored in the MCP buffer).
- *
- * @param [in,out] session On success, the session data will be returned. Note that session.deviceId has to be the device id of an opened device.
- * @param [in] uuid UUID of the Trusted Application to be opened.
- * @param [in] tci TCI buffer for communicating with the Trusted Application.
- * @param [in] tciLen Length of the TCI buffer. Maximum allowed value is MC_MAX_TCI_LEN.
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_INVALID_PARAMETER if session parameter is invalid.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
- * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon socket occur.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when daemon returns an error.
- * @return MC_DRV_ERR_TRUSTED_APPLICATION_NOT_FOUND when Trusted Application or driver cannot be loaded.
- */
-__MC_CLIENT_LIB_API mcResult_t mcOpenSession(
- mcSessionHandle_t *session,
- const mcUuid_t *uuid,
- uint8_t *tci,
- uint32_t tciLen
-);
-
-/** Open a new session to a Trusted Application(Trustlet). The Trusted Application will be loaded from the memory buffer.
- *
- * Write MCP open message to buffer and notify t-base about the availability of a new command.
- * Waits till t-base responds with the new session ID (stored in the MCP buffer).
- *
- * @param [in,out] session On success, the session data will be returned. Note that session.deviceId has to be the device id of an opened device.
- * @param [in] spid Service Provider ID(for Service provider trustlets otherwise ignored)
- * @param [in] trustedapp memory buffer containing the Trusted Application binary
- * @param [in] tlen length of the memory buffer containing the Trusted Application
- * @param [in] tci TCI buffer for communicating with the Trusted Application.
- * @param [in] tciLen Length of the TCI buffer. Maximum allowed value is MC_MAX_TCI_LEN.
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_INVALID_PARAMETER if session parameter is invalid.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
- * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon socket occur.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when daemon returns an error.
- * @return MC_DRV_ERR_TRUSTED_APPLICATION_NOT_FOUND when Trusted Application cannot be loaded.
- */
-__MC_CLIENT_LIB_API mcResult_t mcOpenTrustlet(
- mcSessionHandle_t *session,
- mcSpid_t spid,
- uint8_t *trustedapp,
- uint32_t tLen,
- uint8_t *tci,
- uint32_t tciLen
-);
-
-
-/** Close a Trusted Application session.
- *
- * Closes the specified t-base session. The call will block until the session has been closed.
- *
- * @pre Device deviceId has to be opened in advance.
- *
- * @param [in] session Session to be closed.
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_INVALID_PARAMETER if session parameter is invalid.
- * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
- * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
- * @return MC_DRV_ERR_INVALID_DEVICE_FILE when daemon cannot open trustlet file.
- */
-__MC_CLIENT_LIB_API mcResult_t mcCloseSession(
- mcSessionHandle_t *session
-);
-
-/** Notify a session.
- * Notifies the session end point about available message data.
- * If the session parameter is correct, notify will always succeed.
- * Corresponding errors can only be received by mcWaitNotification().
- * @pre A session has to be opened in advance.
- *
- * @param session The session to be notified.
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_INVALID_PARAMETER if session parameter is invalid.
- * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
- */
-__MC_CLIENT_LIB_API mcResult_t mcNotify(
- mcSessionHandle_t *session
-);
-
-/** Wait for a notification.
- *
- * Wait for a notification issued by t-base for a specific session.
- * The timeout parameter specifies the number of milliseconds the call will wait for a notification.
- * If the caller passes 0 as timeout value the call will immediately return. If timeout value is below 0 the call will block
- * until a notification for the session has been received.
- *
- * @attention if timeout is below 0, call will block:
- * Caller has to trust the other side to send a notification to wake him up again.
- *
- * @param [in] session The session the notification should correspond to.
- * @param [in] timeout Time in milliseconds to wait (MC_NO_TIMEOUT : direct return, > 0 : milliseconds, MC_INFINITE_TIMEOUT : wait indefinitely, MC_INFINITE_TIMEOUT_INTERRUPTIBLE : wait indefinitely except if signal received)
- *
- * @return MC_DRV_OK if notification is available.
- * @return MC_DRV_ERR_TIMEOUT if no notification arrived in time.
- * @return MC_DRV_INFO_NOTIFICATION if a problem with the session was encountered. Get more details with mcGetSessionErrorCode().
- * @return MC_DRV_ERR_NOTIFICATION if a problem with the socket occurred.
- * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
- * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
- */
-__MC_CLIENT_LIB_API mcResult_t mcWaitNotification(
- mcSessionHandle_t *session,
- int32_t timeout
-);
-
-/**
- * Allocate a block of world shared memory (WSM).
- * The MC driver allocates a contiguous block of memory which can be used as WSM.
- * This implicates that the allocated memory is aligned according to the alignment parameter.
- * Always returns a buffer of size WSM_SIZE aligned to 4K.
- *
- * @param [in] deviceId The ID of an opened device to retrieve the WSM from.
- * @param [in] align The alignment (number of pages) of the memory block (e.g. 0x00000001 for 4kB).
- * @param [in] len Length of the block in bytes.
- * @param [out] wsm Virtual address of the world shared memory block.
- * @param [in] wsmFlags Platform specific flags describing the memory to be allocated.
- *
- * @attention: align and wsmFlags are currently ignored
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
- * @return MC_DRV_ERR_NO_FREE_MEMORY if no more contiguous memory is available in this size or for this process.
- *
- * Uses a mutex.
- */
-__MC_CLIENT_LIB_API mcResult_t mcMallocWsm(
- uint32_t deviceId,
- uint32_t align,
- uint32_t len,
- uint8_t **wsm,
- uint32_t wsmFlags
-);
-
-/**
- * Free a block of world shared memory (WSM).
- * The MC driver will free a block of world shared memory (WSM) previously allocated with
- * mcMallocWsm(). The caller has to assure that the address handed over to the driver
- * is a valid WSM address.
- *
- * @param [in] deviceId The ID to which the given address belongs.
- * @param [in] wsm Address of WSM block to be freed.
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
- * @return MC_DRV_ERR_FREE_MEMORY_FAILED on failures.
- *
- * Uses a mutex.
- */
-__MC_CLIENT_LIB_API mcResult_t mcFreeWsm(
- uint32_t deviceId,
- uint8_t *wsm
-);
-
-/**
- * Map additional bulk buffer between a Client Application (CA) and the Trusted Application (TA) for a session.
- * Memory allocated in user space of the CA can be mapped as additional communication channel
- * (besides TCI) to the Trusted Application. Limitation of the Trusted Application memory structure apply: only 6 chunks can be mapped
- * with a maximum chunk size of 1 MiB each.
- *
- * @attention It is up to the application layer (CA) to inform the Trusted Application about the additional mapped bulk memory.
- *
- * @param [in] session Session handle with information of the deviceId and the sessionId. The
- * given buffer is mapped to the session specified in the sessionHandle.
- * @param [in] buf Virtual address of a memory portion (relative to CA) to be shared with the Trusted Application, already includes a possible offset!
- * @param [in] len length of buffer block in bytes.
- * @param [out] mapInfo Information structure about the mapped Bulk buffer between the CA (NWd) and
- * the TA (SWd).
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
- * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
- * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
- * @return MC_DRV_ERR_BULK_MAPPING when buf is already uses as bulk buffer or when registering the buffer failed.
- */
-__MC_CLIENT_LIB_API mcResult_t mcMap(
- mcSessionHandle_t *session,
- void *buf,
- uint32_t len,
- mcBulkMap_t *mapInfo
-);
-
-/**
- * Remove additional mapped bulk buffer between Client Application (CA) and the Trusted Application (TA) for a session.
- *
- * @attention The bulk buffer will immediately be unmapped from the session context.
- * @attention The application layer (CA) must inform the TA about unmapping of the additional bulk memory before calling mcUnmap!
- *
- * @param [in] session Session handle with information of the deviceId and the sessionId. The
- * given buffer is unmapped from the session specified in the sessionHandle.
- * @param [in] buf Virtual address of a memory portion (relative to CA) shared with the TA, already includes a possible offset!
- * @param [in] mapInfo Information structure about the mapped Bulk buffer between the CA (NWd) and
- * the TA (SWd).
- * @attention The clientlib currently ignores the len field in mapInfo.
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
- * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
- * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
- * @return MC_DRV_ERR_BULK_UNMAPPING when buf was not registered earlier or when unregistering failed.
- */
-__MC_CLIENT_LIB_API mcResult_t mcUnmap(
- mcSessionHandle_t *session,
- void *buf,
- mcBulkMap_t *mapInfo
-);
-
-/**
- * Get additional error information of the last error that occurred on a session.
- * After the request the stored error code will be deleted.
- *
- * @param [in] session Session handle with information of the deviceId and the sessionId.
- * @param [out] lastErr >0 Trusted Application has terminated itself with this value, <0 Trusted Application is dead because of an error within t-base (e.g. Kernel exception).
- * See also notificationPayload_t enum in MCI definition at "mcinq.h".
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
- * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
- */
-__MC_CLIENT_LIB_API mcResult_t mcGetSessionErrorCode(
- mcSessionHandle_t *session,
- int32_t *lastErr
-);
-
-/**
- * Get t-base version information of a device.
- *
- * @param [in] deviceId of an open device.
- * @param [out] versionInfo t-base version info.
- *
- * @return MC_DRV_OK if operation has been successfully completed.
- * @return MC_DRV_ERR_UNKNOWN_DEVICE when device is not open.
- * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
- * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
- */
-__MC_CLIENT_LIB_API mcResult_t mcGetMobiCoreVersion(
- uint32_t deviceId,
- mcVersionInfo_t *versionInfo
-);
-#ifndef WIN32
-#pragma GCC visibility pop
-#endif
-#endif /** MCDRIVER_H_ */
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** Log wrapper for Android.
- * Maps LOG_*() macros to __android_log_print() if LOG_ANDROID is defined.
- * Adds some extra info to log output like LOG_TAG, file name and line number.
- */
-#ifndef TLCWRAPPERANDROIDLOG_H_
-#define TLCWRAPPERANDROIDLOG_H_
-
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#ifndef __cplusplus
-#include <stdbool.h>
-#endif
-
-#ifndef WIN32
-#include <errno.h>
-#include <unistd.h>
-#define GETPID getpid
-#else
-#include <process.h>
-#define GETPID _getpid
-#endif
-
-/** LOG_D(fmt, ...)
- * Debug information logging, only shown in debug version
- */
-
-/** LOG_I(fmt, ...)
- * Important information logging
- */
-
-/** LOG_W(fmt, ...)
- * Warnings logging
- */
-
-/** LOG_E(fmt, ...)
- * Error logging
- */
-
-/** LOG_D_BUF(szDescriptor, blob, sizeOfBlob)
- * Binary logging, line-wise output to LOG_D
- */
-
-#define DUMMY_FUNCTION() do {} while(0)
-
-#ifdef LOG_ANDROID
-#include <android/log.h>
-// log to adb logcat
-#ifdef NDEBUG // no logging in debug version
- #define LOG_D(fmt, ...) DUMMY_FUNCTION()
-#else
- // add LINE
- #define LOG_D(fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, fmt " [%s:%d]", ##__VA_ARGS__, __FILE__, __LINE__)
-#endif
- #define LOG_I(fmt, ...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, fmt " [%s:%d]", ##__VA_ARGS__, __FILE__, __LINE__)
- #define LOG_W(fmt, ...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, fmt " [%s:%d]", ##__VA_ARGS__, __FILE__, __LINE__)
- #define _LOG_E(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, fmt, ##__VA_ARGS__)
-#endif // defined(LOG_ANDROID)
-
-
-#ifdef LOG_TIZEN
-#include <dlog.h>
-#ifdef NDEBUG
- #define LOG_D(...) DUMMY_FUNCTION()
-#else
- #define LOG_D(...) SLOGD(__VA_ARGS__)
-#endif
- #define LOG_I(...) SLOGI(__VA_ARGS__)
- #define LOG_W(...) SLOGW(__VA_ARGS__)
- #define _LOG_E(...) SLOGE(__VA_ARGS__)
-#endif // defined(LOG_TIZEN)
-
-
-#if !defined(_LOG_E)
- // log using fprintf, by default to stdout
-#ifdef LOG_FPRINTF
- extern FILE* mc_log_file_;
- #define _LOG_x(_x_,...) \
- do { \
- fprintf(mc_log_file_, "%s/%s(%d): ",_x_,LOG_TAG,GETPID()); \
- fprintf(mc_log_file_, __VA_ARGS__); \
- fprintf(mc_log_file_, "\n"); \
- } while(0)
-#else // LOG_FPRINTF
- #define _LOG_x(_x_,...) \
- do { \
- printf("%s/%s(%d): ",_x_,LOG_TAG,GETPID()); \
- printf(__VA_ARGS__); \
- printf("\n"); \
- } while(0)
-#endif // !LOG_FPRINTF
-
-#ifdef NDEBUG // no logging in debug version
- #define LOG_D(fmt, ...) DUMMY_FUNCTION()
-#else
- #define LOG_D(...) _LOG_x("D",__VA_ARGS__)
-#endif
- #define LOG_I(...) _LOG_x("I",__VA_ARGS__)
- #define LOG_W(...) _LOG_x("W",__VA_ARGS__)
- #define _LOG_E(...) _LOG_x("E",__VA_ARGS__)
-#endif // !defined(_LOG_E): neither Android nor Tizen
-
-
-/** LOG_E() needs to be more prominent:
- * Display "*********** ERROR ***********" before actual error message.
- */
-#define LOG_E(...) \
- do { \
- _LOG_E(" *****************************"); \
- _LOG_E(" *** ERROR: " __VA_ARGS__); \
- _LOG_E(" *** Detected in %s:%u()", __FILE__, __LINE__); \
- _LOG_E(" *****************************"); \
- } while(0)
-
-#define LOG_ERRNO(MESSAGE) \
- LOG_E("%s failed with \"%s\"(errno %i)", MESSAGE, strerror(errno), errno);
-
-#ifdef NDEBUG
- #define LOG_D_BUF(...) DUMMY_FUNCTION()
-#else
- #define LOG_D_BUF(f, b, s) LOG_x_BUF(f, b, s, true)
-#endif
-#define LOG_I_BUF(f, b, s) LOG_x_BUF(f, b, s, false)
-
-#ifndef WIN32
-__attribute__ ((unused))
-#endif
-static void LOG_x_BUF(
- const char* szDescriptor,
- const void* blob,
- size_t sizeOfBlob,
- bool debug
-) {
-
-#define CPL 0x10 // chars per line
-#define OVERHEAD 20
-
- char buffer[CPL * 4 + OVERHEAD];
-
- int index = 0;
-
- uint32_t moreThanOneLine = (sizeOfBlob > CPL);
- size_t blockLen = CPL;
- uint32_t addr = 0;
- uint32_t i = 0;
-
- if (NULL != szDescriptor)
- {
- index += sprintf(&buffer[index], "%s", szDescriptor);
- }
-
- if (moreThanOneLine)
- {
- if (NULL == szDescriptor)
- {
- index += sprintf(&buffer[index], "memory dump");
- }
- index += sprintf(&buffer[index], " (%p, %zu bytes)", blob,sizeOfBlob);
- LOG_D("%s", buffer);
- index = 0;
- }
- else if (NULL == szDescriptor)
- {
- index += sprintf(&buffer[index], "Data at %p: ", blob);
- }
-
- if(sizeOfBlob == 0) {
- LOG_D("%s", buffer);
- }
- else
- {
- while (sizeOfBlob > 0)
- {
- if (sizeOfBlob < blockLen)
- {
- blockLen = sizeOfBlob;
- }
-
- // address
- if (moreThanOneLine)
- {
- index += sprintf(&buffer[index], "0x%08X | ",addr);
- addr += CPL;
- }
- // bytes as hex
- for (i=0; i<blockLen; ++i)
- {
- index += sprintf(&buffer[index], "%02x ", ((const unsigned char *)blob)[i] );
- }
- // spaces if necessary
- if ((blockLen < CPL) && (moreThanOneLine))
- {
- // add spaces
- for (i=0; i<(3*(CPL-blockLen)); ++i) {
- index += sprintf(&buffer[index], " ");
- }
- }
- // bytes as ASCII
- index += sprintf(&buffer[index], "| ");
- for (i=0; i<blockLen; ++i)
- {
- char c = ((const char *)blob)[i];
- index += sprintf(&buffer[index], "%c",(c>32)?c:'.');
- }
-
- blob = &(((const char *)blob)[blockLen]);
- sizeOfBlob -= blockLen;
-
- // print line to logcat / stdout
- if (debug) {
- LOG_D("%s", buffer);
- } else {
- LOG_I("%s", buffer);
- }
- index = 0;
- }
- }
-}
-
-#endif /** TLCWRAPPERANDROIDLOG_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MC_CONTAINER_H_
-#define MC_CONTAINER_H_
-
-#include <stdint.h>
-
-#include "mcRootid.h"
-#include "mcSpid.h"
-#include "mcUuid.h"
-#include "mcSo.h"
-#include "mcSuid.h"
-
-/** Support for trustlet container 2.1 */
-#define CONTAINER_FORMAT_TL21 1
-
-#define CONTAINER_VERSION_MAJOR 2
-/** Support for the old format */
-#ifdef CONTAINER_FORMAT_TL21
-#define CONTAINER_VERSION_MINOR 1
-#else
-#define CONTAINER_VERSION_MINOR 0
-#endif
-
-#define MC_CONT_SYMMETRIC_KEY_SIZE 32
-#define MC_CONT_PUBLIC_KEY_SIZE 320
-#define MC_CONT_CHILDREN_COUNT 16
-#define MC_DATA_CONT_MAX_DATA_SIZE 2048
-#define MC_TLT_CODE_HASH_SIZE 32
-
-#define MC_BYTES_TO_WORDS(bytes) ( (bytes) / sizeof(uint32_t) )
-#define MC_ENUM_32BIT_SPACER ((int32_t)-1)
-
-typedef uint32_t mcContVersion_t;
-
-/** Personalization Data ID. */
-typedef struct {
- uint32_t data;
-} mcPid_t;
-
-typedef struct {
- uint32_t keydata[MC_BYTES_TO_WORDS(MC_CONT_SYMMETRIC_KEY_SIZE)];
-} mcSymmetricKey_t;
-
-typedef struct {
- uint32_t keydata[MC_BYTES_TO_WORDS(MC_CONT_PUBLIC_KEY_SIZE)];
-} mcPublicKey_t;
-
-typedef mcSpid_t spChild_t[MC_CONT_CHILDREN_COUNT];
-
-typedef mcUuid_t mcUuidChild_t[MC_CONT_CHILDREN_COUNT];
-
-/** Content management container states. */
-typedef enum {
- /** Container state unregistered. */
- MC_CONT_STATE_UNREGISTERED = 0,
- /** Container is registered. */
- MC_CONT_STATE_REGISTERED = 1,
- /** Container is activated. */
- MC_CONT_STATE_ACTIVATED = 2,
- /** Container is locked by root. */
- MC_CONT_STATE_ROOT_LOCKED = 3,
- /** Container is locked by service provider. */
- MC_CONT_STATE_SP_LOCKED = 4,
- /** Container is locked by root and service provider. */
- MC_CONT_STATE_ROOT_SP_LOCKED = 5,
- /** Dummy: ensure that enum is 32 bits wide. */
- MC_CONT_ATTRIB_SPACER = MC_ENUM_32BIT_SPACER
-} mcContainerState_t;
-
-/** Content management container attributes. */
-typedef struct {
- mcContainerState_t state;
-} mcContainerAttribs_t;
-
-/** Container types. */
-typedef enum {
- /** SOC container. */
- CONT_TYPE_SOC = 0,
- /** Root container. */
- CONT_TYPE_ROOT = 1,
- /** Service provider container. */
- CONT_TYPE_SP = 2,
- /** Trustlet container. */
- CONT_TYPE_TLCON = 3,
- /** Service provider data. */
- CONT_TYPE_SPDATA = 4,
- /** Trustlet data. */
- CONT_TYPE_TLDATA = 5
-} contType_t;
-
-/** SHA256 checksum. */
-typedef struct {
- uint8_t data[32];
-} mcSha256_t;
-
-/** @defgroup MC_CONTAINER_CRYPTO_OBJECTS Container secrets.
- * Data that is stored encrypted within the container.
- */
-
-/** SoC secret */
-typedef struct {
- mcSymmetricKey_t kSocAuth;
-} mcCoSocCont_t;
-
-/** */
-typedef struct {
- mcSymmetricKey_t kRootAuth;
-} mcCoRootCont_t;
-
-/** */
-typedef struct {
- mcSymmetricKey_t kSpAuth;
-} mcCoSpCont_t;
-
-/** */
-typedef struct {
- mcSymmetricKey_t kTl;
-} mcCoTltCont_t;
-
-/** */
-typedef struct {
- uint8_t data[MC_DATA_CONT_MAX_DATA_SIZE];
-} mcCoDataCont_t;
-
-/** */
-typedef union {
- mcSpid_t spid;
- mcUuid_t uuid;
-} mcCid_t;
-
-/** @defgroup MC_CONTAINER_CONTAINER_OBJECTS Container definitions.
- * Container type definitions.
- */
-
-/** SoC Container */
-typedef struct {
- contType_t type;
- mcContVersion_t version;
- mcContainerAttribs_t attribs;
- mcSuid_t suid;
- // Secrets.
- mcCoSocCont_t co;
-} mcSocCont_t;
-
-/** */
-typedef struct {
- contType_t type;
- mcContVersion_t version;
- mcContainerAttribs_t attribs;
- mcSuid_t suid;
- mcRootid_t rootid;
- spChild_t children;
- // Secrets.
- mcCoRootCont_t co;
-} mcRootCont_t;
-
-/** */
-typedef struct {
- contType_t type;
- mcContVersion_t version;
- mcContainerAttribs_t attribs;
- mcSpid_t spid;
- mcUuidChild_t children;
- // Secrets.
- mcCoSpCont_t co;
-} mcSpCont_t;
-
-/** */
-typedef struct {
- contType_t type;
- mcContVersion_t version;
- mcContainerAttribs_t attribs;
- mcSpid_t parent;
- mcUuid_t uuid;
- // Secrets.
- mcCoTltCont_t co;
-} mcTltContCommon_t;
-
-/** */
-typedef struct {
- mcTltContCommon_t common;
-} mcTltCont_2_0_t;
-
-/** */
-typedef struct {
- mcTltContCommon_t common;
- mcSha256_t skSpTltEnc;
- mcContVersion_t tltVersion;
-} mcTltCont_2_1_t;
-
-/** */
-typedef struct {
- contType_t type;
- mcContVersion_t version;
- mcUuid_t uuid;
- mcPid_t pid;
- // Secrets.
- mcCoDataCont_t co;
-} mcDataCont_t;
-
-/** Helper for finding maximum value */
-#define MC_MAX(x, y) (((x)<(y))?(y):(x))
-
-/** Calculates the total size of the secure object hash and padding for a given
- * container.
- * @param contTotalSize Total size of the container (sum of plain and encrypted
- * parts).
- * @param contCoSize Size/length of the encrypted container part ("crypto
- * object").
- * @return Total size of hash and padding for given container.
- */
-#define SO_CONT_HASH_AND_PAD_SIZE(contTotalSize, contCoSize) \
- MC_MAX( MC_SO_SIZE_F21((contTotalSize) - (contCoSize), (contCoSize)) \
- - sizeof(mcSoHeader_t) - (contTotalSize), \
- MC_SO_SIZE((contTotalSize) - (contCoSize), (contCoSize)) \
- - sizeof(mcSoHeader_t) - (contTotalSize) )
-
-/** @defgroup MC_CONTAINER_SECURE_OBJECTS Containers in secure objects.
- * Secure objects wrapping different containers.
- */
-
-/** Authentication token */
-typedef struct {
- mcSoHeader_t soHeader;
- mcSocCont_t coSoc;
- uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcSocCont_t), sizeof(mcCoSocCont_t))];
-} mcSoAuthTokenCont_t;
-
-/** Root container */
-typedef struct {
- mcSoHeader_t soHeader;
- mcRootCont_t cont;
- uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcRootCont_t), sizeof(mcCoRootCont_t))];
-} mcSoRootCont_t;
-
-/** */
-typedef struct {
- mcSoHeader_t soHeader;
- mcSpCont_t cont;
- uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcSpCont_t), sizeof(mcCoSpCont_t))];
-} mcSoSpCont_t;
-
-/** */
-typedef struct {
- mcSoHeader_t soHeader;
- mcTltCont_2_0_t cont;
- uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcTltCont_2_0_t), sizeof(mcCoTltCont_t))];
-} mcSoTltCont_2_0_t;
-
-typedef struct {
- mcSoHeader_t soHeader;
- mcTltCont_2_1_t cont;
- uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcTltCont_2_1_t), sizeof(mcCoTltCont_t))];
-} mcSoTltCont_2_1_t;
-
-#ifdef CONTAINER_FORMAT_TL21
-typedef mcSoTltCont_2_0_t mcSoTltCont_t;
-#else
-typedef mcTltContCommon_t mcTltCont_t;
-
-typedef struct {
- mcSoHeader_t soHeader;
- mcTltCont_t cont;
- uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcTltCont_t), sizeof(mcCoTltCont_t))];
-} mcSoTltCont_t ;
-#endif
-
-/** */
-typedef struct {
- mcSoHeader_t soHeader;
- mcDataCont_t cont;
- uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcDataCont_t), sizeof(mcCoDataCont_t))];
-} mcSoDataCont_t;
-
-/** Trustlet Blob length info */
-typedef struct {
- uint32_t magic; /**< New blob format magic number*/
- uint32_t rootContBlobSize; /**< Root container blob size */
- uint32_t spContBlobSize; /**< SP container blob size */
- uint32_t tlContBlobSize; /**< Tl container blob size */
- uint32_t reserved[4]; /**< Reserved for further Use */
-} mcBlobLenInfo_t, *mcBlobLenInfo_ptr;
-
-#define MC_TLBLOBLEN_MAGIC 0x7672746C
-
-#endif // MC_CONTAINER_H_
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef RTMDRVID_H_
-#define RTMDRVID_H_
-
-#define MC_DRV_VENDOR_ID_SHIFT (16)
-#define MC_DRV_VENDOR_ID_MASK (0xFFFF << MC_DRV_VENDOR_ID_SHIFT)
-#define MC_DRV_NUMBER_MASK (0x0000FFFF)
-
-/** MobiCore vendor IDs. */
-typedef enum {
- MC_DRV_VENDOR_ID_GD = 0 << MC_DRV_VENDOR_ID_SHIFT,
-} mcDrvVendorId_t;
-
-/** MobiCore GD driver numbers. */
-typedef enum {
- MC_DRV_NUMBER_INVALID = 0,
- MC_DRV_NUMBER_CRYPTO = 1,
- /** Last GD driver number reserved for pre-installed drivers.
- * GD driver numbers up to this constant may not be used for loadable drivers. */
- MC_DRV_NUMBER_LAST_PRE_INSTALLED = 100,
- TB_DRV_NUMBER_TUI = 0x101,
- TB_DRV_NUMBER_SFS = 0x104,
- TB_DRV_NUMBER_TPLAY = 0x600,
-} mcDrvNumber_t;
-
-/** MobiCore driver IDs for Trustlets. */
-typedef enum {
- MC_DRV_ID_INVALID = MC_DRV_VENDOR_ID_GD | MC_DRV_NUMBER_INVALID,
- MC_DRV_ID_CRYPTO = MC_DRV_VENDOR_ID_GD | MC_DRV_NUMBER_CRYPTO,
- MC_DRV_ID_SFS = MC_DRV_VENDOR_ID_GD | TB_DRV_NUMBER_SFS,
- /** Last GD driver ID reserved for pre-installed drivers.
- * GD driver IDs up to this constant may not be used for loadable drivers. */
- MC_DRV_ID_LAST_PRE_INSTALLED = MC_DRV_VENDOR_ID_GD | MC_DRV_NUMBER_LAST_PRE_INSTALLED,
- TB_DRV_ID_TUI = MC_DRV_VENDOR_ID_GD | TB_DRV_NUMBER_TUI,
- TB_DRV_ID_TPLAY = MC_DRV_VENDOR_ID_GD | TB_DRV_NUMBER_TPLAY,
-} mcDriverId_t;
-
-#endif /* RTMDRVID_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef MCLOADFORMAT_H_
-#define MCLOADFORMAT_H_
-
-#include "mcUuid.h"
-#include "mcSuid.h"
-#include "mcDriverId.h"
-
-#define MCLF_VERSION_MAJOR 2
-#define MCLF_VERSION_MINOR 5
-#define MCLF_VERSION_MINOR_CURRENT 3
-
-#define MC_SERVICE_HEADER_MAGIC_BE ((uint32_t)('M'|('C'<<8)|('L'<<16)|('F'<<24))) /**< "MCLF" in big endian integer representation */
-#define MC_SERVICE_HEADER_MAGIC_LE ((uint32_t)(('M'<<24)|('C'<<16)|('L'<<8)|'F')) /**< "MCLF" in little endian integer representation */
-#define MC_SERVICE_HEADER_MAGIC_STR "MCLF" /**< "MCLF" as string */
-
-/** @name MCLF flags */
-#define MC_SERVICE_HEADER_FLAGS_PERMANENT (1U << 0) /**< Loaded service cannot be unloaded from MobiCore. */
-#define MC_SERVICE_HEADER_FLAGS_NO_CONTROL_INTERFACE (1U << 1) /**< Service has no WSM control interface. */
-#define MC_SERVICE_HEADER_FLAGS_DEBUGGABLE (1U << 2) /**< Service can be debugged. */
-#define MC_SERVICE_HEADER_FLAGS_EXTENDED_LAYOUT (1U << 3) /**< New-layout trusted application or trusted driver. */
-
-
-/** Service type.
- * The service type defines the type of executable.
- */
-typedef enum {
- SERVICE_TYPE_ILLEGAL = 0, /**< Service type is invalid. */
- SERVICE_TYPE_DRIVER = 1, /**< Service is a driver. */
- SERVICE_TYPE_SP_TRUSTLET = 2, /**< Service is a Trustlet. */
- SERVICE_TYPE_SYSTEM_TRUSTLET = 3, /**< Service is a system Trustlet. */
- SERVICE_TYPE_MIDDLEWARE = 4, /**< Service is a middleware. */
- SERVICE_TYPE_LAST_ENTRY = 5, /**< marker for last entry */
-} serviceType_t;
-
-/**
- * Memory types.
- */
-typedef enum {
- MCLF_MEM_TYPE_INTERNAL_PREFERRED = 0, /**< If available use internal memory; otherwise external memory. */
- MCLF_MEM_TYPE_INTERNAL = 1, /**< Internal memory must be used for executing the service. */
- MCLF_MEM_TYPE_EXTERNAL = 2, /**< External memory must be used for executing the service. */
-} memType_t;
-
-/**
- * Descriptor for a memory segment.
- */
-typedef struct {
- uint32_t start; /**< Virtual start address. */
- uint32_t len; /**< Length of the segment in bytes. */
-} segmentDescriptor_t, *segmentDescriptor_ptr;
-
-/**
- * MCLF intro for data structure identification.
- * Must be the first element of a valid MCLF file.
- */
-typedef struct {
- uint32_t magic; /**< Header magic value ASCII "MCLF". */
- uint32_t version; /**< Version of the MCLF header structure. */
-} mclfIntro_t, *mclfIntro_ptr;
-
-
-// Version 2 /////////////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * @defgroup MCLF_VER_V2 MCLF Version 32
- * @ingroup MCLF_VER
- *
- * @addtogroup MCLF_VER_V2
- */
-
-/**
- * Version 2.1/2.2 MCLF header.
- */
-typedef struct {
- mclfIntro_t intro; /**< MCLF header start with the mandatory intro. */
- uint32_t flags; /**< Service flags. */
- memType_t memType; /**< Type of memory the service must be executed from. */
- serviceType_t serviceType; /**< Type of service. */
-
- uint32_t numInstances; /**< Number of instances which can be run simultaneously. */
- mcUuid_t uuid; /**< Loadable service unique identifier (UUID). */
- mcDriverId_t driverId; /**< If the serviceType is SERVICE_TYPE_DRIVER the Driver ID is used. */
- uint32_t numThreads; /**<
- * <pre>
- * <br>Number of threads (N) in a service depending on service type.<br>
- *
- * SERVICE_TYPE_SP_TRUSTLET: N = 1
- * SERVICE_TYPE_SYSTEM_TRUSTLET: N = 1
- * SERVICE_TYPE_DRIVER: N >= 1
- * </pre>
- */
- segmentDescriptor_t text; /**< Virtual text segment. */
- segmentDescriptor_t data; /**< Virtual data segment. */
- uint32_t bssLen; /**< Length of the BSS segment in bytes. MUST be at least 8 byte. */
- uint32_t entry; /**< Virtual start address of service code. */
- uint32_t serviceVersion; /**< Version of the interface the driver exports. */
-
-// These should be put on next MCLF update:
-// mcSuid_t permittedSuid; /**< Starting 2.3: If nonzero, suid which is allowed to execute binary */
-// uint32_t permittedHwCf; /**< Starting 2.3: If nonzero, hw configuration which is allowed to execute binary */
-
-} mclfHeaderV2_t, *mclfHeaderV2_ptr;
-
-
-/**
- * Version 2.3 MCLF header.
- */
-typedef struct {
- mclfHeaderV2_t mclfHeaderV2;
- mcSuid_t permittedSuid; /**< Starting 2.3: If nonzero, suid which is allowed to execute binary */
- uint32_t permittedHwCfg; /**< Starting 2.3: If nonzero, hw configuration which is allowed to execute binary */
-} mclfHeaderV23_t, *mclfHeaderV23_ptr;
-
-
-/**
- * Version 2.4 MCLF header.
- */
-typedef struct {
- mclfHeaderV23_t mclfHeaderV2;
- uint32_t gp_level; /**<Starting 2.4: 0 for legacy MobiCore trustlets and 1 for Potato TAs. */
- uint32_t attestationOffset; /**<Starting 2.4: Offset of attestation data area. */
-
-} mclfHeaderV24_t, *mclfHeaderV24_ptr;
-
-
-
-/*
- * HEAP parameters
- */
-
-typedef struct {
- uint32_t init;
- uint32_t max;
-} heapSize_t, *heapSize_ptr;
-
-/*
- * McLib Internal Management Data
- * This structure defines the parameters of a buffer used internally by McLib for each TA/TDriver
- * and it specifies default heap parameters (for MCLF header versions >=2.5)
- *
- * `mcLibData` field describes McLib work buffer
- * and it is used for MCLF header versions <=2.4
- * In this case the buffer is a part of TA BSS section
- *
- * For MCLF header versions >=2.5 `mcLibData` field is not used anymore and
- * replaced by `mcLibData` field
- * RTM itself determines actual address in this case and sets `mcLibData` field value
- *
- * `heapSize` field describes default heap parameters and
- * it is used only for MCLF header versions >=2.5
- *
- */
-typedef struct {
- union {
- segmentDescriptor_t mcLibData; /**< Segment for McLib data.
- Set at compile time.
- Required always. */
- heapSize_t heapSize; /**< Initial and maximum heap sizes.
- Set by MobiConvert for extended-layout TAs */
- } cfg;
- uint32_t mcLibBase; /**< McLib base address.
- Mobicore sets at load time for trustlets / drivers.
- Required always. */
-} mclfIMD_t, *mclfIMD_ptr;
-
-
-/*
- * GP TA identity.
- */
-typedef struct {
- uint32_t loginType; /**< GP TA login type */
- uint8_t loginData[16]; /**< GP TA login data */
-} mcIdentity_t;
-
-/**
- * Version 2 MCLF text segment header.
- * Required to be present in MobiCore 1.2 components at address (0x1080).
- * This extension is initialized already at trustlet compile time,
- * but may be modified later by configuration tools and by MobiCore at load time.
- */
-typedef struct {
- uint32_t version; /**< Version of the TextHeader structure. */
- uint32_t textHeaderLen; /**< Size of this structure (fixed at compile time) */
- uint32_t requiredFeat; /**< Flags to indicate features that Mobicore must understand/interprete when loading.
- Required always. */
- uint32_t mcLibEntry; /**< Address for McLib entry.
- Mobicore sets at load time for trustlets / drivers.
- Required always. */
- mclfIMD_t mcIMD; /**< McLib Internal Management Data */
- uint32_t tlApiVers; /**< TlApi version used when building trustlet.
- Value set at compile time.
- Required always. */
- uint32_t drApiVers; /**< DrApi version used when building trustlet.
- Value set at compile time for drivers. 0 for trustlets.
- Required always. */
- uint32_t ta_properties; /**< address of _TA_Properties in the TA. */
- mcIdentity_t mcIdentity; /**< Identity of GP TA */
-} mclfTextHeader_t, *mclfTextHeader_ptr;
-
-// Version 2 ///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * @addtogroup MCLF
- */
-
-/** MCLF header */
-typedef union {
- mclfIntro_t intro; /**< Intro for data structure identification. */
- mclfHeaderV2_t mclfHeaderV2; /**< Version 2 header */
-} mclfHeader_t, *mclfHeader_ptr;
-
-// Version 2.3 changes header definition
-// Above structure is hard-coded into many places.
-// So new changes are made into separate structure.
-#define MCLF_HEADER_SIZE_V23 (0x080)
-
-// Actual (known) length can be calculated using macro
-#define MCLF_HEADER_SIZE(version) ((version)>0x20002?(MCLF_HEADER_SIZE_V23):sizeof(mclfHeader_t))
-
-// This is only minimum size, so nothing below this makes sense.
-#define MCLF_BINARY_MIN_SIZE(version) (MCLF_HEADER_SIZE_V23+sizeof(mclfTextHeader_t))
-
-/** mclfTlHeader: layout of TA start */
-typedef struct {
- mclfIntro_t intro;
- uint8_t mclfHeader[0x80-sizeof(mclfIntro_t)];
- mclfTextHeader_t textHeader;
-} mclfTlHeader_t;
-
-#endif /* MCLOADFORMAT_H_ */
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MC_ROOTID_H_
-#define MC_ROOTID_H_
-
-#ifdef WIN32
-#define _UNUSED
-#else
-#define _UNUSED __attribute__((unused))
-#endif
-
-/** Root Identifier type. */
-typedef uint32_t mcRootid_t;
-
-/** Reserved root id value 1. */
-static _UNUSED const mcRootid_t MC_ROOTID_RESERVED1 = 0;
-
-/** Reserved root id value 2. */
-static _UNUSED const mcRootid_t MC_ROOTID_RESERVED2 = 0xFFFFFFFF;
-
-/** Root id for system applications. */
-static _UNUSED const mcRootid_t MC_ROOTID_SYSTEM = 0xFFFFFFFE;
-
-/** Yet another test ROOT ID */
-static _UNUSED const mcRootid_t MC_ROOTID_RESERVED3 = 0xFFFFFFFD;
-
-/** GP TAs - used in the Trusted storage */
-static _UNUSED const mcRootid_t MC_ROOTID_GP = 0xFFFFFFFC;
-
-/** RTM's Root ID */
-static _UNUSED const mcRootid_t MC_ROOTID_RTM = 0xFFFFFFFB;
-
-#endif // MC_ROOTID_H_
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MC_SO_H_
-#define MC_SO_H_
-
-#include "mcUuid.h"
-#include "mcSpid.h"
-#include "mcRootid.h"
-
-#define SO_USE_VERSION_22 1
-
-#define SO_VERSION_MAJOR 2
-#define SO_VERSION_MINOR 2
-
-#define MC_ENUM_32BIT_SPACER ((int32_t)-1)
-
-/** Secure object type. */
-typedef enum {
- /** Regular secure object. */
- MC_SO_TYPE_REGULAR = 0x00000001,
- /** Dummy to ensure that enum is 32 bit wide. */
- MC_SO_TYPE_DUMMY = MC_ENUM_32BIT_SPACER,
-} mcSoType_t;
-
-
-/** Secure object context.
- * A context defines which key to use to encrypt/decrypt a secure object.
- */
-typedef enum {
- /** Trustlet context. */
- MC_SO_CONTEXT_TLT = 0x00000001,
- /** Service provider context. */
- MC_SO_CONTEXT_SP = 0x00000002,
- /** Device context. */
- MC_SO_CONTEXT_DEVICE = 0x00000003,
- /** Dummy to ensure that enum is 32 bit wide. */
- MC_SO_CONTEXT_DUMMY = MC_ENUM_32BIT_SPACER,
-} mcSoContext_t;
-
-/** Secure object lifetime.
- * A lifetime defines how long a secure object is valid.
- */
-typedef enum {
- /** SO does not expire. */
- MC_SO_LIFETIME_PERMANENT = 0x00000000,
- /** SO expires on reboot (coldboot). */
- MC_SO_LIFETIME_POWERCYCLE = 0x00000001,
- /** SO expires when Trustlet is closed. */
- MC_SO_LIFETIME_SESSION = 0x00000002,
- /** Dummy to ensure that enum is 32 bit wide. */
- MC_SO_LIFETIME_DUMMY = MC_ENUM_32BIT_SPACER,
-} mcSoLifeTime_t;
-
-/** Service provider Trustlet id.
- * The combination of service provider id and Trustlet UUID forms a unique
- * Trustlet identifier.
- */
-typedef struct {
- /** Service provider id. */
- mcSpid_t spid;
- /** Trustlet UUID. */
- mcUuid_t uuid;
-} tlApiSpTrustletId_t;
-
-/** Service provider Trustlet id with specific RootId.
- */
-typedef struct {
- /** Service provider id. */
- mcSpid_t spid;
- /** Trustlet UUID. */
- mcUuid_t uuid;
- /** Trustlet RootId. */
- mcRootid_t rootid;
-} tlApiSpTrustletIdEx_t;
-
-// The client identity (encoding its root ID, SPID and UUID).
-typedef tlApiSpTrustletIdEx_t client_identity_t;
-
-/** Secure object header v2.2.
- * A secure object header introduces a secure object.
- * Layout of a secure object:
- * <pre>
- * <code>
- *
- * +--------+------------------+------------------+--------+--------+
- * | Header | plain-data | encrypted-data | hash | random |
- * +--------+------------------+------------------+--------+--------+
- *
- * /--------/---- plainLen ----/-- encryptedLen --/-- 32 --/-- 16 --/
- *
- * /----------------- toBeHashedLen --------------/
- *
- * /-- toBeEncryptedLen --/
- *
- * /--------------------------- totalSoSize ------------------------/
- *
- * </code>
- * </pre>
- */
-
-/** Secure object header v2.1.
- * A secure object header introduces a secure object.
- * Layout of a secure object:
- * <pre>
- * <code>
- *
- * +--------+------------------+------------------+--------+--------+---------+
- * | Header | plain-data | encrypted-data | hash | random | padding |
- * +--------+------------------+------------------+--------+--------+---------+
- *
- * /--------/---- plainLen ----/-- encryptedLen --/-- 24 --/--- 9 --/- 0..15 -/
- *
- * /----------------- toBeHashedLen --------------/
- *
- * /-- toBeEncryptedLen --/
- *
- * /--------------------------- totalSoSize ----------------------------------/
- *
- * </code>
- * </pre>
- */
-
-/** Secure object header v2.0.
- * A secure object header introduces a secure object.
- * Layout of a secure object:
- * <pre>
- * <code>
- *
- * +--------+------------------+------------------+--------+---------+
- * | Header | plain-data | encrypted-data | hash | padding |
- * +--------+------------------+------------------+--------+---------+
- *
- * /--------/---- plainLen ----/-- encryptedLen --/-- 32 --/- 1..16 -/
- *
- * /----------------- toBeHashedLen --------------/
- *
- * /---------- toBeEncryptedLen ---------/
- *
- * /--------------------------- totalSoSize -------------------------/
- *
- * </code>
- * </pre>
- */
-typedef struct {
- /** Type of secure object. */
- uint32_t type;
- /** Secure object version. */
- uint32_t version;
- /** Secure object context. */
- mcSoContext_t context;
- /** Secure object lifetime. */
- mcSoLifeTime_t lifetime;
- /** Producer Trustlet id. */
- tlApiSpTrustletId_t producer;
- /** Length of unencrypted user data (after the header). */
- uint32_t plainLen;
- /** Length of encrypted user data (after unencrypted data, excl. checksum
- * and excl. padding bytes). */
- uint32_t encryptedLen;
-} mcSoHeader_t;
-
-/** Maximum size of the payload (plain length + encrypted length) of a secure object. */
-#define MC_SO_PAYLOAD_MAX_SIZE 1000000
-
-/** Block size of encryption algorithm used for secure objects. */
-#define MC_SO_ENCRYPT_BLOCK_SIZE 16
-
-/** Maximum number of ISO padding bytes. */
-#define MC_SO_MAX_PADDING_SIZE (MC_SO_ENCRYPT_BLOCK_SIZE)
-
-/** Size of hash used for secure objects v2. */
-#define MC_SO_HASH_SIZE 32
-
-/** Size of hash used for secure object v2.1. */
-#define MC_SO21_HASH_SIZE 24
-/** Size of random used for secure objects v2.1. */
-#define MC_SO21_RND_SIZE 9
-
-/** Size of hash used for secure object v2.2. */
-#define MC_SO22_HASH_SIZE 32
-/** Size of random used for secure objects v2.2. */
-#define MC_SO22_RND_SIZE 16
-
-/** Hash size for current generated wrapping */
-#define MC_SO2X_HASH_SIZE MC_SO22_HASH_SIZE
-/** Random size for current generated wrapping */
-#define MC_SO2X_RND_SIZE MC_SO22_RND_SIZE
-
-#define MC_SO_ENCRYPT_PADDED_SIZE_F21(netsize) ( (netsize) + \
- MC_SO_MAX_PADDING_SIZE - (netsize) % MC_SO_MAX_PADDING_SIZE )
-
-#if SO_USE_VERSION_22
- // No encryption padding at all.
-#else
- /** Calculates gross size of cryptogram within secure object including ISO padding bytes. */
- #define MC_SO_ENCRYPT_PADDED_SIZE(netsize) MC_SO_ENCRYPT_PADDED_SIZE_F21(netsize)
-#endif
-
-
-/** Calculates the total size of a secure object.
- * @param plainLen Length of plain text part within secure object.
- * @param encryptedLen Length of encrypted part within secure object (excl.
- * hash, padding).
- * @return Total (gross) size of the secure object or 0 if given parameters are
- * illegal or would lead to a secure object of invalid size.
- */
-#define MC_SO_SIZE_F22(plainLen, encryptedLen) ( \
- ((plainLen) + (encryptedLen) < (encryptedLen) || (plainLen) + (encryptedLen) > MC_SO_PAYLOAD_MAX_SIZE) ? 0 : \
- sizeof(mcSoHeader_t) + (plainLen) + (encryptedLen) +MC_SO22_HASH_SIZE +MC_SO22_RND_SIZE \
- )
-#define MC_SO_SIZE_F21(plainLen, encryptedLen) ( \
- ((plainLen) + (encryptedLen) < (encryptedLen) || (plainLen) + (encryptedLen) > MC_SO_PAYLOAD_MAX_SIZE) ? 0 : \
- sizeof(mcSoHeader_t) +(plainLen) +MC_SO_ENCRYPT_PADDED_SIZE_F21((encryptedLen) +MC_SO_HASH_SIZE) \
-)
-
-#define MC_SO_SIZE(plainLen, encryptedLen) MC_SO_SIZE_F22(plainLen, encryptedLen)
-
-#endif // MC_SO_H_
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MC_SPID_H_
-#define MC_SPID_H_
-
-#ifdef WIN32
-#define _UNUSED
-#else
-#define _UNUSED __attribute__((unused))
-#endif
-
-/** Service provider Identifier type. */
-typedef uint32_t mcSpid_t;
-
-/** SPID value used as free marker in root containers. */
-static _UNUSED const mcSpid_t MC_SPID_FREE = 0xFFFFFFFF;
-
-/** Reserved SPID value. */
-static _UNUSED const mcSpid_t MC_SPID_RESERVED = 0;
-
-/** SPID for system applications. */
-static _UNUSED const mcSpid_t MC_SPID_SYSTEM = 0xFFFFFFFE;
-
-/** SPID reserved for tests only */
-static _UNUSED const mcSpid_t MC_SPID_RESERVED_TEST = 0xFFFFFFFD;
-static _UNUSED const mcSpid_t MC_SPID_TRUSTONIC_TEST = 0x4;
-
-/** SPID reserved for OTA development */
-static _UNUSED const mcSpid_t MC_SPID_TRUSTONIC_OTA = 0x2A;
-
-/** GP TAs - stored in the trusted storage. They all share the same */
-static _UNUSED const mcSpid_t MC_SPID_GP = 0xFFFFFFFC;
-
-/** RTM's SPID */
-static _UNUSED const mcSpid_t MC_SPID_RTM = 0xFFFFFFFB;
-
-#endif // MC_SPID_H_
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MC_SUID_H_
-#define MC_SUID_H_
-
-/** Length of SUID. */
-#define MC_SUID_LEN 16
-
-/** Platform specific device identifier (serial number of the chip). */
-typedef struct {
- uint8_t data[MC_SUID_LEN - sizeof(uint32_t)];
-} suidData_t;
-
-/** Soc unique identifier type. */
-typedef struct {
- uint32_t sipId; /**< Silicon Provider ID to be set during build. */
- suidData_t suidData;
-} mcSuid_t;
-
-#endif // MC_SUID_H_
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MC_UUID_H_
-#define MC_UUID_H_
-
-#ifdef WIN32
-#define _UNUSED
-#else
-#define _UNUSED __attribute__((unused))
-#endif
-
-#define UUID_TYPE
-
-#define UUID_LENGTH 16
-/** Universally Unique Identifier (UUID) according to ISO/IEC 11578. */
-typedef struct {
- uint8_t value[UUID_LENGTH]; /**< Value of the UUID. */
-} mcUuid_t, *mcUuid_ptr;
-
-/** UUID value used as free marker in service provider containers. */
-#define MC_UUID_FREE_DEFINE \
- { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
-
-static _UNUSED const mcUuid_t MC_UUID_FREE = {
- MC_UUID_FREE_DEFINE
-};
-
-/** Reserved UUID. */
-#define MC_UUID_RESERVED_DEFINE \
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
-
-static _UNUSED const mcUuid_t MC_UUID_RESERVED = {
- MC_UUID_RESERVED_DEFINE
-};
-
-/** UUID for system applications. */
-#define MC_UUID_SYSTEM_DEFINE \
- { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE }
-
-static _UNUSED const mcUuid_t MC_UUID_SYSTEM = {
- MC_UUID_SYSTEM_DEFINE
-};
-
-#define MC_UUID_RTM_DEFINE \
- { 0x12, 0x34, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34, \
- 0x12, 0x34, 0x12, 0x34, 0x12, 0x34, 0x12, 0x34 }
-
-static _UNUSED const mcUuid_t MC_UUID_RTM = {
- MC_UUID_RTM_DEFINE
-};
-
-/**
- * TODO: Replace with v5 UUID (milestone #3)
- */
-#define LTA_UUID_DEFINE \
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
- 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11}
-
-#endif // MC_UUID_H_
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MCVERSIONHELPER_H_
-#define MCVERSIONHELPER_H_
-
-#include <stdio.h>
-
-
-/** Create a version number given major and minor numbers. */
-#define MC_MAKE_VERSION(major,minor) \
- ( (((major) & 0xffff) << 16) |\
- ((minor) & 0xffff))
-
-/** Get major version number from complete version. */
-#define MC_GET_MAJOR_VERSION(version) ((version) >> 16)
-
-/** Get minor version number from complete version. */
-#define MC_GET_MINOR_VERSION(version) ((version) & 0xffff)
-
-// Asserts expression at compile-time (to be used outside a function body).
-#define ASSERT_VERSION_IMPLEMENTATION(comp, versionpart, requiredV, actualV, expression) \
- extern int Actual_##comp##_##versionpart##_VERSION_##actualV##_does_not_match_required_version_##requiredV[(expression) ? 0:-1]
-
-#define ASSERT_VERSION_EVALUATOR(comp, versionpart, requiredV, actualV, expression) \
- ASSERT_VERSION_IMPLEMENTATION(comp, versionpart, requiredV, actualV, expression)
-
-#define ASSERT_VERSION(required, comparator, comp, versionpart) \
- ASSERT_VERSION_EVALUATOR(comp, versionpart, required, comp ##_VERSION_## versionpart, required comparator comp ##_VERSION_## versionpart)
-
-/** Checks at compile-time that an interface version provided by component
- * 'comp' is identical to the required version of a component using this interface.
- * Note! This check is useful for components that IMPLEMENT a particular
- * interface to be alerted of changes to the interface which are likely to
- * require adaptations in the implementation. */
-#define MC_CHECK_VERSION_EQUALS(comp, major, minor) \
- ASSERT_VERSION(major, ==, comp, MAJOR); \
- ASSERT_VERSION(minor, ==, comp, MINOR);
-
-/** Checks at compile-time that an interface version provided by component 'comp' meets the
- * required version of a component using this interface. */
-#define MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
- ASSERT_VERSION(majorRequired, ==, comp, MAJOR); \
- ASSERT_VERSION(minorRequired, <=, comp, MINOR);
-
-/** Version check helper macro for an interface consumer against an interface
- * provider.
- * @param comp Name of Interface to check.
- * @param majorRequired Required major version of interface provider.
- * @param minorRequired Required minor version of interface provider.
- * Performs a compile-time interface version check that comp_VERSION_MAJOR
- * equals majorRequired and that comp_VERSION_MINOR is at least minorRequired.
- * On success, compilation goes through.
- * On error, compilation breaks, telling the component that did not match in the
- * error message.
- *
- * Additionally, a function is created:
- *
- * checkVersionOk##component(uint32_t version, char** errmsg)
- *
- * Compares version against majorRequired and minorRequired.
- * Additionally, it creates a message string that can be printed out using printf("%s", errmsg).
- * It returns either only the actual version, or on mismatch, actual and required version.
- *
- * @param version[in] component version as returned by layer-specific getVersion.
- * @param errmsg[out] a message string that contains a log.
- *
- */
-#if !defined(NDEBUG)
-#if !defined(TRUSTLET)
-#define MC_CHECK_VERSION(comp, majorRequired, minorRequired) \
- MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
- static uint32_t checkVersionOk##comp(uint32_t version, char** errmsg) { \
- static char msgBuf[100]; \
- uint32_t major = MC_GET_MAJOR_VERSION(version); \
- uint32_t minor = MC_GET_MINOR_VERSION(version); \
- uint32_t ret = 0; \
- *errmsg = msgBuf; \
- /* Check equality and superiority separately to avoid warning if minor == 0 */ \
- if ((major == majorRequired) && ((minor == minorRequired) || (minor > minorRequired))) { \
- snprintf(msgBuf, sizeof(msgBuf), \
- #comp " version is %u.%u", major, minor); \
- ret = 1; \
- } else { \
- snprintf(msgBuf, sizeof(msgBuf), \
- #comp " version error. Got: %u.%u, want >= %u.%u", major, minor, majorRequired, minorRequired); \
- } \
- msgBuf[sizeof(msgBuf) - 1] = '\0'; \
- return ret; \
- }
-#else /* TRUSTLET */
-#define MC_CHECK_VERSION(comp, majorRequired, minorRequired) \
- MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
- static uint32_t checkVersionOk##comp(uint32_t version, char** errmsg) { \
- uint32_t major = MC_GET_MAJOR_VERSION(version); \
- uint32_t minor = MC_GET_MINOR_VERSION(version); \
- *errmsg = NULL; \
- if ((major == majorRequired) && (minor >= minorRequired)) { \
- tlDbgPrintf(#comp " version is %u.%u", major, minor); \
- return 1; \
- } else { \
- tlDbgPrintf( \
- #comp " version error. Got: %u.%u, want >= %u.%u", major, minor, majorRequired, minorRequired); \
- } \
- return 0; \
- }
-#endif /* TRUSTLET */
-#else
-#define MC_CHECK_VERSION(comp, majorRequired, minorRequired) \
- MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
- static uint32_t checkVersionOk##comp(uint32_t version, char** errmsg) { \
- uint32_t major = MC_GET_MAJOR_VERSION(version); \
- uint32_t minor = MC_GET_MINOR_VERSION(version); \
- *errmsg = NULL; \
- /* Check equality and superiority separately to avoid warning if minor == 0 */ \
- if ((major == majorRequired) && ((minor == minorRequired) || (minor > minorRequired))) { \
- return 1; \
- }; \
- return 0; \
- }
-#endif
-
-/** Version check helper macro for version checks of a data object version
- * against an data object consumer.
- *
- * @param comp Name of Interface to check.
- * @param majorRequired Major data object version supported by component.
- * @param minorRequired Minor data object version supported by component.
- * Performs a compile-time interface version check that comp_VERSION_MAJOR
- * equals majorRequired and that comp_VERSION_MINOR is at least minorRequired.
- * On success, compilation goes through.
- * On error, compilation breaks, telling the component that did not match in the
- * error message.
- *
- * Additionally, the following function is created:
- *
- * checkVersionOkDataObject##component(uint32_t version, char** errmsg)
- *
- * This function checks that the data object version is compatible with the
- * interface version; that is, the major version of the data object must match
- * exactly and the minor version of the data object MUST BE LESS OR EQUAL to the
- * required interface version.
- * Additionally, it creates a message string that can be printed out using printf("%s", errmsg).
- * It returns either only the actual version, or on mismatch, actual and
- * provided version.
- *
- * @param version[in] Data object version of data object.
- * @param errmsg[out] a message string that contains a log.
- *
- */
-#if !defined(NDEBUG)
-#if !defined(TRUSTLET)
-#define MC_CHECK_DATA_OBJECT_VERSION(comp, majorRequired, minorRequired) \
- MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
- static uint32_t checkVersionOkDataObject##comp(uint32_t version, char** errmsg) { \
- static char msgBuf[100]; \
- uint32_t major = MC_GET_MAJOR_VERSION(version); \
- uint32_t minor = MC_GET_MINOR_VERSION(version); \
- uint32_t ret = 0; \
- *errmsg = msgBuf; \
- if ((major == majorRequired) && (minor <= minorRequired)) { \
- snprintf(msgBuf, sizeof(msgBuf), \
- #comp " version is %u.%u", major, minor); \
- ret = 1; \
- } else { \
- snprintf(msgBuf, sizeof(msgBuf), \
- #comp " version error. Got: %u.%u, want <= %u.%u", major, minor, \
- (uint32_t)majorRequired, (uint32_t)minorRequired); \
- } \
- msgBuf[sizeof(msgBuf) - 1] = '\0'; \
- return ret; \
- }
-#else /* TRUSTLET */
-#define MC_CHECK_DATA_OBJECT_VERSION(comp, majorRequired, minorRequired) \
- MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
- static uint32_t checkVersionOkDataObject##comp(uint32_t version, char** errmsg) { \
- uint32_t major = MC_GET_MAJOR_VERSION(version); \
- uint32_t minor = MC_GET_MINOR_VERSION(version); \
- *errmsg = NULL; \
- if ((major == majorRequired) && (minor <= minorRequired)) { \
- tlDbgPrintf(#comp " version is %u.%u", major, minor); \
- return 1; \
- } else { \
- tlDbgPrintf( \
- #comp " version error. Got: %u.%u, want <= %u.%u", major, minor, \
- (uint32_t)majorRequired, (uint32_t)minorRequired); \
- } \
- return 0; \
- }
-#endif /* TRUSTLET */
-#else
-#define MC_CHECK_DATA_OBJECT_VERSION(comp, majorRequired, minorRequired) \
- MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
- static uint32_t checkVersionOkDataObject##comp(uint32_t version, char** errmsg) { \
- uint32_t major = MC_GET_MAJOR_VERSION(version); \
- uint32_t minor = MC_GET_MINOR_VERSION(version); \
- *errmsg = NULL; \
- if ((major == majorRequired) && (minor <= minorRequired)) { \
- return 1; \
- }; \
- return 0; \
- }
-#endif
-
-#endif // MCVERSIONHELPER_H_
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef MCVERSIONINFO_H_
-#define MCVERSIONINFO_H_
-
-/** Length of MobiCore product ID string. */
-#define MC_PRODUCT_ID_LEN 64
-
-/** Global MobiCore Version Information.
- */
-typedef struct {
- char productId[MC_PRODUCT_ID_LEN]; /** < Product ID of Mobicore; zero-terminated */
- uint32_t versionMci; /** < Version of Mobicore Control Interface */
- uint32_t versionSo; /** < Version of Secure Objects */
- uint32_t versionMclf; /** < Version of MobiCore Load Format */
- uint32_t versionContainer; /** < Version of MobiCore Container Format */
- uint32_t versionMcConfig; /** < Version of MobiCore Configuration Block Format */
- uint32_t versionTlApi; /** < Version of MobiCore Trustlet API Implementation */
- uint32_t versionDrApi; /** < Version of MobiCore Driver API Implementation */
- uint32_t versionCmp; /** < Version of Content Management Protocol */
-} mcVersionInfo_t;
-
-#endif /** MCVERSIONINFO_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __PROXY_SERVER_H__
-#define __PROXY_SERVER_H__
-
-class ProxyServer {
- struct Impl;
- Impl* const pimpl_;
- void run();
-public:
- ProxyServer();
- ~ProxyServer();
- int open();
- int close();
-};
-
-#endif // __PROXY_SERVER_H__
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __TEE_UUID_ATTESTATION_H__
-#define __TEE_UUID_ATTESTATION_H__
-
-#ifndef __TEE_CLIENT_TYPES_H__
-#include "tee_type.h"
-#endif
-
-// Sizes of the fields of attestation structure
-#define AT_MAGIC_SIZE 8
-#define AT_SIZE_SIZE sizeof(uint32_t)
-#define AT_VERSION_SIZE sizeof(uint32_t)
-#define AT_UUID_SIZE sizeof(TEE_UUID)
-
-// Sizes of the fields used to generate signature
-#define AT_TAG_SIZE 20
-#define AT_SHA1_HASH_SIZE 20
-
-// Max size of RSA modulus supported
-#define AT_MODULUS_MAX_SIZE 256
-// Max size of RSA public exponent supported
-#define AT_PUBLIC_EXPO_MAX_SIZE 4
-
-// Attestation version
-#define AT_VERSION 1
-
-// Name space ID (the UUID of the RSA OID)
-const uint8_t RSA_OID_UUID[AT_UUID_SIZE] = {0x6b, 0x8e, 0x02, 0x6b, 0x63, 0xc1, 0x5d, 0x58, 0xb0, 0x64, 0x00, 0xd3, 0x51, 0x89, 0xce, 0x65};
-// Magic word
-const char MAGIC[AT_MAGIC_SIZE] = "TAUUID\0";
-
-// Tag for signature generation
-const char TAG[AT_TAG_SIZE]="Trusted Application";
-
-// Public key structure
-typedef struct uuid_public_key {
- uint32_t type; // TEE_TYPE_RSA_PUBLIC_KEY: 0xA0000030
- uint16_t modulus_bytes; // Length of the modulus in bytes
- uint16_t exponent_bytes; // Length of the exponent in bytes
- uint8_t data[]; // Key material
-} uuid_public_key;
-
-// Attestation structure
-typedef struct uuid_attestation {
- uint8_t magic[AT_MAGIC_SIZE]; // Magic word: "TAUUID\0\0"
- uint32_t size; // Attestation size (4 bytes)
- uint32_t version; // Version number: 1 (4 bytes)
- uint8_t uuid[AT_UUID_SIZE]; // UUID
- uuid_public_key key; // Public key
-} uuid_attestation;
-
-#endif /* __TEE_UUID_ATTESTATION_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef MOBICORE_COMPONENT_BUILD_TAG
-#define MOBICORE_COMPONENT_BUILD_TAG \
- "t-base-EXYNOS64-Android-310B-V006-20160331_140301_7136"
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-#include <string.h>
-
-#undef LOG_TAG
-#define LOG_TAG "TeeCommonClient"
-#include "log.h"
-#include "mcVersionHelper.h"
-#include "driver_client.h"
-#ifndef WITHOUT_PROXY
-#include "proxy_client.h"
-#endif
-#include "common_client.h"
-
-#ifdef LOG_FPRINTF
-// Set default log destination (needs to be somewhere)
-FILE* mc_log_file_ = stdout;
-#endif
-
-struct CommonClient::Impl {
- pthread_mutex_t mutex;
- int open_count;
- DriverClient driver;
-#ifndef WITHOUT_PROXY
- ProxyClient proxy;
-#endif
- IClient* client;
- OpenMode open_mode;
- Impl(): open_count(0), client(NULL), open_mode(AUTO) {
- pthread_mutex_init(&mutex, NULL);
- }
-};
-
-CommonClient::CommonClient(): pimpl_(new Impl) {
-}
-
-CommonClient::~CommonClient() {
- delete pimpl_;
-}
-
-int CommonClient::open() {
- int ret = 0;
- pthread_mutex_lock(&pimpl_->mutex);
- if (pimpl_->client && !pimpl_->client->isOpen()) {
- pimpl_->open_count = 0;
- }
- if (pimpl_->open_count == 0) {
- if ((pimpl_->open_mode != PROXY) && (pimpl_->driver.open() >= 0)) {
- pimpl_->client = &pimpl_->driver;
-#ifndef WITHOUT_PROXY
- } else if ((pimpl_->open_mode != DRIVER) &&
- (pimpl_->proxy.open() >= 0)) {
- pimpl_->client = &pimpl_->proxy;
-#endif
- } else {
- LOG_E("Failed to open lower layers: %s", strerror(errno));
- ret = -1;
- }
- }
- if (pimpl_->client) {
- pimpl_->open_count++;
- }
- pthread_mutex_unlock(&pimpl_->mutex);
- LOG_D("%s ret=%d open_count=%d", __FUNCTION__, ret, pimpl_->open_count);
- return ret;
-}
-
-int CommonClient::closeCheck() {
- int ret;
- pthread_mutex_lock(&pimpl_->mutex);
- if (pimpl_->open_count > 1) {
- pimpl_->open_count--;
- ret = 0;
- } else {
- errno = EPERM;
- ret = -1;
- }
- pthread_mutex_unlock(&pimpl_->mutex);
- LOG_D("%s ret=%d open_count=%d", __FUNCTION__, ret, pimpl_->open_count);
- return ret;
-}
-
-int CommonClient::close() {
- int ret = -1;
- pthread_mutex_lock(&pimpl_->mutex);
- /* Not open */
- if (!pimpl_->client) {
- errno = EBADF;
- } else {
- /* Last token */
- if (pimpl_->open_count == 1) {
- ret = pimpl_->client->close();
- pimpl_->client = NULL;
- } else {
- ret = 0;
- }
- pimpl_->open_count--;
- }
- pthread_mutex_unlock(&pimpl_->mutex);
- LOG_D("%s ret=%d open_count=%d", __FUNCTION__, ret, pimpl_->open_count);
- return ret;
-}
-
-bool CommonClient::isOpen() const {
- return pimpl_->open_count > 0;
-}
-
-int CommonClient::hasOpenSessions() const {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->hasOpenSessions();
-}
-
-int CommonClient::openSession(struct mc_ioctl_open_session& session) {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->openSession(session);
-}
-
-int CommonClient::openTrustlet(struct mc_ioctl_open_trustlet& trustlet) {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->openTrustlet(trustlet);
-}
-
-int CommonClient::closeSession(uint32_t session_id) {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->closeSession(session_id);
-}
-
-int CommonClient::notify(uint32_t session_id) {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->notify(session_id);
-}
-
-int CommonClient::waitNotification(const struct mc_ioctl_wait& wait) {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->waitNotification(wait);
-}
-
-int CommonClient::malloc(uint8_t** buffer, uint32_t length) {
- // Check length here to make sure we are consistent, with or without proxy
- if ((length == 0) || (length > BUFFER_LENGTH_MAX)) {
- errno = EINVAL;
- return -1;
- }
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->malloc(buffer, length);
-}
-
-int CommonClient::free(uint8_t* buffer, uint32_t length) {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->free(buffer, length);
-}
-
-int CommonClient::map(struct mc_ioctl_map& map) {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->map(map);
-}
-
-int CommonClient::unmap(const struct mc_ioctl_map& map) {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->unmap(map);
-}
-
-int CommonClient::getError(struct mc_ioctl_geterr& err) {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->getError(err);
-}
-
-int CommonClient::getVersion(struct mc_version_info& version_info) {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->getVersion(version_info);
-}
-
-int CommonClient::gpRequestCancellation(uint32_t session_id) {
- if (!pimpl_->client) {
- errno = EBADF;
- return -1;
- }
- return pimpl_->client->gpRequestCancellation(session_id);
-}
-
-void CommonClient::setOpenMode(OpenMode open_mode) {
-#ifdef WITHOUT_PROXY
- (void) open_mode;
-#else
- pimpl_->open_mode = open_mode;
-#endif
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* Common open/file device functions for Mobicore and GP */
-
-#ifndef __CLIENT_COMMON_H__
-#define __CLIENT_COMMON_H__
-
-#include "iclient.h"
-
-class CommonClient: public IClient {
- struct Impl;
- Impl* const pimpl_;
- CommonClient();
-public:
- ~CommonClient();
- virtual int open();
- int closeCheck();
- virtual int close();
- virtual bool isOpen() const;
- virtual int hasOpenSessions() const;
- virtual int openSession(struct mc_ioctl_open_session& session);
- virtual int openTrustlet(struct mc_ioctl_open_trustlet& trustlet);
- virtual int closeSession(uint32_t session_id);
- virtual int notify(uint32_t session_id);
- virtual int waitNotification(const struct mc_ioctl_wait& wait);
- virtual int malloc(uint8_t** buffer, uint32_t length);
- virtual int free(uint8_t* buffer, uint32_t length);
- virtual int map(struct mc_ioctl_map& map);
- virtual int unmap(const struct mc_ioctl_map& map);
- virtual int getError(struct mc_ioctl_geterr& err);
- virtual int getVersion(struct mc_version_info& version_info);
- virtual int gpRequestCancellation(uint32_t session_id);
- // Singleton
- static CommonClient& getInstance() {
- static CommonClient client;
- return client;
- }
- // For test purpose
- enum OpenMode {
- AUTO,
- DRIVER = 0x44525652,
- PROXY = 0x50525859,
- };
- void setOpenMode(OpenMode open_mode);
-};
-
-#endif // __CLIENT_COMMON_H__
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <vector>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <pthread.h>
-
-#include <tee_client_api.h> // TEEC_UUID
-#include <GpTci.h> // _TEEC_TCI
-
-#undef LOG_TAG
-#define LOG_TAG "TeeDriverClient"
-#include "log.h"
-#include "mcVersionHelper.h"
-#include "driver_client.h"
-
-MC_CHECK_VERSION(MCDRVMODULEAPI, 2, 1);
-
-struct DriverClient::Impl {
- struct GpSession {
- uint32_t id;
- _TEEC_TCI* tci;
- GpSession(uint32_t i, uint64_t t): id(i) {
- tci = reinterpret_cast<_TEEC_TCI*>(static_cast<uintptr_t>(t));
- }
- };
- pthread_mutex_t gp_sessions_mutex;
- std::vector<GpSession*> gp_sessions;
- int fd;
- Impl(): fd(-1) {
- ::pthread_mutex_init(&gp_sessions_mutex, NULL);
- }
- ~Impl() {
- ::pthread_mutex_destroy(&gp_sessions_mutex);
- }
-};
-
-DriverClient::DriverClient(): pimpl_(new Impl) {
-}
-
-DriverClient::~DriverClient() {
- delete pimpl_;
-}
-
-int DriverClient::open() {
- int fd = ::open("/dev/" MC_USER_DEVNODE, O_RDWR | O_CLOEXEC);
- if (fd < 0) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- return -1;
- }
-
- struct mc_version_info version_info;
- if (::ioctl(fd, MC_IO_VERSION, &version_info) < 0) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- (void)::close(fd);
- return -1;
- }
-
- // Run-time check.
- uint32_t version = version_info.version_nwd;
- char* errmsg;
- if (!checkVersionOkMCDRVMODULEAPI(version, &errmsg)) {
- (void)::close(fd);
- errno = EHOSTDOWN;
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- return -1;
- }
-
- pimpl_->fd = fd;
- LOG_I("driver client open");
- return 0;
-}
-
-int DriverClient::close() {
- int ret = ::close(pimpl_->fd);
- if (ret) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- }
- pimpl_->fd = -1;
- LOG_I("driver client closed");
- return ret;
-}
-
-bool DriverClient::isOpen() const {
- return pimpl_->fd != -1;
-}
-
-int DriverClient::hasOpenSessions() const {
- int ret = ::ioctl(pimpl_->fd, MC_IO_HAS_SESSIONS);
- if (ret) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- }
- return ret;
-}
-
-int DriverClient::openSession(struct mc_ioctl_open_session& session) {
- int ret = ::ioctl(pimpl_->fd, MC_IO_OPEN_SESSION, &session);
- if (ret) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- return ret;
- }
- if (session.is_gp_uuid) {
- pthread_mutex_lock(&pimpl_->gp_sessions_mutex);
- pimpl_->gp_sessions.push_back(
- new Impl::GpSession(session.sid, session.tci));
- pthread_mutex_unlock(&pimpl_->gp_sessions_mutex);
- }
- LOG_D("session %x open", session.sid);
- return ret;
-}
-
-int DriverClient::openTrustlet(struct mc_ioctl_open_trustlet& trustlet) {
- int ret = ::ioctl(pimpl_->fd, MC_IO_OPEN_TRUSTLET, &trustlet);
- if (ret) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- return ret;
- }
- LOG_D("session %x open", trustlet.sid);
- return ret;
-}
-
-int DriverClient::closeSession(uint32_t session_id) {
- LOG_D("session %x close", session_id);
- int ret = ::ioctl(pimpl_->fd, MC_IO_CLOSE_SESSION, session_id);
- if (ret) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- return ret;
- }
- pthread_mutex_lock(&pimpl_->gp_sessions_mutex);
- for (auto it = pimpl_->gp_sessions.begin();
- it != pimpl_->gp_sessions.end(); it++) {
- auto gp_session = *it;
- if (gp_session->id == session_id) {
- pimpl_->gp_sessions.erase(it);
- delete gp_session;
- break;
- }
- }
- pthread_mutex_unlock(&pimpl_->gp_sessions_mutex);
- LOG_D("session %x closed", session_id);
- return ret;
-}
-
-int DriverClient::notify(uint32_t session_id) {
- int ret = ::ioctl(pimpl_->fd, MC_IO_NOTIFY, session_id);
- if (ret) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- return ret;
- }
- LOG_D("session %x notification sent", session_id);
- return ret;
-}
-
-int DriverClient::waitNotification(const struct mc_ioctl_wait& wait) {
- LOG_D("session %x wait for notification", wait.sid);
- int ret = ::ioctl(pimpl_->fd, MC_IO_WAIT, &wait);
- if (ret && ((errno != ETIME) || !wait.partial)) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- return ret;
- }
- LOG_D("session %x notification received", wait.sid);
- return ret;
-}
-
-int DriverClient::malloc(uint8_t** buffer, uint32_t length) {
- *buffer = static_cast<uint8_t*>(mmap(0, length, PROT_READ | PROT_WRITE,
- MAP_SHARED, pimpl_->fd, 0));
- if (*buffer == MAP_FAILED) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- return -1;
- }
- return 0;
-}
-
-int DriverClient::free(uint8_t* buffer, uint32_t length) {
- int ret = munmap(buffer, length);
- if (ret) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- }
- return ret;
-}
-
-int DriverClient::map(struct mc_ioctl_map& map) {
- int ret = ::ioctl(pimpl_->fd, MC_IO_MAP, &map);
- if (ret) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- return ret;
- }
- LOG_D("session %x buffer(s) mapped", map.sid);
- return ret;
-}
-
-int DriverClient::unmap(const struct mc_ioctl_map& map) {
- int ret = ::ioctl(pimpl_->fd, MC_IO_UNMAP, &map);
- if (ret) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- return ret;
- }
- LOG_D("session %x buffer(s) unmapped", map.sid);
- return ret;
-}
-
-int DriverClient::getError(struct mc_ioctl_geterr& err) {
- int ret = ::ioctl(pimpl_->fd, MC_IO_ERR, &err);
- if (ret) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- return ret;
- }
- LOG_D("session %x exit code %d", err.sid, err.value);
- return ret;
-}
-
-int DriverClient::getVersion(struct mc_version_info& version_info) {
- int ret = ::ioctl(pimpl_->fd, MC_IO_VERSION, &version_info);
- if (ret) {
- _LOG_E("%s in %s", strerror(errno), __FUNCTION__);
- }
- return ret;
-}
-
-// This class will need to handle the GP protocol at some point, but for now it
-// only deals with cancellation
-int DriverClient::gpRequestCancellation(uint32_t session_id) {
- bool found = false;
- pthread_mutex_lock(&pimpl_->gp_sessions_mutex);
- for (auto it = pimpl_->gp_sessions.begin(); it != pimpl_->gp_sessions.end();
- it++) {
- auto gp_session = *it;
- if (gp_session->id == session_id) {
- // Will be reset by caller at next InvokeCommand
- gp_session->tci->operation.isCancelled = true;
- found = true;
- }
- }
- pthread_mutex_unlock(&pimpl_->gp_sessions_mutex);
- if (!found) {
- errno = ENOENT;
- return -1;
- }
- return notify(session_id);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __CLIENT_DRIVER_H__
-#define __CLIENT_DRIVER_H__
-
-#include "iclient.h"
-
-class DriverClient: public IClient {
- struct Impl;
- Impl* const pimpl_;
-public:
- DriverClient();
- ~DriverClient();
- virtual int open();
- virtual int close();
- virtual bool isOpen() const;
- virtual int hasOpenSessions() const;
- virtual int openSession(struct mc_ioctl_open_session& session);
- virtual int openTrustlet(struct mc_ioctl_open_trustlet& trustlet);
- virtual int closeSession(uint32_t session_id);
- virtual int notify(uint32_t session_id);
- virtual int waitNotification(const struct mc_ioctl_wait& wait);
- virtual int malloc(uint8_t** buffer, uint32_t length);
- virtual int free(uint8_t* buffer, uint32_t length);
- virtual int map(struct mc_ioctl_map& map);
- virtual int unmap(const struct mc_ioctl_map& map);
- virtual int getError(struct mc_ioctl_geterr& err);
- virtual int getVersion(struct mc_version_info& version_info);
- virtual int gpRequestCancellation(uint32_t session_id);
-};
-
-#endif // __CLIENT_DRIVER_H__
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __CLIENT_INTERFACE_H__
-#define __CLIENT_INTERFACE_H__
-
-#include <stdint.h> // *int*_t
-#include <sys/types.h> // uid_t git_t
-#include "mc_user.h" // ioctl structures
-
-class IClient {
-public:
- virtual ~IClient() {}
- virtual int open() = 0;
- virtual int close() = 0;
- virtual bool isOpen() const = 0;
- // MC protocol, also used by GP for now
- virtual int hasOpenSessions() const = 0;
- virtual int openSession(struct mc_ioctl_open_session& session) = 0;
- virtual int openTrustlet(struct mc_ioctl_open_trustlet& trustlet) = 0;
- virtual int closeSession(uint32_t session_id) = 0;
- virtual int notify(uint32_t session_id) = 0;
- virtual int waitNotification(const struct mc_ioctl_wait& wait) = 0;
- virtual int malloc(uint8_t** buffer, uint32_t length) = 0;
- virtual int free(uint8_t* buffer, uint32_t length) = 0;
- virtual int map(struct mc_ioctl_map& map) = 0;
- virtual int unmap(const struct mc_ioctl_map& map) = 0;
- virtual int getError(struct mc_ioctl_geterr& err) = 0;
- virtual int getVersion(struct mc_version_info& version_info) = 0;
- // GP protocol only
- virtual int gpRequestCancellation(uint32_t session_id) = 0;
-};
-
-#endif // __CLIENT_INTERFACE_H__
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: mc.proto
-
-#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
-#include "mc.pb.h"
-
-#include <algorithm>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/once.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/wire_format_lite_inl.h>
-#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
-// @@protoc_insertion_point(includes)
-
-namespace com {
-namespace trustonic {
-namespace tee_proxy {
-
-void protobuf_ShutdownFile_mc_2eproto() {
- delete OpenSessionRequest::default_instance_;
- delete OpenSessionResponse::default_instance_;
- delete OpenTrustletRequest::default_instance_;
- delete OpenTrustletResponse::default_instance_;
- delete CloseSessionRequest::default_instance_;
- delete CloseSessionResponse::default_instance_;
- delete NotifyRequest::default_instance_;
- delete NotifyRequest_Buffers::default_instance_;
- delete NotifyResponse::default_instance_;
- delete WaitNotificationRequest::default_instance_;
- delete WaitNotificationResponse::default_instance_;
- delete WaitNotificationResponse_Buffers::default_instance_;
- delete MapRequest::default_instance_;
- delete MapRequest_Buffers::default_instance_;
- delete MapResponse::default_instance_;
- delete MapResponse_Buffers::default_instance_;
- delete UnmapRequest::default_instance_;
- delete UnmapRequest_Buffers::default_instance_;
- delete UnmapResponse::default_instance_;
- delete GetErrorRequest::default_instance_;
- delete GetErrorResponse::default_instance_;
- delete GetVersionRequest::default_instance_;
- delete GetVersionResponse::default_instance_;
- delete GpRequestCancellationRequest::default_instance_;
- delete GpRequestCancellationResponse::default_instance_;
-}
-
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-void protobuf_AddDesc_mc_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
-#else
-void protobuf_AddDesc_mc_2eproto() {
- static bool already_here = false;
- if (already_here) return;
- already_here = true;
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
-#endif
- OpenSessionRequest::default_instance_ = new OpenSessionRequest();
- OpenSessionResponse::default_instance_ = new OpenSessionResponse();
- OpenTrustletRequest::default_instance_ = new OpenTrustletRequest();
- OpenTrustletResponse::default_instance_ = new OpenTrustletResponse();
- CloseSessionRequest::default_instance_ = new CloseSessionRequest();
- CloseSessionResponse::default_instance_ = new CloseSessionResponse();
- NotifyRequest::default_instance_ = new NotifyRequest();
- NotifyRequest_Buffers::default_instance_ = new NotifyRequest_Buffers();
- NotifyResponse::default_instance_ = new NotifyResponse();
- WaitNotificationRequest::default_instance_ = new WaitNotificationRequest();
- WaitNotificationResponse::default_instance_ = new WaitNotificationResponse();
- WaitNotificationResponse_Buffers::default_instance_ = new WaitNotificationResponse_Buffers();
- MapRequest::default_instance_ = new MapRequest();
- MapRequest_Buffers::default_instance_ = new MapRequest_Buffers();
- MapResponse::default_instance_ = new MapResponse();
- MapResponse_Buffers::default_instance_ = new MapResponse_Buffers();
- UnmapRequest::default_instance_ = new UnmapRequest();
- UnmapRequest_Buffers::default_instance_ = new UnmapRequest_Buffers();
- UnmapResponse::default_instance_ = new UnmapResponse();
- GetErrorRequest::default_instance_ = new GetErrorRequest();
- GetErrorResponse::default_instance_ = new GetErrorResponse();
- GetVersionRequest::default_instance_ = new GetVersionRequest();
- GetVersionResponse::default_instance_ = new GetVersionResponse();
- GpRequestCancellationRequest::default_instance_ = new GpRequestCancellationRequest();
- GpRequestCancellationResponse::default_instance_ = new GpRequestCancellationResponse();
- OpenSessionRequest::default_instance_->InitAsDefaultInstance();
- OpenSessionResponse::default_instance_->InitAsDefaultInstance();
- OpenTrustletRequest::default_instance_->InitAsDefaultInstance();
- OpenTrustletResponse::default_instance_->InitAsDefaultInstance();
- CloseSessionRequest::default_instance_->InitAsDefaultInstance();
- CloseSessionResponse::default_instance_->InitAsDefaultInstance();
- NotifyRequest::default_instance_->InitAsDefaultInstance();
- NotifyRequest_Buffers::default_instance_->InitAsDefaultInstance();
- NotifyResponse::default_instance_->InitAsDefaultInstance();
- WaitNotificationRequest::default_instance_->InitAsDefaultInstance();
- WaitNotificationResponse::default_instance_->InitAsDefaultInstance();
- WaitNotificationResponse_Buffers::default_instance_->InitAsDefaultInstance();
- MapRequest::default_instance_->InitAsDefaultInstance();
- MapRequest_Buffers::default_instance_->InitAsDefaultInstance();
- MapResponse::default_instance_->InitAsDefaultInstance();
- MapResponse_Buffers::default_instance_->InitAsDefaultInstance();
- UnmapRequest::default_instance_->InitAsDefaultInstance();
- UnmapRequest_Buffers::default_instance_->InitAsDefaultInstance();
- UnmapResponse::default_instance_->InitAsDefaultInstance();
- GetErrorRequest::default_instance_->InitAsDefaultInstance();
- GetErrorResponse::default_instance_->InitAsDefaultInstance();
- GetVersionRequest::default_instance_->InitAsDefaultInstance();
- GetVersionResponse::default_instance_->InitAsDefaultInstance();
- GpRequestCancellationRequest::default_instance_->InitAsDefaultInstance();
- GpRequestCancellationResponse::default_instance_->InitAsDefaultInstance();
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_mc_2eproto);
-}
-
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_mc_2eproto_once_);
-void protobuf_AddDesc_mc_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_mc_2eproto_once_,
- &protobuf_AddDesc_mc_2eproto_impl);
-}
-#else
-// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_mc_2eproto {
- StaticDescriptorInitializer_mc_2eproto() {
- protobuf_AddDesc_mc_2eproto();
- }
-} static_descriptor_initializer_mc_2eproto_;
-#endif
-bool LoginType_IsValid(int value) {
- switch(value) {
- case 0:
- case 1:
- case 2:
- case 4:
- case 5:
- case 6:
- return true;
- default:
- return false;
- }
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int OpenSessionRequest::kUuidFieldNumber;
-const int OpenSessionRequest::kIsGpUuidFieldNumber;
-const int OpenSessionRequest::kTciFieldNumber;
-const int OpenSessionRequest::kLoginTypeFieldNumber;
-const int OpenSessionRequest::kLoginDataFieldNumber;
-#endif // !_MSC_VER
-
-OpenSessionRequest::OpenSessionRequest()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.OpenSessionRequest)
-}
-
-void OpenSessionRequest::InitAsDefaultInstance() {
-}
-
-OpenSessionRequest::OpenSessionRequest(const OpenSessionRequest& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.OpenSessionRequest)
-}
-
-void OpenSessionRequest::SharedCtor() {
- ::google::protobuf::internal::GetEmptyString();
- _cached_size_ = 0;
- uuid_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- is_gp_uuid_ = false;
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- login_type_ = 0;
- login_data_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-OpenSessionRequest::~OpenSessionRequest() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.OpenSessionRequest)
- SharedDtor();
-}
-
-void OpenSessionRequest::SharedDtor() {
- if (uuid_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete uuid_;
- }
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete tci_;
- }
- if (login_data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete login_data_;
- }
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void OpenSessionRequest::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const OpenSessionRequest& OpenSessionRequest::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-OpenSessionRequest* OpenSessionRequest::default_instance_ = NULL;
-
-OpenSessionRequest* OpenSessionRequest::New() const {
- return new OpenSessionRequest;
-}
-
-void OpenSessionRequest::Clear() {
-#define OFFSET_OF_FIELD_(f) (reinterpret_cast<char*>( \
- &reinterpret_cast<OpenSessionRequest*>(16)->f) - \
- reinterpret_cast<char*>(16))
-
-#define ZR_(first, last) do { \
- size_t f = OFFSET_OF_FIELD_(first); \
- size_t n = OFFSET_OF_FIELD_(last) - f + sizeof(last); \
- ::memset(&first, 0, n); \
- } while (0)
-
- if (_has_bits_[0 / 32] & 31) {
- ZR_(is_gp_uuid_, login_type_);
- if (has_uuid()) {
- if (uuid_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- uuid_->clear();
- }
- }
- if (has_tci()) {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_->clear();
- }
- }
- if (has_login_data()) {
- if (login_data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- login_data_->clear();
- }
- }
- }
-
-#undef OFFSET_OF_FIELD_
-#undef ZR_
-
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool OpenSessionRequest::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.OpenSessionRequest)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required bytes uuid = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_uuid()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_is_gp_uuid;
- break;
- }
-
- // required bool is_gp_uuid = 2;
- case 2: {
- if (tag == 16) {
- parse_is_gp_uuid:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &is_gp_uuid_)));
- set_has_is_gp_uuid();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_tci;
- break;
- }
-
- // optional bytes tci = 3;
- case 3: {
- if (tag == 26) {
- parse_tci:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_tci()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_login_type;
- break;
- }
-
- // required .com.trustonic.tee_proxy.LoginType login_type = 4;
- case 4: {
- if (tag == 32) {
- parse_login_type:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::com::trustonic::tee_proxy::LoginType_IsValid(value)) {
- set_login_type(static_cast< ::com::trustonic::tee_proxy::LoginType >(value));
- } else {
- unknown_fields_stream.WriteVarint32(tag);
- unknown_fields_stream.WriteVarint32(value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(42)) goto parse_login_data;
- break;
- }
-
- // required bytes login_data = 5;
- case 5: {
- if (tag == 42) {
- parse_login_data:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_login_data()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.OpenSessionRequest)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.OpenSessionRequest)
- return false;
-#undef DO_
-}
-
-void OpenSessionRequest::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.OpenSessionRequest)
- // required bytes uuid = 1;
- if (has_uuid()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
- 1, this->uuid(), output);
- }
-
- // required bool is_gp_uuid = 2;
- if (has_is_gp_uuid()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->is_gp_uuid(), output);
- }
-
- // optional bytes tci = 3;
- if (has_tci()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
- 3, this->tci(), output);
- }
-
- // required .com.trustonic.tee_proxy.LoginType login_type = 4;
- if (has_login_type()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 4, this->login_type(), output);
- }
-
- // required bytes login_data = 5;
- if (has_login_data()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
- 5, this->login_data(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.OpenSessionRequest)
-}
-
-int OpenSessionRequest::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required bytes uuid = 1;
- if (has_uuid()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->uuid());
- }
-
- // required bool is_gp_uuid = 2;
- if (has_is_gp_uuid()) {
- total_size += 1 + 1;
- }
-
- // optional bytes tci = 3;
- if (has_tci()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->tci());
- }
-
- // required .com.trustonic.tee_proxy.LoginType login_type = 4;
- if (has_login_type()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->login_type());
- }
-
- // required bytes login_data = 5;
- if (has_login_data()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->login_data());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void OpenSessionRequest::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const OpenSessionRequest*>(&from));
-}
-
-void OpenSessionRequest::MergeFrom(const OpenSessionRequest& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_uuid()) {
- set_uuid(from.uuid());
- }
- if (from.has_is_gp_uuid()) {
- set_is_gp_uuid(from.is_gp_uuid());
- }
- if (from.has_tci()) {
- set_tci(from.tci());
- }
- if (from.has_login_type()) {
- set_login_type(from.login_type());
- }
- if (from.has_login_data()) {
- set_login_data(from.login_data());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void OpenSessionRequest::CopyFrom(const OpenSessionRequest& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool OpenSessionRequest::IsInitialized() const {
- if ((_has_bits_[0] & 0x0000001b) != 0x0000001b) return false;
-
- return true;
-}
-
-void OpenSessionRequest::Swap(OpenSessionRequest* other) {
- if (other != this) {
- std::swap(uuid_, other->uuid_);
- std::swap(is_gp_uuid_, other->is_gp_uuid_);
- std::swap(tci_, other->tci_);
- std::swap(login_type_, other->login_type_);
- std::swap(login_data_, other->login_data_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string OpenSessionRequest::GetTypeName() const {
- return "com.trustonic.tee_proxy.OpenSessionRequest";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int OpenSessionResponse::kIdFieldNumber;
-#endif // !_MSC_VER
-
-OpenSessionResponse::OpenSessionResponse()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.OpenSessionResponse)
-}
-
-void OpenSessionResponse::InitAsDefaultInstance() {
-}
-
-OpenSessionResponse::OpenSessionResponse(const OpenSessionResponse& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.OpenSessionResponse)
-}
-
-void OpenSessionResponse::SharedCtor() {
- _cached_size_ = 0;
- id_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-OpenSessionResponse::~OpenSessionResponse() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.OpenSessionResponse)
- SharedDtor();
-}
-
-void OpenSessionResponse::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void OpenSessionResponse::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const OpenSessionResponse& OpenSessionResponse::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-OpenSessionResponse* OpenSessionResponse::default_instance_ = NULL;
-
-OpenSessionResponse* OpenSessionResponse::New() const {
- return new OpenSessionResponse;
-}
-
-void OpenSessionResponse::Clear() {
- id_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool OpenSessionResponse::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.OpenSessionResponse)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint32 id = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &id_)));
- set_has_id();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.OpenSessionResponse)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.OpenSessionResponse)
- return false;
-#undef DO_
-}
-
-void OpenSessionResponse::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.OpenSessionResponse)
- // required uint32 id = 1;
- if (has_id()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->id(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.OpenSessionResponse)
-}
-
-int OpenSessionResponse::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint32 id = 1;
- if (has_id()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->id());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void OpenSessionResponse::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const OpenSessionResponse*>(&from));
-}
-
-void OpenSessionResponse::MergeFrom(const OpenSessionResponse& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_id()) {
- set_id(from.id());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void OpenSessionResponse::CopyFrom(const OpenSessionResponse& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool OpenSessionResponse::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- return true;
-}
-
-void OpenSessionResponse::Swap(OpenSessionResponse* other) {
- if (other != this) {
- std::swap(id_, other->id_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string OpenSessionResponse::GetTypeName() const {
- return "com.trustonic.tee_proxy.OpenSessionResponse";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int OpenTrustletRequest::kSpidFieldNumber;
-const int OpenTrustletRequest::kTrustappFieldNumber;
-const int OpenTrustletRequest::kTciFieldNumber;
-#endif // !_MSC_VER
-
-OpenTrustletRequest::OpenTrustletRequest()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.OpenTrustletRequest)
-}
-
-void OpenTrustletRequest::InitAsDefaultInstance() {
-}
-
-OpenTrustletRequest::OpenTrustletRequest(const OpenTrustletRequest& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.OpenTrustletRequest)
-}
-
-void OpenTrustletRequest::SharedCtor() {
- ::google::protobuf::internal::GetEmptyString();
- _cached_size_ = 0;
- spid_ = 0u;
- trustapp_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-OpenTrustletRequest::~OpenTrustletRequest() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.OpenTrustletRequest)
- SharedDtor();
-}
-
-void OpenTrustletRequest::SharedDtor() {
- if (trustapp_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete trustapp_;
- }
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete tci_;
- }
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void OpenTrustletRequest::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const OpenTrustletRequest& OpenTrustletRequest::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-OpenTrustletRequest* OpenTrustletRequest::default_instance_ = NULL;
-
-OpenTrustletRequest* OpenTrustletRequest::New() const {
- return new OpenTrustletRequest;
-}
-
-void OpenTrustletRequest::Clear() {
- if (_has_bits_[0 / 32] & 7) {
- spid_ = 0u;
- if (has_trustapp()) {
- if (trustapp_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- trustapp_->clear();
- }
- }
- if (has_tci()) {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_->clear();
- }
- }
- }
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool OpenTrustletRequest::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.OpenTrustletRequest)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint32 spid = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &spid_)));
- set_has_spid();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_trustapp;
- break;
- }
-
- // required bytes trustapp = 2;
- case 2: {
- if (tag == 18) {
- parse_trustapp:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_trustapp()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_tci;
- break;
- }
-
- // optional bytes tci = 3;
- case 3: {
- if (tag == 26) {
- parse_tci:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_tci()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.OpenTrustletRequest)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.OpenTrustletRequest)
- return false;
-#undef DO_
-}
-
-void OpenTrustletRequest::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.OpenTrustletRequest)
- // required uint32 spid = 1;
- if (has_spid()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->spid(), output);
- }
-
- // required bytes trustapp = 2;
- if (has_trustapp()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
- 2, this->trustapp(), output);
- }
-
- // optional bytes tci = 3;
- if (has_tci()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
- 3, this->tci(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.OpenTrustletRequest)
-}
-
-int OpenTrustletRequest::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint32 spid = 1;
- if (has_spid()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->spid());
- }
-
- // required bytes trustapp = 2;
- if (has_trustapp()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->trustapp());
- }
-
- // optional bytes tci = 3;
- if (has_tci()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->tci());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void OpenTrustletRequest::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const OpenTrustletRequest*>(&from));
-}
-
-void OpenTrustletRequest::MergeFrom(const OpenTrustletRequest& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_spid()) {
- set_spid(from.spid());
- }
- if (from.has_trustapp()) {
- set_trustapp(from.trustapp());
- }
- if (from.has_tci()) {
- set_tci(from.tci());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void OpenTrustletRequest::CopyFrom(const OpenTrustletRequest& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool OpenTrustletRequest::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
-
- return true;
-}
-
-void OpenTrustletRequest::Swap(OpenTrustletRequest* other) {
- if (other != this) {
- std::swap(spid_, other->spid_);
- std::swap(trustapp_, other->trustapp_);
- std::swap(tci_, other->tci_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string OpenTrustletRequest::GetTypeName() const {
- return "com.trustonic.tee_proxy.OpenTrustletRequest";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int OpenTrustletResponse::kIdFieldNumber;
-#endif // !_MSC_VER
-
-OpenTrustletResponse::OpenTrustletResponse()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.OpenTrustletResponse)
-}
-
-void OpenTrustletResponse::InitAsDefaultInstance() {
-}
-
-OpenTrustletResponse::OpenTrustletResponse(const OpenTrustletResponse& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.OpenTrustletResponse)
-}
-
-void OpenTrustletResponse::SharedCtor() {
- _cached_size_ = 0;
- id_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-OpenTrustletResponse::~OpenTrustletResponse() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.OpenTrustletResponse)
- SharedDtor();
-}
-
-void OpenTrustletResponse::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void OpenTrustletResponse::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const OpenTrustletResponse& OpenTrustletResponse::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-OpenTrustletResponse* OpenTrustletResponse::default_instance_ = NULL;
-
-OpenTrustletResponse* OpenTrustletResponse::New() const {
- return new OpenTrustletResponse;
-}
-
-void OpenTrustletResponse::Clear() {
- id_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool OpenTrustletResponse::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.OpenTrustletResponse)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint32 id = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &id_)));
- set_has_id();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.OpenTrustletResponse)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.OpenTrustletResponse)
- return false;
-#undef DO_
-}
-
-void OpenTrustletResponse::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.OpenTrustletResponse)
- // required uint32 id = 1;
- if (has_id()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->id(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.OpenTrustletResponse)
-}
-
-int OpenTrustletResponse::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint32 id = 1;
- if (has_id()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->id());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void OpenTrustletResponse::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const OpenTrustletResponse*>(&from));
-}
-
-void OpenTrustletResponse::MergeFrom(const OpenTrustletResponse& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_id()) {
- set_id(from.id());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void OpenTrustletResponse::CopyFrom(const OpenTrustletResponse& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool OpenTrustletResponse::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- return true;
-}
-
-void OpenTrustletResponse::Swap(OpenTrustletResponse* other) {
- if (other != this) {
- std::swap(id_, other->id_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string OpenTrustletResponse::GetTypeName() const {
- return "com.trustonic.tee_proxy.OpenTrustletResponse";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int CloseSessionRequest::kIdFieldNumber;
-#endif // !_MSC_VER
-
-CloseSessionRequest::CloseSessionRequest()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.CloseSessionRequest)
-}
-
-void CloseSessionRequest::InitAsDefaultInstance() {
-}
-
-CloseSessionRequest::CloseSessionRequest(const CloseSessionRequest& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.CloseSessionRequest)
-}
-
-void CloseSessionRequest::SharedCtor() {
- _cached_size_ = 0;
- id_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-CloseSessionRequest::~CloseSessionRequest() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.CloseSessionRequest)
- SharedDtor();
-}
-
-void CloseSessionRequest::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void CloseSessionRequest::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const CloseSessionRequest& CloseSessionRequest::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-CloseSessionRequest* CloseSessionRequest::default_instance_ = NULL;
-
-CloseSessionRequest* CloseSessionRequest::New() const {
- return new CloseSessionRequest;
-}
-
-void CloseSessionRequest::Clear() {
- id_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool CloseSessionRequest::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.CloseSessionRequest)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint32 id = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &id_)));
- set_has_id();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.CloseSessionRequest)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.CloseSessionRequest)
- return false;
-#undef DO_
-}
-
-void CloseSessionRequest::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.CloseSessionRequest)
- // required uint32 id = 1;
- if (has_id()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->id(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.CloseSessionRequest)
-}
-
-int CloseSessionRequest::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint32 id = 1;
- if (has_id()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->id());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void CloseSessionRequest::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const CloseSessionRequest*>(&from));
-}
-
-void CloseSessionRequest::MergeFrom(const CloseSessionRequest& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_id()) {
- set_id(from.id());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void CloseSessionRequest::CopyFrom(const CloseSessionRequest& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool CloseSessionRequest::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- return true;
-}
-
-void CloseSessionRequest::Swap(CloseSessionRequest* other) {
- if (other != this) {
- std::swap(id_, other->id_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string CloseSessionRequest::GetTypeName() const {
- return "com.trustonic.tee_proxy.CloseSessionRequest";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-#endif // !_MSC_VER
-
-CloseSessionResponse::CloseSessionResponse()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.CloseSessionResponse)
-}
-
-void CloseSessionResponse::InitAsDefaultInstance() {
-}
-
-CloseSessionResponse::CloseSessionResponse(const CloseSessionResponse& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.CloseSessionResponse)
-}
-
-void CloseSessionResponse::SharedCtor() {
- _cached_size_ = 0;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-CloseSessionResponse::~CloseSessionResponse() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.CloseSessionResponse)
- SharedDtor();
-}
-
-void CloseSessionResponse::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void CloseSessionResponse::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const CloseSessionResponse& CloseSessionResponse::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-CloseSessionResponse* CloseSessionResponse::default_instance_ = NULL;
-
-CloseSessionResponse* CloseSessionResponse::New() const {
- return new CloseSessionResponse;
-}
-
-void CloseSessionResponse::Clear() {
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool CloseSessionResponse::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.CloseSessionResponse)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.CloseSessionResponse)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.CloseSessionResponse)
- return false;
-#undef DO_
-}
-
-void CloseSessionResponse::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.CloseSessionResponse)
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.CloseSessionResponse)
-}
-
-int CloseSessionResponse::ByteSize() const {
- int total_size = 0;
-
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void CloseSessionResponse::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const CloseSessionResponse*>(&from));
-}
-
-void CloseSessionResponse::MergeFrom(const CloseSessionResponse& from) {
- GOOGLE_CHECK_NE(&from, this);
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void CloseSessionResponse::CopyFrom(const CloseSessionResponse& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool CloseSessionResponse::IsInitialized() const {
-
- return true;
-}
-
-void CloseSessionResponse::Swap(CloseSessionResponse* other) {
- if (other != this) {
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string CloseSessionResponse::GetTypeName() const {
- return "com.trustonic.tee_proxy.CloseSessionResponse";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int NotifyRequest_Buffers::kSvaFieldNumber;
-const int NotifyRequest_Buffers::kDataFieldNumber;
-#endif // !_MSC_VER
-
-NotifyRequest_Buffers::NotifyRequest_Buffers()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.NotifyRequest.Buffers)
-}
-
-void NotifyRequest_Buffers::InitAsDefaultInstance() {
-}
-
-NotifyRequest_Buffers::NotifyRequest_Buffers(const NotifyRequest_Buffers& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.NotifyRequest.Buffers)
-}
-
-void NotifyRequest_Buffers::SharedCtor() {
- ::google::protobuf::internal::GetEmptyString();
- _cached_size_ = 0;
- sva_ = GOOGLE_ULONGLONG(0);
- data_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-NotifyRequest_Buffers::~NotifyRequest_Buffers() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.NotifyRequest.Buffers)
- SharedDtor();
-}
-
-void NotifyRequest_Buffers::SharedDtor() {
- if (data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete data_;
- }
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void NotifyRequest_Buffers::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const NotifyRequest_Buffers& NotifyRequest_Buffers::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-NotifyRequest_Buffers* NotifyRequest_Buffers::default_instance_ = NULL;
-
-NotifyRequest_Buffers* NotifyRequest_Buffers::New() const {
- return new NotifyRequest_Buffers;
-}
-
-void NotifyRequest_Buffers::Clear() {
- if (_has_bits_[0 / 32] & 3) {
- sva_ = GOOGLE_ULONGLONG(0);
- if (has_data()) {
- if (data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_->clear();
- }
- }
- }
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool NotifyRequest_Buffers::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.NotifyRequest.Buffers)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint64 sva = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
- input, &sva_)));
- set_has_sva();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_data;
- break;
- }
-
- // required bytes data = 2;
- case 2: {
- if (tag == 18) {
- parse_data:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_data()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.NotifyRequest.Buffers)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.NotifyRequest.Buffers)
- return false;
-#undef DO_
-}
-
-void NotifyRequest_Buffers::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.NotifyRequest.Buffers)
- // required uint64 sva = 1;
- if (has_sva()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->sva(), output);
- }
-
- // required bytes data = 2;
- if (has_data()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
- 2, this->data(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.NotifyRequest.Buffers)
-}
-
-int NotifyRequest_Buffers::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint64 sva = 1;
- if (has_sva()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt64Size(
- this->sva());
- }
-
- // required bytes data = 2;
- if (has_data()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->data());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void NotifyRequest_Buffers::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const NotifyRequest_Buffers*>(&from));
-}
-
-void NotifyRequest_Buffers::MergeFrom(const NotifyRequest_Buffers& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_sva()) {
- set_sva(from.sva());
- }
- if (from.has_data()) {
- set_data(from.data());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void NotifyRequest_Buffers::CopyFrom(const NotifyRequest_Buffers& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool NotifyRequest_Buffers::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
-
- return true;
-}
-
-void NotifyRequest_Buffers::Swap(NotifyRequest_Buffers* other) {
- if (other != this) {
- std::swap(sva_, other->sva_);
- std::swap(data_, other->data_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string NotifyRequest_Buffers::GetTypeName() const {
- return "com.trustonic.tee_proxy.NotifyRequest.Buffers";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int NotifyRequest::kSidFieldNumber;
-const int NotifyRequest::kTciFieldNumber;
-const int NotifyRequest::kBuffersFieldNumber;
-#endif // !_MSC_VER
-
-NotifyRequest::NotifyRequest()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.NotifyRequest)
-}
-
-void NotifyRequest::InitAsDefaultInstance() {
-}
-
-NotifyRequest::NotifyRequest(const NotifyRequest& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.NotifyRequest)
-}
-
-void NotifyRequest::SharedCtor() {
- ::google::protobuf::internal::GetEmptyString();
- _cached_size_ = 0;
- sid_ = 0u;
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-NotifyRequest::~NotifyRequest() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.NotifyRequest)
- SharedDtor();
-}
-
-void NotifyRequest::SharedDtor() {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete tci_;
- }
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void NotifyRequest::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const NotifyRequest& NotifyRequest::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-NotifyRequest* NotifyRequest::default_instance_ = NULL;
-
-NotifyRequest* NotifyRequest::New() const {
- return new NotifyRequest;
-}
-
-void NotifyRequest::Clear() {
- if (_has_bits_[0 / 32] & 3) {
- sid_ = 0u;
- if (has_tci()) {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_->clear();
- }
- }
- }
- buffers_.Clear();
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool NotifyRequest::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.NotifyRequest)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint32 sid = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &sid_)));
- set_has_sid();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_tci;
- break;
- }
-
- // optional bytes tci = 2;
- case 2: {
- if (tag == 18) {
- parse_tci:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_tci()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_buffers;
- break;
- }
-
- // repeated .com.trustonic.tee_proxy.NotifyRequest.Buffers buffers = 3;
- case 3: {
- if (tag == 26) {
- parse_buffers:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, add_buffers()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_buffers;
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.NotifyRequest)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.NotifyRequest)
- return false;
-#undef DO_
-}
-
-void NotifyRequest::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.NotifyRequest)
- // required uint32 sid = 1;
- if (has_sid()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->sid(), output);
- }
-
- // optional bytes tci = 2;
- if (has_tci()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
- 2, this->tci(), output);
- }
-
- // repeated .com.trustonic.tee_proxy.NotifyRequest.Buffers buffers = 3;
- for (int i = 0; i < this->buffers_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 3, this->buffers(i), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.NotifyRequest)
-}
-
-int NotifyRequest::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint32 sid = 1;
- if (has_sid()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->sid());
- }
-
- // optional bytes tci = 2;
- if (has_tci()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->tci());
- }
-
- }
- // repeated .com.trustonic.tee_proxy.NotifyRequest.Buffers buffers = 3;
- total_size += 1 * this->buffers_size();
- for (int i = 0; i < this->buffers_size(); i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->buffers(i));
- }
-
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void NotifyRequest::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const NotifyRequest*>(&from));
-}
-
-void NotifyRequest::MergeFrom(const NotifyRequest& from) {
- GOOGLE_CHECK_NE(&from, this);
- buffers_.MergeFrom(from.buffers_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_sid()) {
- set_sid(from.sid());
- }
- if (from.has_tci()) {
- set_tci(from.tci());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void NotifyRequest::CopyFrom(const NotifyRequest& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool NotifyRequest::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- if (!::google::protobuf::internal::AllAreInitialized(this->buffers())) return false;
- return true;
-}
-
-void NotifyRequest::Swap(NotifyRequest* other) {
- if (other != this) {
- std::swap(sid_, other->sid_);
- std::swap(tci_, other->tci_);
- buffers_.Swap(&other->buffers_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string NotifyRequest::GetTypeName() const {
- return "com.trustonic.tee_proxy.NotifyRequest";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-#endif // !_MSC_VER
-
-NotifyResponse::NotifyResponse()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.NotifyResponse)
-}
-
-void NotifyResponse::InitAsDefaultInstance() {
-}
-
-NotifyResponse::NotifyResponse(const NotifyResponse& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.NotifyResponse)
-}
-
-void NotifyResponse::SharedCtor() {
- _cached_size_ = 0;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-NotifyResponse::~NotifyResponse() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.NotifyResponse)
- SharedDtor();
-}
-
-void NotifyResponse::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void NotifyResponse::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const NotifyResponse& NotifyResponse::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-NotifyResponse* NotifyResponse::default_instance_ = NULL;
-
-NotifyResponse* NotifyResponse::New() const {
- return new NotifyResponse;
-}
-
-void NotifyResponse::Clear() {
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool NotifyResponse::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.NotifyResponse)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.NotifyResponse)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.NotifyResponse)
- return false;
-#undef DO_
-}
-
-void NotifyResponse::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.NotifyResponse)
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.NotifyResponse)
-}
-
-int NotifyResponse::ByteSize() const {
- int total_size = 0;
-
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void NotifyResponse::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const NotifyResponse*>(&from));
-}
-
-void NotifyResponse::MergeFrom(const NotifyResponse& from) {
- GOOGLE_CHECK_NE(&from, this);
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void NotifyResponse::CopyFrom(const NotifyResponse& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool NotifyResponse::IsInitialized() const {
-
- return true;
-}
-
-void NotifyResponse::Swap(NotifyResponse* other) {
- if (other != this) {
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string NotifyResponse::GetTypeName() const {
- return "com.trustonic.tee_proxy.NotifyResponse";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int WaitNotificationRequest::kSidFieldNumber;
-const int WaitNotificationRequest::kTimeoutFieldNumber;
-const int WaitNotificationRequest::kPartialFieldNumber;
-#endif // !_MSC_VER
-
-WaitNotificationRequest::WaitNotificationRequest()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.WaitNotificationRequest)
-}
-
-void WaitNotificationRequest::InitAsDefaultInstance() {
-}
-
-WaitNotificationRequest::WaitNotificationRequest(const WaitNotificationRequest& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.WaitNotificationRequest)
-}
-
-void WaitNotificationRequest::SharedCtor() {
- _cached_size_ = 0;
- sid_ = 0u;
- timeout_ = 0;
- partial_ = false;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-WaitNotificationRequest::~WaitNotificationRequest() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.WaitNotificationRequest)
- SharedDtor();
-}
-
-void WaitNotificationRequest::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void WaitNotificationRequest::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const WaitNotificationRequest& WaitNotificationRequest::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-WaitNotificationRequest* WaitNotificationRequest::default_instance_ = NULL;
-
-WaitNotificationRequest* WaitNotificationRequest::New() const {
- return new WaitNotificationRequest;
-}
-
-void WaitNotificationRequest::Clear() {
-#define OFFSET_OF_FIELD_(f) (reinterpret_cast<char*>( \
- &reinterpret_cast<WaitNotificationRequest*>(16)->f) - \
- reinterpret_cast<char*>(16))
-
-#define ZR_(first, last) do { \
- size_t f = OFFSET_OF_FIELD_(first); \
- size_t n = OFFSET_OF_FIELD_(last) - f + sizeof(last); \
- ::memset(&first, 0, n); \
- } while (0)
-
- ZR_(sid_, partial_);
-
-#undef OFFSET_OF_FIELD_
-#undef ZR_
-
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool WaitNotificationRequest::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.WaitNotificationRequest)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint32 sid = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &sid_)));
- set_has_sid();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_timeout;
- break;
- }
-
- // required sint32 timeout = 2;
- case 2: {
- if (tag == 16) {
- parse_timeout:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_SINT32>(
- input, &timeout_)));
- set_has_timeout();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_partial;
- break;
- }
-
- // required bool partial = 3;
- case 3: {
- if (tag == 24) {
- parse_partial:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &partial_)));
- set_has_partial();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.WaitNotificationRequest)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.WaitNotificationRequest)
- return false;
-#undef DO_
-}
-
-void WaitNotificationRequest::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.WaitNotificationRequest)
- // required uint32 sid = 1;
- if (has_sid()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->sid(), output);
- }
-
- // required sint32 timeout = 2;
- if (has_timeout()) {
- ::google::protobuf::internal::WireFormatLite::WriteSInt32(2, this->timeout(), output);
- }
-
- // required bool partial = 3;
- if (has_partial()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->partial(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.WaitNotificationRequest)
-}
-
-int WaitNotificationRequest::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint32 sid = 1;
- if (has_sid()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->sid());
- }
-
- // required sint32 timeout = 2;
- if (has_timeout()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::SInt32Size(
- this->timeout());
- }
-
- // required bool partial = 3;
- if (has_partial()) {
- total_size += 1 + 1;
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void WaitNotificationRequest::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const WaitNotificationRequest*>(&from));
-}
-
-void WaitNotificationRequest::MergeFrom(const WaitNotificationRequest& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_sid()) {
- set_sid(from.sid());
- }
- if (from.has_timeout()) {
- set_timeout(from.timeout());
- }
- if (from.has_partial()) {
- set_partial(from.partial());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void WaitNotificationRequest::CopyFrom(const WaitNotificationRequest& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool WaitNotificationRequest::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000007) != 0x00000007) return false;
-
- return true;
-}
-
-void WaitNotificationRequest::Swap(WaitNotificationRequest* other) {
- if (other != this) {
- std::swap(sid_, other->sid_);
- std::swap(timeout_, other->timeout_);
- std::swap(partial_, other->partial_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string WaitNotificationRequest::GetTypeName() const {
- return "com.trustonic.tee_proxy.WaitNotificationRequest";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int WaitNotificationResponse_Buffers::kSvaFieldNumber;
-const int WaitNotificationResponse_Buffers::kDataFieldNumber;
-#endif // !_MSC_VER
-
-WaitNotificationResponse_Buffers::WaitNotificationResponse_Buffers()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers)
-}
-
-void WaitNotificationResponse_Buffers::InitAsDefaultInstance() {
-}
-
-WaitNotificationResponse_Buffers::WaitNotificationResponse_Buffers(const WaitNotificationResponse_Buffers& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers)
-}
-
-void WaitNotificationResponse_Buffers::SharedCtor() {
- ::google::protobuf::internal::GetEmptyString();
- _cached_size_ = 0;
- sva_ = GOOGLE_ULONGLONG(0);
- data_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-WaitNotificationResponse_Buffers::~WaitNotificationResponse_Buffers() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers)
- SharedDtor();
-}
-
-void WaitNotificationResponse_Buffers::SharedDtor() {
- if (data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete data_;
- }
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void WaitNotificationResponse_Buffers::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const WaitNotificationResponse_Buffers& WaitNotificationResponse_Buffers::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-WaitNotificationResponse_Buffers* WaitNotificationResponse_Buffers::default_instance_ = NULL;
-
-WaitNotificationResponse_Buffers* WaitNotificationResponse_Buffers::New() const {
- return new WaitNotificationResponse_Buffers;
-}
-
-void WaitNotificationResponse_Buffers::Clear() {
- if (_has_bits_[0 / 32] & 3) {
- sva_ = GOOGLE_ULONGLONG(0);
- if (has_data()) {
- if (data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_->clear();
- }
- }
- }
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool WaitNotificationResponse_Buffers::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint64 sva = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
- input, &sva_)));
- set_has_sva();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_data;
- break;
- }
-
- // required bytes data = 2;
- case 2: {
- if (tag == 18) {
- parse_data:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_data()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers)
- return false;
-#undef DO_
-}
-
-void WaitNotificationResponse_Buffers::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers)
- // required uint64 sva = 1;
- if (has_sva()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->sva(), output);
- }
-
- // required bytes data = 2;
- if (has_data()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
- 2, this->data(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers)
-}
-
-int WaitNotificationResponse_Buffers::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint64 sva = 1;
- if (has_sva()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt64Size(
- this->sva());
- }
-
- // required bytes data = 2;
- if (has_data()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->data());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void WaitNotificationResponse_Buffers::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const WaitNotificationResponse_Buffers*>(&from));
-}
-
-void WaitNotificationResponse_Buffers::MergeFrom(const WaitNotificationResponse_Buffers& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_sva()) {
- set_sva(from.sva());
- }
- if (from.has_data()) {
- set_data(from.data());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void WaitNotificationResponse_Buffers::CopyFrom(const WaitNotificationResponse_Buffers& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool WaitNotificationResponse_Buffers::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
-
- return true;
-}
-
-void WaitNotificationResponse_Buffers::Swap(WaitNotificationResponse_Buffers* other) {
- if (other != this) {
- std::swap(sva_, other->sva_);
- std::swap(data_, other->data_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string WaitNotificationResponse_Buffers::GetTypeName() const {
- return "com.trustonic.tee_proxy.WaitNotificationResponse.Buffers";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int WaitNotificationResponse::kTciFieldNumber;
-const int WaitNotificationResponse::kBuffersFieldNumber;
-#endif // !_MSC_VER
-
-WaitNotificationResponse::WaitNotificationResponse()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.WaitNotificationResponse)
-}
-
-void WaitNotificationResponse::InitAsDefaultInstance() {
-}
-
-WaitNotificationResponse::WaitNotificationResponse(const WaitNotificationResponse& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.WaitNotificationResponse)
-}
-
-void WaitNotificationResponse::SharedCtor() {
- ::google::protobuf::internal::GetEmptyString();
- _cached_size_ = 0;
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-WaitNotificationResponse::~WaitNotificationResponse() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.WaitNotificationResponse)
- SharedDtor();
-}
-
-void WaitNotificationResponse::SharedDtor() {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete tci_;
- }
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void WaitNotificationResponse::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const WaitNotificationResponse& WaitNotificationResponse::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-WaitNotificationResponse* WaitNotificationResponse::default_instance_ = NULL;
-
-WaitNotificationResponse* WaitNotificationResponse::New() const {
- return new WaitNotificationResponse;
-}
-
-void WaitNotificationResponse::Clear() {
- if (has_tci()) {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_->clear();
- }
- }
- buffers_.Clear();
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool WaitNotificationResponse::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.WaitNotificationResponse)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional bytes tci = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_tci()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_buffers;
- break;
- }
-
- // repeated .com.trustonic.tee_proxy.WaitNotificationResponse.Buffers buffers = 2;
- case 2: {
- if (tag == 18) {
- parse_buffers:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, add_buffers()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_buffers;
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.WaitNotificationResponse)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.WaitNotificationResponse)
- return false;
-#undef DO_
-}
-
-void WaitNotificationResponse::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.WaitNotificationResponse)
- // optional bytes tci = 1;
- if (has_tci()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
- 1, this->tci(), output);
- }
-
- // repeated .com.trustonic.tee_proxy.WaitNotificationResponse.Buffers buffers = 2;
- for (int i = 0; i < this->buffers_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 2, this->buffers(i), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.WaitNotificationResponse)
-}
-
-int WaitNotificationResponse::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // optional bytes tci = 1;
- if (has_tci()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->tci());
- }
-
- }
- // repeated .com.trustonic.tee_proxy.WaitNotificationResponse.Buffers buffers = 2;
- total_size += 1 * this->buffers_size();
- for (int i = 0; i < this->buffers_size(); i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->buffers(i));
- }
-
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void WaitNotificationResponse::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const WaitNotificationResponse*>(&from));
-}
-
-void WaitNotificationResponse::MergeFrom(const WaitNotificationResponse& from) {
- GOOGLE_CHECK_NE(&from, this);
- buffers_.MergeFrom(from.buffers_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_tci()) {
- set_tci(from.tci());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void WaitNotificationResponse::CopyFrom(const WaitNotificationResponse& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool WaitNotificationResponse::IsInitialized() const {
-
- if (!::google::protobuf::internal::AllAreInitialized(this->buffers())) return false;
- return true;
-}
-
-void WaitNotificationResponse::Swap(WaitNotificationResponse* other) {
- if (other != this) {
- std::swap(tci_, other->tci_);
- buffers_.Swap(&other->buffers_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string WaitNotificationResponse::GetTypeName() const {
- return "com.trustonic.tee_proxy.WaitNotificationResponse";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int MapRequest_Buffers::kLenFieldNumber;
-const int MapRequest_Buffers::kFlagsFieldNumber;
-#endif // !_MSC_VER
-
-MapRequest_Buffers::MapRequest_Buffers()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.MapRequest.Buffers)
-}
-
-void MapRequest_Buffers::InitAsDefaultInstance() {
-}
-
-MapRequest_Buffers::MapRequest_Buffers(const MapRequest_Buffers& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.MapRequest.Buffers)
-}
-
-void MapRequest_Buffers::SharedCtor() {
- _cached_size_ = 0;
- len_ = 0u;
- flags_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-MapRequest_Buffers::~MapRequest_Buffers() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.MapRequest.Buffers)
- SharedDtor();
-}
-
-void MapRequest_Buffers::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void MapRequest_Buffers::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const MapRequest_Buffers& MapRequest_Buffers::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-MapRequest_Buffers* MapRequest_Buffers::default_instance_ = NULL;
-
-MapRequest_Buffers* MapRequest_Buffers::New() const {
- return new MapRequest_Buffers;
-}
-
-void MapRequest_Buffers::Clear() {
-#define OFFSET_OF_FIELD_(f) (reinterpret_cast<char*>( \
- &reinterpret_cast<MapRequest_Buffers*>(16)->f) - \
- reinterpret_cast<char*>(16))
-
-#define ZR_(first, last) do { \
- size_t f = OFFSET_OF_FIELD_(first); \
- size_t n = OFFSET_OF_FIELD_(last) - f + sizeof(last); \
- ::memset(&first, 0, n); \
- } while (0)
-
- ZR_(len_, flags_);
-
-#undef OFFSET_OF_FIELD_
-#undef ZR_
-
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool MapRequest_Buffers::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.MapRequest.Buffers)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint32 len = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &len_)));
- set_has_len();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_flags;
- break;
- }
-
- // required uint32 flags = 2;
- case 2: {
- if (tag == 16) {
- parse_flags:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &flags_)));
- set_has_flags();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.MapRequest.Buffers)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.MapRequest.Buffers)
- return false;
-#undef DO_
-}
-
-void MapRequest_Buffers::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.MapRequest.Buffers)
- // required uint32 len = 1;
- if (has_len()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->len(), output);
- }
-
- // required uint32 flags = 2;
- if (has_flags()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->flags(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.MapRequest.Buffers)
-}
-
-int MapRequest_Buffers::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint32 len = 1;
- if (has_len()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->len());
- }
-
- // required uint32 flags = 2;
- if (has_flags()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->flags());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void MapRequest_Buffers::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const MapRequest_Buffers*>(&from));
-}
-
-void MapRequest_Buffers::MergeFrom(const MapRequest_Buffers& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_len()) {
- set_len(from.len());
- }
- if (from.has_flags()) {
- set_flags(from.flags());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void MapRequest_Buffers::CopyFrom(const MapRequest_Buffers& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool MapRequest_Buffers::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
-
- return true;
-}
-
-void MapRequest_Buffers::Swap(MapRequest_Buffers* other) {
- if (other != this) {
- std::swap(len_, other->len_);
- std::swap(flags_, other->flags_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string MapRequest_Buffers::GetTypeName() const {
- return "com.trustonic.tee_proxy.MapRequest.Buffers";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int MapRequest::kSidFieldNumber;
-const int MapRequest::kBuffersFieldNumber;
-#endif // !_MSC_VER
-
-MapRequest::MapRequest()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.MapRequest)
-}
-
-void MapRequest::InitAsDefaultInstance() {
-}
-
-MapRequest::MapRequest(const MapRequest& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.MapRequest)
-}
-
-void MapRequest::SharedCtor() {
- _cached_size_ = 0;
- sid_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-MapRequest::~MapRequest() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.MapRequest)
- SharedDtor();
-}
-
-void MapRequest::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void MapRequest::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const MapRequest& MapRequest::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-MapRequest* MapRequest::default_instance_ = NULL;
-
-MapRequest* MapRequest::New() const {
- return new MapRequest;
-}
-
-void MapRequest::Clear() {
- sid_ = 0u;
- buffers_.Clear();
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool MapRequest::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.MapRequest)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint32 sid = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &sid_)));
- set_has_sid();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_buffers;
- break;
- }
-
- // repeated .com.trustonic.tee_proxy.MapRequest.Buffers buffers = 2;
- case 2: {
- if (tag == 18) {
- parse_buffers:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, add_buffers()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_buffers;
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.MapRequest)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.MapRequest)
- return false;
-#undef DO_
-}
-
-void MapRequest::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.MapRequest)
- // required uint32 sid = 1;
- if (has_sid()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->sid(), output);
- }
-
- // repeated .com.trustonic.tee_proxy.MapRequest.Buffers buffers = 2;
- for (int i = 0; i < this->buffers_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 2, this->buffers(i), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.MapRequest)
-}
-
-int MapRequest::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint32 sid = 1;
- if (has_sid()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->sid());
- }
-
- }
- // repeated .com.trustonic.tee_proxy.MapRequest.Buffers buffers = 2;
- total_size += 1 * this->buffers_size();
- for (int i = 0; i < this->buffers_size(); i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->buffers(i));
- }
-
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void MapRequest::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const MapRequest*>(&from));
-}
-
-void MapRequest::MergeFrom(const MapRequest& from) {
- GOOGLE_CHECK_NE(&from, this);
- buffers_.MergeFrom(from.buffers_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_sid()) {
- set_sid(from.sid());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void MapRequest::CopyFrom(const MapRequest& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool MapRequest::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- if (!::google::protobuf::internal::AllAreInitialized(this->buffers())) return false;
- return true;
-}
-
-void MapRequest::Swap(MapRequest* other) {
- if (other != this) {
- std::swap(sid_, other->sid_);
- buffers_.Swap(&other->buffers_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string MapRequest::GetTypeName() const {
- return "com.trustonic.tee_proxy.MapRequest";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int MapResponse_Buffers::kSvaFieldNumber;
-#endif // !_MSC_VER
-
-MapResponse_Buffers::MapResponse_Buffers()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.MapResponse.Buffers)
-}
-
-void MapResponse_Buffers::InitAsDefaultInstance() {
-}
-
-MapResponse_Buffers::MapResponse_Buffers(const MapResponse_Buffers& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.MapResponse.Buffers)
-}
-
-void MapResponse_Buffers::SharedCtor() {
- _cached_size_ = 0;
- sva_ = GOOGLE_ULONGLONG(0);
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-MapResponse_Buffers::~MapResponse_Buffers() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.MapResponse.Buffers)
- SharedDtor();
-}
-
-void MapResponse_Buffers::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void MapResponse_Buffers::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const MapResponse_Buffers& MapResponse_Buffers::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-MapResponse_Buffers* MapResponse_Buffers::default_instance_ = NULL;
-
-MapResponse_Buffers* MapResponse_Buffers::New() const {
- return new MapResponse_Buffers;
-}
-
-void MapResponse_Buffers::Clear() {
- sva_ = GOOGLE_ULONGLONG(0);
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool MapResponse_Buffers::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.MapResponse.Buffers)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint64 sva = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
- input, &sva_)));
- set_has_sva();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.MapResponse.Buffers)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.MapResponse.Buffers)
- return false;
-#undef DO_
-}
-
-void MapResponse_Buffers::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.MapResponse.Buffers)
- // required uint64 sva = 1;
- if (has_sva()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->sva(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.MapResponse.Buffers)
-}
-
-int MapResponse_Buffers::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint64 sva = 1;
- if (has_sva()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt64Size(
- this->sva());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void MapResponse_Buffers::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const MapResponse_Buffers*>(&from));
-}
-
-void MapResponse_Buffers::MergeFrom(const MapResponse_Buffers& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_sva()) {
- set_sva(from.sva());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void MapResponse_Buffers::CopyFrom(const MapResponse_Buffers& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool MapResponse_Buffers::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- return true;
-}
-
-void MapResponse_Buffers::Swap(MapResponse_Buffers* other) {
- if (other != this) {
- std::swap(sva_, other->sva_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string MapResponse_Buffers::GetTypeName() const {
- return "com.trustonic.tee_proxy.MapResponse.Buffers";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int MapResponse::kBuffersFieldNumber;
-#endif // !_MSC_VER
-
-MapResponse::MapResponse()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.MapResponse)
-}
-
-void MapResponse::InitAsDefaultInstance() {
-}
-
-MapResponse::MapResponse(const MapResponse& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.MapResponse)
-}
-
-void MapResponse::SharedCtor() {
- _cached_size_ = 0;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-MapResponse::~MapResponse() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.MapResponse)
- SharedDtor();
-}
-
-void MapResponse::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void MapResponse::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const MapResponse& MapResponse::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-MapResponse* MapResponse::default_instance_ = NULL;
-
-MapResponse* MapResponse::New() const {
- return new MapResponse;
-}
-
-void MapResponse::Clear() {
- buffers_.Clear();
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool MapResponse::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.MapResponse)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // repeated .com.trustonic.tee_proxy.MapResponse.Buffers buffers = 1;
- case 1: {
- if (tag == 10) {
- parse_buffers:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, add_buffers()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(10)) goto parse_buffers;
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.MapResponse)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.MapResponse)
- return false;
-#undef DO_
-}
-
-void MapResponse::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.MapResponse)
- // repeated .com.trustonic.tee_proxy.MapResponse.Buffers buffers = 1;
- for (int i = 0; i < this->buffers_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 1, this->buffers(i), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.MapResponse)
-}
-
-int MapResponse::ByteSize() const {
- int total_size = 0;
-
- // repeated .com.trustonic.tee_proxy.MapResponse.Buffers buffers = 1;
- total_size += 1 * this->buffers_size();
- for (int i = 0; i < this->buffers_size(); i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->buffers(i));
- }
-
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void MapResponse::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const MapResponse*>(&from));
-}
-
-void MapResponse::MergeFrom(const MapResponse& from) {
- GOOGLE_CHECK_NE(&from, this);
- buffers_.MergeFrom(from.buffers_);
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void MapResponse::CopyFrom(const MapResponse& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool MapResponse::IsInitialized() const {
-
- if (!::google::protobuf::internal::AllAreInitialized(this->buffers())) return false;
- return true;
-}
-
-void MapResponse::Swap(MapResponse* other) {
- if (other != this) {
- buffers_.Swap(&other->buffers_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string MapResponse::GetTypeName() const {
- return "com.trustonic.tee_proxy.MapResponse";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int UnmapRequest_Buffers::kSvaFieldNumber;
-#endif // !_MSC_VER
-
-UnmapRequest_Buffers::UnmapRequest_Buffers()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.UnmapRequest.Buffers)
-}
-
-void UnmapRequest_Buffers::InitAsDefaultInstance() {
-}
-
-UnmapRequest_Buffers::UnmapRequest_Buffers(const UnmapRequest_Buffers& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.UnmapRequest.Buffers)
-}
-
-void UnmapRequest_Buffers::SharedCtor() {
- _cached_size_ = 0;
- sva_ = GOOGLE_ULONGLONG(0);
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-UnmapRequest_Buffers::~UnmapRequest_Buffers() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.UnmapRequest.Buffers)
- SharedDtor();
-}
-
-void UnmapRequest_Buffers::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void UnmapRequest_Buffers::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const UnmapRequest_Buffers& UnmapRequest_Buffers::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-UnmapRequest_Buffers* UnmapRequest_Buffers::default_instance_ = NULL;
-
-UnmapRequest_Buffers* UnmapRequest_Buffers::New() const {
- return new UnmapRequest_Buffers;
-}
-
-void UnmapRequest_Buffers::Clear() {
- sva_ = GOOGLE_ULONGLONG(0);
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool UnmapRequest_Buffers::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.UnmapRequest.Buffers)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint64 sva = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
- input, &sva_)));
- set_has_sva();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.UnmapRequest.Buffers)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.UnmapRequest.Buffers)
- return false;
-#undef DO_
-}
-
-void UnmapRequest_Buffers::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.UnmapRequest.Buffers)
- // required uint64 sva = 1;
- if (has_sva()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->sva(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.UnmapRequest.Buffers)
-}
-
-int UnmapRequest_Buffers::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint64 sva = 1;
- if (has_sva()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt64Size(
- this->sva());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void UnmapRequest_Buffers::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const UnmapRequest_Buffers*>(&from));
-}
-
-void UnmapRequest_Buffers::MergeFrom(const UnmapRequest_Buffers& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_sva()) {
- set_sva(from.sva());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void UnmapRequest_Buffers::CopyFrom(const UnmapRequest_Buffers& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool UnmapRequest_Buffers::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- return true;
-}
-
-void UnmapRequest_Buffers::Swap(UnmapRequest_Buffers* other) {
- if (other != this) {
- std::swap(sva_, other->sva_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string UnmapRequest_Buffers::GetTypeName() const {
- return "com.trustonic.tee_proxy.UnmapRequest.Buffers";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int UnmapRequest::kSidFieldNumber;
-const int UnmapRequest::kBuffersFieldNumber;
-#endif // !_MSC_VER
-
-UnmapRequest::UnmapRequest()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.UnmapRequest)
-}
-
-void UnmapRequest::InitAsDefaultInstance() {
-}
-
-UnmapRequest::UnmapRequest(const UnmapRequest& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.UnmapRequest)
-}
-
-void UnmapRequest::SharedCtor() {
- _cached_size_ = 0;
- sid_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-UnmapRequest::~UnmapRequest() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.UnmapRequest)
- SharedDtor();
-}
-
-void UnmapRequest::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void UnmapRequest::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const UnmapRequest& UnmapRequest::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-UnmapRequest* UnmapRequest::default_instance_ = NULL;
-
-UnmapRequest* UnmapRequest::New() const {
- return new UnmapRequest;
-}
-
-void UnmapRequest::Clear() {
- sid_ = 0u;
- buffers_.Clear();
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool UnmapRequest::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.UnmapRequest)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint32 sid = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &sid_)));
- set_has_sid();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_buffers;
- break;
- }
-
- // repeated .com.trustonic.tee_proxy.UnmapRequest.Buffers buffers = 2;
- case 2: {
- if (tag == 18) {
- parse_buffers:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, add_buffers()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_buffers;
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.UnmapRequest)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.UnmapRequest)
- return false;
-#undef DO_
-}
-
-void UnmapRequest::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.UnmapRequest)
- // required uint32 sid = 1;
- if (has_sid()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->sid(), output);
- }
-
- // repeated .com.trustonic.tee_proxy.UnmapRequest.Buffers buffers = 2;
- for (int i = 0; i < this->buffers_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 2, this->buffers(i), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.UnmapRequest)
-}
-
-int UnmapRequest::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint32 sid = 1;
- if (has_sid()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->sid());
- }
-
- }
- // repeated .com.trustonic.tee_proxy.UnmapRequest.Buffers buffers = 2;
- total_size += 1 * this->buffers_size();
- for (int i = 0; i < this->buffers_size(); i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->buffers(i));
- }
-
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void UnmapRequest::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const UnmapRequest*>(&from));
-}
-
-void UnmapRequest::MergeFrom(const UnmapRequest& from) {
- GOOGLE_CHECK_NE(&from, this);
- buffers_.MergeFrom(from.buffers_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_sid()) {
- set_sid(from.sid());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void UnmapRequest::CopyFrom(const UnmapRequest& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool UnmapRequest::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- if (!::google::protobuf::internal::AllAreInitialized(this->buffers())) return false;
- return true;
-}
-
-void UnmapRequest::Swap(UnmapRequest* other) {
- if (other != this) {
- std::swap(sid_, other->sid_);
- buffers_.Swap(&other->buffers_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string UnmapRequest::GetTypeName() const {
- return "com.trustonic.tee_proxy.UnmapRequest";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-#endif // !_MSC_VER
-
-UnmapResponse::UnmapResponse()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.UnmapResponse)
-}
-
-void UnmapResponse::InitAsDefaultInstance() {
-}
-
-UnmapResponse::UnmapResponse(const UnmapResponse& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.UnmapResponse)
-}
-
-void UnmapResponse::SharedCtor() {
- _cached_size_ = 0;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-UnmapResponse::~UnmapResponse() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.UnmapResponse)
- SharedDtor();
-}
-
-void UnmapResponse::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void UnmapResponse::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const UnmapResponse& UnmapResponse::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-UnmapResponse* UnmapResponse::default_instance_ = NULL;
-
-UnmapResponse* UnmapResponse::New() const {
- return new UnmapResponse;
-}
-
-void UnmapResponse::Clear() {
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool UnmapResponse::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.UnmapResponse)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.UnmapResponse)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.UnmapResponse)
- return false;
-#undef DO_
-}
-
-void UnmapResponse::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.UnmapResponse)
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.UnmapResponse)
-}
-
-int UnmapResponse::ByteSize() const {
- int total_size = 0;
-
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void UnmapResponse::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const UnmapResponse*>(&from));
-}
-
-void UnmapResponse::MergeFrom(const UnmapResponse& from) {
- GOOGLE_CHECK_NE(&from, this);
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void UnmapResponse::CopyFrom(const UnmapResponse& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool UnmapResponse::IsInitialized() const {
-
- return true;
-}
-
-void UnmapResponse::Swap(UnmapResponse* other) {
- if (other != this) {
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string UnmapResponse::GetTypeName() const {
- return "com.trustonic.tee_proxy.UnmapResponse";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int GetErrorRequest::kSidFieldNumber;
-#endif // !_MSC_VER
-
-GetErrorRequest::GetErrorRequest()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.GetErrorRequest)
-}
-
-void GetErrorRequest::InitAsDefaultInstance() {
-}
-
-GetErrorRequest::GetErrorRequest(const GetErrorRequest& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.GetErrorRequest)
-}
-
-void GetErrorRequest::SharedCtor() {
- _cached_size_ = 0;
- sid_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-GetErrorRequest::~GetErrorRequest() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.GetErrorRequest)
- SharedDtor();
-}
-
-void GetErrorRequest::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void GetErrorRequest::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const GetErrorRequest& GetErrorRequest::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-GetErrorRequest* GetErrorRequest::default_instance_ = NULL;
-
-GetErrorRequest* GetErrorRequest::New() const {
- return new GetErrorRequest;
-}
-
-void GetErrorRequest::Clear() {
- sid_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool GetErrorRequest::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.GetErrorRequest)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint32 sid = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &sid_)));
- set_has_sid();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.GetErrorRequest)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.GetErrorRequest)
- return false;
-#undef DO_
-}
-
-void GetErrorRequest::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.GetErrorRequest)
- // required uint32 sid = 1;
- if (has_sid()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->sid(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.GetErrorRequest)
-}
-
-int GetErrorRequest::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint32 sid = 1;
- if (has_sid()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->sid());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void GetErrorRequest::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const GetErrorRequest*>(&from));
-}
-
-void GetErrorRequest::MergeFrom(const GetErrorRequest& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_sid()) {
- set_sid(from.sid());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void GetErrorRequest::CopyFrom(const GetErrorRequest& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool GetErrorRequest::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- return true;
-}
-
-void GetErrorRequest::Swap(GetErrorRequest* other) {
- if (other != this) {
- std::swap(sid_, other->sid_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string GetErrorRequest::GetTypeName() const {
- return "com.trustonic.tee_proxy.GetErrorRequest";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int GetErrorResponse::kExitCodeFieldNumber;
-#endif // !_MSC_VER
-
-GetErrorResponse::GetErrorResponse()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.GetErrorResponse)
-}
-
-void GetErrorResponse::InitAsDefaultInstance() {
-}
-
-GetErrorResponse::GetErrorResponse(const GetErrorResponse& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.GetErrorResponse)
-}
-
-void GetErrorResponse::SharedCtor() {
- _cached_size_ = 0;
- exit_code_ = 0;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-GetErrorResponse::~GetErrorResponse() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.GetErrorResponse)
- SharedDtor();
-}
-
-void GetErrorResponse::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void GetErrorResponse::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const GetErrorResponse& GetErrorResponse::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-GetErrorResponse* GetErrorResponse::default_instance_ = NULL;
-
-GetErrorResponse* GetErrorResponse::New() const {
- return new GetErrorResponse;
-}
-
-void GetErrorResponse::Clear() {
- exit_code_ = 0;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool GetErrorResponse::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.GetErrorResponse)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required sint32 exit_code = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_SINT32>(
- input, &exit_code_)));
- set_has_exit_code();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.GetErrorResponse)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.GetErrorResponse)
- return false;
-#undef DO_
-}
-
-void GetErrorResponse::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.GetErrorResponse)
- // required sint32 exit_code = 1;
- if (has_exit_code()) {
- ::google::protobuf::internal::WireFormatLite::WriteSInt32(1, this->exit_code(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.GetErrorResponse)
-}
-
-int GetErrorResponse::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required sint32 exit_code = 1;
- if (has_exit_code()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::SInt32Size(
- this->exit_code());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void GetErrorResponse::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const GetErrorResponse*>(&from));
-}
-
-void GetErrorResponse::MergeFrom(const GetErrorResponse& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_exit_code()) {
- set_exit_code(from.exit_code());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void GetErrorResponse::CopyFrom(const GetErrorResponse& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool GetErrorResponse::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- return true;
-}
-
-void GetErrorResponse::Swap(GetErrorResponse* other) {
- if (other != this) {
- std::swap(exit_code_, other->exit_code_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string GetErrorResponse::GetTypeName() const {
- return "com.trustonic.tee_proxy.GetErrorResponse";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-#endif // !_MSC_VER
-
-GetVersionRequest::GetVersionRequest()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.GetVersionRequest)
-}
-
-void GetVersionRequest::InitAsDefaultInstance() {
-}
-
-GetVersionRequest::GetVersionRequest(const GetVersionRequest& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.GetVersionRequest)
-}
-
-void GetVersionRequest::SharedCtor() {
- _cached_size_ = 0;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-GetVersionRequest::~GetVersionRequest() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.GetVersionRequest)
- SharedDtor();
-}
-
-void GetVersionRequest::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void GetVersionRequest::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const GetVersionRequest& GetVersionRequest::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-GetVersionRequest* GetVersionRequest::default_instance_ = NULL;
-
-GetVersionRequest* GetVersionRequest::New() const {
- return new GetVersionRequest;
-}
-
-void GetVersionRequest::Clear() {
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool GetVersionRequest::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.GetVersionRequest)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.GetVersionRequest)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.GetVersionRequest)
- return false;
-#undef DO_
-}
-
-void GetVersionRequest::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.GetVersionRequest)
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.GetVersionRequest)
-}
-
-int GetVersionRequest::ByteSize() const {
- int total_size = 0;
-
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void GetVersionRequest::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const GetVersionRequest*>(&from));
-}
-
-void GetVersionRequest::MergeFrom(const GetVersionRequest& from) {
- GOOGLE_CHECK_NE(&from, this);
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void GetVersionRequest::CopyFrom(const GetVersionRequest& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool GetVersionRequest::IsInitialized() const {
-
- return true;
-}
-
-void GetVersionRequest::Swap(GetVersionRequest* other) {
- if (other != this) {
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string GetVersionRequest::GetTypeName() const {
- return "com.trustonic.tee_proxy.GetVersionRequest";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int GetVersionResponse::kProductIdFieldNumber;
-const int GetVersionResponse::kMciFieldNumber;
-const int GetVersionResponse::kSoFieldNumber;
-const int GetVersionResponse::kMclfFieldNumber;
-const int GetVersionResponse::kContainerFieldNumber;
-const int GetVersionResponse::kMcConfigFieldNumber;
-const int GetVersionResponse::kTlApiFieldNumber;
-const int GetVersionResponse::kDrApiFieldNumber;
-const int GetVersionResponse::kNwdFieldNumber;
-#endif // !_MSC_VER
-
-GetVersionResponse::GetVersionResponse()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.GetVersionResponse)
-}
-
-void GetVersionResponse::InitAsDefaultInstance() {
-}
-
-GetVersionResponse::GetVersionResponse(const GetVersionResponse& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.GetVersionResponse)
-}
-
-void GetVersionResponse::SharedCtor() {
- ::google::protobuf::internal::GetEmptyString();
- _cached_size_ = 0;
- product_id_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- mci_ = 0u;
- so_ = 0u;
- mclf_ = 0u;
- container_ = 0u;
- mc_config_ = 0u;
- tl_api_ = 0u;
- dr_api_ = 0u;
- nwd_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-GetVersionResponse::~GetVersionResponse() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.GetVersionResponse)
- SharedDtor();
-}
-
-void GetVersionResponse::SharedDtor() {
- if (product_id_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete product_id_;
- }
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void GetVersionResponse::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const GetVersionResponse& GetVersionResponse::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-GetVersionResponse* GetVersionResponse::default_instance_ = NULL;
-
-GetVersionResponse* GetVersionResponse::New() const {
- return new GetVersionResponse;
-}
-
-void GetVersionResponse::Clear() {
-#define OFFSET_OF_FIELD_(f) (reinterpret_cast<char*>( \
- &reinterpret_cast<GetVersionResponse*>(16)->f) - \
- reinterpret_cast<char*>(16))
-
-#define ZR_(first, last) do { \
- size_t f = OFFSET_OF_FIELD_(first); \
- size_t n = OFFSET_OF_FIELD_(last) - f + sizeof(last); \
- ::memset(&first, 0, n); \
- } while (0)
-
- if (_has_bits_[0 / 32] & 255) {
- ZR_(mci_, dr_api_);
- if (has_product_id()) {
- if (product_id_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- product_id_->clear();
- }
- }
- }
- nwd_ = 0u;
-
-#undef OFFSET_OF_FIELD_
-#undef ZR_
-
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool GetVersionResponse::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.GetVersionResponse)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required string product_id = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_product_id()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_mci;
- break;
- }
-
- // required uint32 mci = 2;
- case 2: {
- if (tag == 16) {
- parse_mci:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &mci_)));
- set_has_mci();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_so;
- break;
- }
-
- // required uint32 so = 3;
- case 3: {
- if (tag == 24) {
- parse_so:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &so_)));
- set_has_so();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_mclf;
- break;
- }
-
- // required uint32 mclf = 4;
- case 4: {
- if (tag == 32) {
- parse_mclf:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &mclf_)));
- set_has_mclf();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_container;
- break;
- }
-
- // required uint32 container = 5;
- case 5: {
- if (tag == 40) {
- parse_container:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &container_)));
- set_has_container();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(48)) goto parse_mc_config;
- break;
- }
-
- // required uint32 mc_config = 6;
- case 6: {
- if (tag == 48) {
- parse_mc_config:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &mc_config_)));
- set_has_mc_config();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(56)) goto parse_tl_api;
- break;
- }
-
- // required uint32 tl_api = 7;
- case 7: {
- if (tag == 56) {
- parse_tl_api:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &tl_api_)));
- set_has_tl_api();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(64)) goto parse_dr_api;
- break;
- }
-
- // required uint32 dr_api = 8;
- case 8: {
- if (tag == 64) {
- parse_dr_api:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &dr_api_)));
- set_has_dr_api();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(72)) goto parse_nwd;
- break;
- }
-
- // required uint32 nwd = 9;
- case 9: {
- if (tag == 72) {
- parse_nwd:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &nwd_)));
- set_has_nwd();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.GetVersionResponse)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.GetVersionResponse)
- return false;
-#undef DO_
-}
-
-void GetVersionResponse::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.GetVersionResponse)
- // required string product_id = 1;
- if (has_product_id()) {
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->product_id(), output);
- }
-
- // required uint32 mci = 2;
- if (has_mci()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->mci(), output);
- }
-
- // required uint32 so = 3;
- if (has_so()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->so(), output);
- }
-
- // required uint32 mclf = 4;
- if (has_mclf()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->mclf(), output);
- }
-
- // required uint32 container = 5;
- if (has_container()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->container(), output);
- }
-
- // required uint32 mc_config = 6;
- if (has_mc_config()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(6, this->mc_config(), output);
- }
-
- // required uint32 tl_api = 7;
- if (has_tl_api()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->tl_api(), output);
- }
-
- // required uint32 dr_api = 8;
- if (has_dr_api()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(8, this->dr_api(), output);
- }
-
- // required uint32 nwd = 9;
- if (has_nwd()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(9, this->nwd(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.GetVersionResponse)
-}
-
-int GetVersionResponse::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required string product_id = 1;
- if (has_product_id()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->product_id());
- }
-
- // required uint32 mci = 2;
- if (has_mci()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->mci());
- }
-
- // required uint32 so = 3;
- if (has_so()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->so());
- }
-
- // required uint32 mclf = 4;
- if (has_mclf()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->mclf());
- }
-
- // required uint32 container = 5;
- if (has_container()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->container());
- }
-
- // required uint32 mc_config = 6;
- if (has_mc_config()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->mc_config());
- }
-
- // required uint32 tl_api = 7;
- if (has_tl_api()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->tl_api());
- }
-
- // required uint32 dr_api = 8;
- if (has_dr_api()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->dr_api());
- }
-
- }
- if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- // required uint32 nwd = 9;
- if (has_nwd()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->nwd());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void GetVersionResponse::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const GetVersionResponse*>(&from));
-}
-
-void GetVersionResponse::MergeFrom(const GetVersionResponse& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_product_id()) {
- set_product_id(from.product_id());
- }
- if (from.has_mci()) {
- set_mci(from.mci());
- }
- if (from.has_so()) {
- set_so(from.so());
- }
- if (from.has_mclf()) {
- set_mclf(from.mclf());
- }
- if (from.has_container()) {
- set_container(from.container());
- }
- if (from.has_mc_config()) {
- set_mc_config(from.mc_config());
- }
- if (from.has_tl_api()) {
- set_tl_api(from.tl_api());
- }
- if (from.has_dr_api()) {
- set_dr_api(from.dr_api());
- }
- }
- if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- if (from.has_nwd()) {
- set_nwd(from.nwd());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void GetVersionResponse::CopyFrom(const GetVersionResponse& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool GetVersionResponse::IsInitialized() const {
- if ((_has_bits_[0] & 0x000001ff) != 0x000001ff) return false;
-
- return true;
-}
-
-void GetVersionResponse::Swap(GetVersionResponse* other) {
- if (other != this) {
- std::swap(product_id_, other->product_id_);
- std::swap(mci_, other->mci_);
- std::swap(so_, other->so_);
- std::swap(mclf_, other->mclf_);
- std::swap(container_, other->container_);
- std::swap(mc_config_, other->mc_config_);
- std::swap(tl_api_, other->tl_api_);
- std::swap(dr_api_, other->dr_api_);
- std::swap(nwd_, other->nwd_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string GetVersionResponse::GetTypeName() const {
- return "com.trustonic.tee_proxy.GetVersionResponse";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-const int GpRequestCancellationRequest::kSidFieldNumber;
-#endif // !_MSC_VER
-
-GpRequestCancellationRequest::GpRequestCancellationRequest()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.GpRequestCancellationRequest)
-}
-
-void GpRequestCancellationRequest::InitAsDefaultInstance() {
-}
-
-GpRequestCancellationRequest::GpRequestCancellationRequest(const GpRequestCancellationRequest& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.GpRequestCancellationRequest)
-}
-
-void GpRequestCancellationRequest::SharedCtor() {
- _cached_size_ = 0;
- sid_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-GpRequestCancellationRequest::~GpRequestCancellationRequest() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.GpRequestCancellationRequest)
- SharedDtor();
-}
-
-void GpRequestCancellationRequest::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void GpRequestCancellationRequest::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const GpRequestCancellationRequest& GpRequestCancellationRequest::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-GpRequestCancellationRequest* GpRequestCancellationRequest::default_instance_ = NULL;
-
-GpRequestCancellationRequest* GpRequestCancellationRequest::New() const {
- return new GpRequestCancellationRequest;
-}
-
-void GpRequestCancellationRequest::Clear() {
- sid_ = 0u;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool GpRequestCancellationRequest::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.GpRequestCancellationRequest)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required uint32 sid = 1;
- case 1: {
- if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &sid_)));
- set_has_sid();
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.GpRequestCancellationRequest)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.GpRequestCancellationRequest)
- return false;
-#undef DO_
-}
-
-void GpRequestCancellationRequest::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.GpRequestCancellationRequest)
- // required uint32 sid = 1;
- if (has_sid()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->sid(), output);
- }
-
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.GpRequestCancellationRequest)
-}
-
-int GpRequestCancellationRequest::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required uint32 sid = 1;
- if (has_sid()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->sid());
- }
-
- }
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void GpRequestCancellationRequest::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const GpRequestCancellationRequest*>(&from));
-}
-
-void GpRequestCancellationRequest::MergeFrom(const GpRequestCancellationRequest& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_sid()) {
- set_sid(from.sid());
- }
- }
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void GpRequestCancellationRequest::CopyFrom(const GpRequestCancellationRequest& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool GpRequestCancellationRequest::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- return true;
-}
-
-void GpRequestCancellationRequest::Swap(GpRequestCancellationRequest* other) {
- if (other != this) {
- std::swap(sid_, other->sid_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string GpRequestCancellationRequest::GetTypeName() const {
- return "com.trustonic.tee_proxy.GpRequestCancellationRequest";
-}
-
-
-// ===================================================================
-
-#ifndef _MSC_VER
-#endif // !_MSC_VER
-
-GpRequestCancellationResponse::GpRequestCancellationResponse()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- // @@protoc_insertion_point(constructor:com.trustonic.tee_proxy.GpRequestCancellationResponse)
-}
-
-void GpRequestCancellationResponse::InitAsDefaultInstance() {
-}
-
-GpRequestCancellationResponse::GpRequestCancellationResponse(const GpRequestCancellationResponse& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:com.trustonic.tee_proxy.GpRequestCancellationResponse)
-}
-
-void GpRequestCancellationResponse::SharedCtor() {
- _cached_size_ = 0;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-GpRequestCancellationResponse::~GpRequestCancellationResponse() {
- // @@protoc_insertion_point(destructor:com.trustonic.tee_proxy.GpRequestCancellationResponse)
- SharedDtor();
-}
-
-void GpRequestCancellationResponse::SharedDtor() {
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- if (this != &default_instance()) {
- #else
- if (this != default_instance_) {
- #endif
- }
-}
-
-void GpRequestCancellationResponse::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const GpRequestCancellationResponse& GpRequestCancellationResponse::default_instance() {
-#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- protobuf_AddDesc_mc_2eproto();
-#else
- if (default_instance_ == NULL) protobuf_AddDesc_mc_2eproto();
-#endif
- return *default_instance_;
-}
-
-GpRequestCancellationResponse* GpRequestCancellationResponse::default_instance_ = NULL;
-
-GpRequestCancellationResponse* GpRequestCancellationResponse::New() const {
- return new GpRequestCancellationResponse;
-}
-
-void GpRequestCancellationResponse::Clear() {
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
- mutable_unknown_fields()->clear();
-}
-
-bool GpRequestCancellationResponse::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- ::google::protobuf::io::StringOutputStream unknown_fields_string(
- mutable_unknown_fields());
- ::google::protobuf::io::CodedOutputStream unknown_fields_stream(
- &unknown_fields_string);
- // @@protoc_insertion_point(parse_start:com.trustonic.tee_proxy.GpRequestCancellationResponse)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(
- input, tag, &unknown_fields_stream));
- }
-success:
- // @@protoc_insertion_point(parse_success:com.trustonic.tee_proxy.GpRequestCancellationResponse)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:com.trustonic.tee_proxy.GpRequestCancellationResponse)
- return false;
-#undef DO_
-}
-
-void GpRequestCancellationResponse::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:com.trustonic.tee_proxy.GpRequestCancellationResponse)
- output->WriteRaw(unknown_fields().data(),
- unknown_fields().size());
- // @@protoc_insertion_point(serialize_end:com.trustonic.tee_proxy.GpRequestCancellationResponse)
-}
-
-int GpRequestCancellationResponse::ByteSize() const {
- int total_size = 0;
-
- total_size += unknown_fields().size();
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void GpRequestCancellationResponse::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast<const GpRequestCancellationResponse*>(&from));
-}
-
-void GpRequestCancellationResponse::MergeFrom(const GpRequestCancellationResponse& from) {
- GOOGLE_CHECK_NE(&from, this);
- mutable_unknown_fields()->append(from.unknown_fields());
-}
-
-void GpRequestCancellationResponse::CopyFrom(const GpRequestCancellationResponse& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool GpRequestCancellationResponse::IsInitialized() const {
-
- return true;
-}
-
-void GpRequestCancellationResponse::Swap(GpRequestCancellationResponse* other) {
- if (other != this) {
- _unknown_fields_.swap(other->_unknown_fields_);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string GpRequestCancellationResponse::GetTypeName() const {
- return "com.trustonic.tee_proxy.GpRequestCancellationResponse";
-}
-
-
-// @@protoc_insertion_point(namespace_scope)
-
-} // namespace tee_proxy
-} // namespace trustonic
-} // namespace com
-
-// @@protoc_insertion_point(global_scope)
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: mc.proto
-
-#ifndef PROTOBUF_mc_2eproto__INCLUDED
-#define PROTOBUF_mc_2eproto__INCLUDED
-
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-
-#if GOOGLE_PROTOBUF_VERSION < 2006000
-#warning This file was generated by a newer version of protoc which is
-#warning incompatible with your Protocol Buffer headers. Please update
-#warning your headers.
-#endif
-#if 2006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
-#warning This file was generated by an older version of protoc which is
-#warning incompatible with your Protocol Buffer headers. Please
-#warning regenerate this file with a newer version of protoc.
-#endif
-
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/message_lite.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
-// @@protoc_insertion_point(includes)
-
-namespace com {
-namespace trustonic {
-namespace tee_proxy {
-
-// Internal implementation detail -- do not call these.
-void protobuf_AddDesc_mc_2eproto();
-void protobuf_AssignDesc_mc_2eproto();
-void protobuf_ShutdownFile_mc_2eproto();
-
-class OpenSessionRequest;
-class OpenSessionResponse;
-class OpenTrustletRequest;
-class OpenTrustletResponse;
-class CloseSessionRequest;
-class CloseSessionResponse;
-class NotifyRequest;
-class NotifyRequest_Buffers;
-class NotifyResponse;
-class WaitNotificationRequest;
-class WaitNotificationResponse;
-class WaitNotificationResponse_Buffers;
-class MapRequest;
-class MapRequest_Buffers;
-class MapResponse;
-class MapResponse_Buffers;
-class UnmapRequest;
-class UnmapRequest_Buffers;
-class UnmapResponse;
-class GetErrorRequest;
-class GetErrorResponse;
-class GetVersionRequest;
-class GetVersionResponse;
-class GpRequestCancellationRequest;
-class GpRequestCancellationResponse;
-
-enum LoginType {
- TEEC_LOGIN_PUBLIC = 0,
- TEEC_LOGIN_USER = 1,
- TEEC_LOGIN_GROUP = 2,
- TEEC_LOGIN_APPLICATION = 4,
- TEEC_LOGIN_USER_APPLICATION = 5,
- TEEC_LOGIN_GROUP_APPLICATION = 6
-};
-bool LoginType_IsValid(int value);
-const LoginType LoginType_MIN = TEEC_LOGIN_PUBLIC;
-const LoginType LoginType_MAX = TEEC_LOGIN_GROUP_APPLICATION;
-const int LoginType_ARRAYSIZE = LoginType_MAX + 1;
-
-// ===================================================================
-
-class OpenSessionRequest : public ::google::protobuf::MessageLite {
- public:
- OpenSessionRequest();
- virtual ~OpenSessionRequest();
-
- OpenSessionRequest(const OpenSessionRequest& from);
-
- inline OpenSessionRequest& operator=(const OpenSessionRequest& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const OpenSessionRequest& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const OpenSessionRequest* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(OpenSessionRequest* other);
-
- // implements Message ----------------------------------------------
-
- OpenSessionRequest* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const OpenSessionRequest& from);
- void MergeFrom(const OpenSessionRequest& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required bytes uuid = 1;
- inline bool has_uuid() const;
- inline void clear_uuid();
- static const int kUuidFieldNumber = 1;
- inline const ::std::string& uuid() const;
- inline void set_uuid(const ::std::string& value);
- inline void set_uuid(const char* value);
- inline void set_uuid(const void* value, size_t size);
- inline ::std::string* mutable_uuid();
- inline ::std::string* release_uuid();
- inline void set_allocated_uuid(::std::string* uuid);
-
- // required bool is_gp_uuid = 2;
- inline bool has_is_gp_uuid() const;
- inline void clear_is_gp_uuid();
- static const int kIsGpUuidFieldNumber = 2;
- inline bool is_gp_uuid() const;
- inline void set_is_gp_uuid(bool value);
-
- // optional bytes tci = 3;
- inline bool has_tci() const;
- inline void clear_tci();
- static const int kTciFieldNumber = 3;
- inline const ::std::string& tci() const;
- inline void set_tci(const ::std::string& value);
- inline void set_tci(const char* value);
- inline void set_tci(const void* value, size_t size);
- inline ::std::string* mutable_tci();
- inline ::std::string* release_tci();
- inline void set_allocated_tci(::std::string* tci);
-
- // required .com.trustonic.tee_proxy.LoginType login_type = 4;
- inline bool has_login_type() const;
- inline void clear_login_type();
- static const int kLoginTypeFieldNumber = 4;
- inline ::com::trustonic::tee_proxy::LoginType login_type() const;
- inline void set_login_type(::com::trustonic::tee_proxy::LoginType value);
-
- // required bytes login_data = 5;
- inline bool has_login_data() const;
- inline void clear_login_data();
- static const int kLoginDataFieldNumber = 5;
- inline const ::std::string& login_data() const;
- inline void set_login_data(const ::std::string& value);
- inline void set_login_data(const char* value);
- inline void set_login_data(const void* value, size_t size);
- inline ::std::string* mutable_login_data();
- inline ::std::string* release_login_data();
- inline void set_allocated_login_data(::std::string* login_data);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.OpenSessionRequest)
- private:
- inline void set_has_uuid();
- inline void clear_has_uuid();
- inline void set_has_is_gp_uuid();
- inline void clear_has_is_gp_uuid();
- inline void set_has_tci();
- inline void clear_has_tci();
- inline void set_has_login_type();
- inline void clear_has_login_type();
- inline void set_has_login_data();
- inline void clear_has_login_data();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::std::string* uuid_;
- ::std::string* tci_;
- bool is_gp_uuid_;
- int login_type_;
- ::std::string* login_data_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static OpenSessionRequest* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class OpenSessionResponse : public ::google::protobuf::MessageLite {
- public:
- OpenSessionResponse();
- virtual ~OpenSessionResponse();
-
- OpenSessionResponse(const OpenSessionResponse& from);
-
- inline OpenSessionResponse& operator=(const OpenSessionResponse& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const OpenSessionResponse& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const OpenSessionResponse* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(OpenSessionResponse* other);
-
- // implements Message ----------------------------------------------
-
- OpenSessionResponse* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const OpenSessionResponse& from);
- void MergeFrom(const OpenSessionResponse& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint32 id = 1;
- inline bool has_id() const;
- inline void clear_id();
- static const int kIdFieldNumber = 1;
- inline ::google::protobuf::uint32 id() const;
- inline void set_id(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.OpenSessionResponse)
- private:
- inline void set_has_id();
- inline void clear_has_id();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::uint32 id_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static OpenSessionResponse* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class OpenTrustletRequest : public ::google::protobuf::MessageLite {
- public:
- OpenTrustletRequest();
- virtual ~OpenTrustletRequest();
-
- OpenTrustletRequest(const OpenTrustletRequest& from);
-
- inline OpenTrustletRequest& operator=(const OpenTrustletRequest& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const OpenTrustletRequest& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const OpenTrustletRequest* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(OpenTrustletRequest* other);
-
- // implements Message ----------------------------------------------
-
- OpenTrustletRequest* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const OpenTrustletRequest& from);
- void MergeFrom(const OpenTrustletRequest& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint32 spid = 1;
- inline bool has_spid() const;
- inline void clear_spid();
- static const int kSpidFieldNumber = 1;
- inline ::google::protobuf::uint32 spid() const;
- inline void set_spid(::google::protobuf::uint32 value);
-
- // required bytes trustapp = 2;
- inline bool has_trustapp() const;
- inline void clear_trustapp();
- static const int kTrustappFieldNumber = 2;
- inline const ::std::string& trustapp() const;
- inline void set_trustapp(const ::std::string& value);
- inline void set_trustapp(const char* value);
- inline void set_trustapp(const void* value, size_t size);
- inline ::std::string* mutable_trustapp();
- inline ::std::string* release_trustapp();
- inline void set_allocated_trustapp(::std::string* trustapp);
-
- // optional bytes tci = 3;
- inline bool has_tci() const;
- inline void clear_tci();
- static const int kTciFieldNumber = 3;
- inline const ::std::string& tci() const;
- inline void set_tci(const ::std::string& value);
- inline void set_tci(const char* value);
- inline void set_tci(const void* value, size_t size);
- inline ::std::string* mutable_tci();
- inline ::std::string* release_tci();
- inline void set_allocated_tci(::std::string* tci);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.OpenTrustletRequest)
- private:
- inline void set_has_spid();
- inline void clear_has_spid();
- inline void set_has_trustapp();
- inline void clear_has_trustapp();
- inline void set_has_tci();
- inline void clear_has_tci();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::std::string* trustapp_;
- ::std::string* tci_;
- ::google::protobuf::uint32 spid_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static OpenTrustletRequest* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class OpenTrustletResponse : public ::google::protobuf::MessageLite {
- public:
- OpenTrustletResponse();
- virtual ~OpenTrustletResponse();
-
- OpenTrustletResponse(const OpenTrustletResponse& from);
-
- inline OpenTrustletResponse& operator=(const OpenTrustletResponse& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const OpenTrustletResponse& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const OpenTrustletResponse* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(OpenTrustletResponse* other);
-
- // implements Message ----------------------------------------------
-
- OpenTrustletResponse* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const OpenTrustletResponse& from);
- void MergeFrom(const OpenTrustletResponse& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint32 id = 1;
- inline bool has_id() const;
- inline void clear_id();
- static const int kIdFieldNumber = 1;
- inline ::google::protobuf::uint32 id() const;
- inline void set_id(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.OpenTrustletResponse)
- private:
- inline void set_has_id();
- inline void clear_has_id();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::uint32 id_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static OpenTrustletResponse* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class CloseSessionRequest : public ::google::protobuf::MessageLite {
- public:
- CloseSessionRequest();
- virtual ~CloseSessionRequest();
-
- CloseSessionRequest(const CloseSessionRequest& from);
-
- inline CloseSessionRequest& operator=(const CloseSessionRequest& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const CloseSessionRequest& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const CloseSessionRequest* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(CloseSessionRequest* other);
-
- // implements Message ----------------------------------------------
-
- CloseSessionRequest* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const CloseSessionRequest& from);
- void MergeFrom(const CloseSessionRequest& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint32 id = 1;
- inline bool has_id() const;
- inline void clear_id();
- static const int kIdFieldNumber = 1;
- inline ::google::protobuf::uint32 id() const;
- inline void set_id(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.CloseSessionRequest)
- private:
- inline void set_has_id();
- inline void clear_has_id();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::uint32 id_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static CloseSessionRequest* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class CloseSessionResponse : public ::google::protobuf::MessageLite {
- public:
- CloseSessionResponse();
- virtual ~CloseSessionResponse();
-
- CloseSessionResponse(const CloseSessionResponse& from);
-
- inline CloseSessionResponse& operator=(const CloseSessionResponse& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const CloseSessionResponse& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const CloseSessionResponse* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(CloseSessionResponse* other);
-
- // implements Message ----------------------------------------------
-
- CloseSessionResponse* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const CloseSessionResponse& from);
- void MergeFrom(const CloseSessionResponse& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.CloseSessionResponse)
- private:
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static CloseSessionResponse* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class NotifyRequest_Buffers : public ::google::protobuf::MessageLite {
- public:
- NotifyRequest_Buffers();
- virtual ~NotifyRequest_Buffers();
-
- NotifyRequest_Buffers(const NotifyRequest_Buffers& from);
-
- inline NotifyRequest_Buffers& operator=(const NotifyRequest_Buffers& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const NotifyRequest_Buffers& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const NotifyRequest_Buffers* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(NotifyRequest_Buffers* other);
-
- // implements Message ----------------------------------------------
-
- NotifyRequest_Buffers* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const NotifyRequest_Buffers& from);
- void MergeFrom(const NotifyRequest_Buffers& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint64 sva = 1;
- inline bool has_sva() const;
- inline void clear_sva();
- static const int kSvaFieldNumber = 1;
- inline ::google::protobuf::uint64 sva() const;
- inline void set_sva(::google::protobuf::uint64 value);
-
- // required bytes data = 2;
- inline bool has_data() const;
- inline void clear_data();
- static const int kDataFieldNumber = 2;
- inline const ::std::string& data() const;
- inline void set_data(const ::std::string& value);
- inline void set_data(const char* value);
- inline void set_data(const void* value, size_t size);
- inline ::std::string* mutable_data();
- inline ::std::string* release_data();
- inline void set_allocated_data(::std::string* data);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.NotifyRequest.Buffers)
- private:
- inline void set_has_sva();
- inline void clear_has_sva();
- inline void set_has_data();
- inline void clear_has_data();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::uint64 sva_;
- ::std::string* data_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static NotifyRequest_Buffers* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class NotifyRequest : public ::google::protobuf::MessageLite {
- public:
- NotifyRequest();
- virtual ~NotifyRequest();
-
- NotifyRequest(const NotifyRequest& from);
-
- inline NotifyRequest& operator=(const NotifyRequest& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const NotifyRequest& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const NotifyRequest* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(NotifyRequest* other);
-
- // implements Message ----------------------------------------------
-
- NotifyRequest* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const NotifyRequest& from);
- void MergeFrom(const NotifyRequest& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- typedef NotifyRequest_Buffers Buffers;
-
- // accessors -------------------------------------------------------
-
- // required uint32 sid = 1;
- inline bool has_sid() const;
- inline void clear_sid();
- static const int kSidFieldNumber = 1;
- inline ::google::protobuf::uint32 sid() const;
- inline void set_sid(::google::protobuf::uint32 value);
-
- // optional bytes tci = 2;
- inline bool has_tci() const;
- inline void clear_tci();
- static const int kTciFieldNumber = 2;
- inline const ::std::string& tci() const;
- inline void set_tci(const ::std::string& value);
- inline void set_tci(const char* value);
- inline void set_tci(const void* value, size_t size);
- inline ::std::string* mutable_tci();
- inline ::std::string* release_tci();
- inline void set_allocated_tci(::std::string* tci);
-
- // repeated .com.trustonic.tee_proxy.NotifyRequest.Buffers buffers = 3;
- inline int buffers_size() const;
- inline void clear_buffers();
- static const int kBuffersFieldNumber = 3;
- inline const ::com::trustonic::tee_proxy::NotifyRequest_Buffers& buffers(int index) const;
- inline ::com::trustonic::tee_proxy::NotifyRequest_Buffers* mutable_buffers(int index);
- inline ::com::trustonic::tee_proxy::NotifyRequest_Buffers* add_buffers();
- inline const ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::NotifyRequest_Buffers >&
- buffers() const;
- inline ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::NotifyRequest_Buffers >*
- mutable_buffers();
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.NotifyRequest)
- private:
- inline void set_has_sid();
- inline void clear_has_sid();
- inline void set_has_tci();
- inline void clear_has_tci();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::std::string* tci_;
- ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::NotifyRequest_Buffers > buffers_;
- ::google::protobuf::uint32 sid_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static NotifyRequest* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class NotifyResponse : public ::google::protobuf::MessageLite {
- public:
- NotifyResponse();
- virtual ~NotifyResponse();
-
- NotifyResponse(const NotifyResponse& from);
-
- inline NotifyResponse& operator=(const NotifyResponse& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const NotifyResponse& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const NotifyResponse* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(NotifyResponse* other);
-
- // implements Message ----------------------------------------------
-
- NotifyResponse* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const NotifyResponse& from);
- void MergeFrom(const NotifyResponse& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.NotifyResponse)
- private:
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static NotifyResponse* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class WaitNotificationRequest : public ::google::protobuf::MessageLite {
- public:
- WaitNotificationRequest();
- virtual ~WaitNotificationRequest();
-
- WaitNotificationRequest(const WaitNotificationRequest& from);
-
- inline WaitNotificationRequest& operator=(const WaitNotificationRequest& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const WaitNotificationRequest& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const WaitNotificationRequest* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(WaitNotificationRequest* other);
-
- // implements Message ----------------------------------------------
-
- WaitNotificationRequest* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const WaitNotificationRequest& from);
- void MergeFrom(const WaitNotificationRequest& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint32 sid = 1;
- inline bool has_sid() const;
- inline void clear_sid();
- static const int kSidFieldNumber = 1;
- inline ::google::protobuf::uint32 sid() const;
- inline void set_sid(::google::protobuf::uint32 value);
-
- // required sint32 timeout = 2;
- inline bool has_timeout() const;
- inline void clear_timeout();
- static const int kTimeoutFieldNumber = 2;
- inline ::google::protobuf::int32 timeout() const;
- inline void set_timeout(::google::protobuf::int32 value);
-
- // required bool partial = 3;
- inline bool has_partial() const;
- inline void clear_partial();
- static const int kPartialFieldNumber = 3;
- inline bool partial() const;
- inline void set_partial(bool value);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.WaitNotificationRequest)
- private:
- inline void set_has_sid();
- inline void clear_has_sid();
- inline void set_has_timeout();
- inline void clear_has_timeout();
- inline void set_has_partial();
- inline void clear_has_partial();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::uint32 sid_;
- ::google::protobuf::int32 timeout_;
- bool partial_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static WaitNotificationRequest* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class WaitNotificationResponse_Buffers : public ::google::protobuf::MessageLite {
- public:
- WaitNotificationResponse_Buffers();
- virtual ~WaitNotificationResponse_Buffers();
-
- WaitNotificationResponse_Buffers(const WaitNotificationResponse_Buffers& from);
-
- inline WaitNotificationResponse_Buffers& operator=(const WaitNotificationResponse_Buffers& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const WaitNotificationResponse_Buffers& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const WaitNotificationResponse_Buffers* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(WaitNotificationResponse_Buffers* other);
-
- // implements Message ----------------------------------------------
-
- WaitNotificationResponse_Buffers* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const WaitNotificationResponse_Buffers& from);
- void MergeFrom(const WaitNotificationResponse_Buffers& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint64 sva = 1;
- inline bool has_sva() const;
- inline void clear_sva();
- static const int kSvaFieldNumber = 1;
- inline ::google::protobuf::uint64 sva() const;
- inline void set_sva(::google::protobuf::uint64 value);
-
- // required bytes data = 2;
- inline bool has_data() const;
- inline void clear_data();
- static const int kDataFieldNumber = 2;
- inline const ::std::string& data() const;
- inline void set_data(const ::std::string& value);
- inline void set_data(const char* value);
- inline void set_data(const void* value, size_t size);
- inline ::std::string* mutable_data();
- inline ::std::string* release_data();
- inline void set_allocated_data(::std::string* data);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers)
- private:
- inline void set_has_sva();
- inline void clear_has_sva();
- inline void set_has_data();
- inline void clear_has_data();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::uint64 sva_;
- ::std::string* data_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static WaitNotificationResponse_Buffers* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class WaitNotificationResponse : public ::google::protobuf::MessageLite {
- public:
- WaitNotificationResponse();
- virtual ~WaitNotificationResponse();
-
- WaitNotificationResponse(const WaitNotificationResponse& from);
-
- inline WaitNotificationResponse& operator=(const WaitNotificationResponse& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const WaitNotificationResponse& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const WaitNotificationResponse* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(WaitNotificationResponse* other);
-
- // implements Message ----------------------------------------------
-
- WaitNotificationResponse* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const WaitNotificationResponse& from);
- void MergeFrom(const WaitNotificationResponse& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- typedef WaitNotificationResponse_Buffers Buffers;
-
- // accessors -------------------------------------------------------
-
- // optional bytes tci = 1;
- inline bool has_tci() const;
- inline void clear_tci();
- static const int kTciFieldNumber = 1;
- inline const ::std::string& tci() const;
- inline void set_tci(const ::std::string& value);
- inline void set_tci(const char* value);
- inline void set_tci(const void* value, size_t size);
- inline ::std::string* mutable_tci();
- inline ::std::string* release_tci();
- inline void set_allocated_tci(::std::string* tci);
-
- // repeated .com.trustonic.tee_proxy.WaitNotificationResponse.Buffers buffers = 2;
- inline int buffers_size() const;
- inline void clear_buffers();
- static const int kBuffersFieldNumber = 2;
- inline const ::com::trustonic::tee_proxy::WaitNotificationResponse_Buffers& buffers(int index) const;
- inline ::com::trustonic::tee_proxy::WaitNotificationResponse_Buffers* mutable_buffers(int index);
- inline ::com::trustonic::tee_proxy::WaitNotificationResponse_Buffers* add_buffers();
- inline const ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::WaitNotificationResponse_Buffers >&
- buffers() const;
- inline ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::WaitNotificationResponse_Buffers >*
- mutable_buffers();
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.WaitNotificationResponse)
- private:
- inline void set_has_tci();
- inline void clear_has_tci();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::std::string* tci_;
- ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::WaitNotificationResponse_Buffers > buffers_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static WaitNotificationResponse* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class MapRequest_Buffers : public ::google::protobuf::MessageLite {
- public:
- MapRequest_Buffers();
- virtual ~MapRequest_Buffers();
-
- MapRequest_Buffers(const MapRequest_Buffers& from);
-
- inline MapRequest_Buffers& operator=(const MapRequest_Buffers& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const MapRequest_Buffers& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const MapRequest_Buffers* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(MapRequest_Buffers* other);
-
- // implements Message ----------------------------------------------
-
- MapRequest_Buffers* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const MapRequest_Buffers& from);
- void MergeFrom(const MapRequest_Buffers& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint32 len = 1;
- inline bool has_len() const;
- inline void clear_len();
- static const int kLenFieldNumber = 1;
- inline ::google::protobuf::uint32 len() const;
- inline void set_len(::google::protobuf::uint32 value);
-
- // required uint32 flags = 2;
- inline bool has_flags() const;
- inline void clear_flags();
- static const int kFlagsFieldNumber = 2;
- inline ::google::protobuf::uint32 flags() const;
- inline void set_flags(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.MapRequest.Buffers)
- private:
- inline void set_has_len();
- inline void clear_has_len();
- inline void set_has_flags();
- inline void clear_has_flags();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::uint32 len_;
- ::google::protobuf::uint32 flags_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static MapRequest_Buffers* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class MapRequest : public ::google::protobuf::MessageLite {
- public:
- MapRequest();
- virtual ~MapRequest();
-
- MapRequest(const MapRequest& from);
-
- inline MapRequest& operator=(const MapRequest& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const MapRequest& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const MapRequest* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(MapRequest* other);
-
- // implements Message ----------------------------------------------
-
- MapRequest* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const MapRequest& from);
- void MergeFrom(const MapRequest& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- typedef MapRequest_Buffers Buffers;
-
- // accessors -------------------------------------------------------
-
- // required uint32 sid = 1;
- inline bool has_sid() const;
- inline void clear_sid();
- static const int kSidFieldNumber = 1;
- inline ::google::protobuf::uint32 sid() const;
- inline void set_sid(::google::protobuf::uint32 value);
-
- // repeated .com.trustonic.tee_proxy.MapRequest.Buffers buffers = 2;
- inline int buffers_size() const;
- inline void clear_buffers();
- static const int kBuffersFieldNumber = 2;
- inline const ::com::trustonic::tee_proxy::MapRequest_Buffers& buffers(int index) const;
- inline ::com::trustonic::tee_proxy::MapRequest_Buffers* mutable_buffers(int index);
- inline ::com::trustonic::tee_proxy::MapRequest_Buffers* add_buffers();
- inline const ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::MapRequest_Buffers >&
- buffers() const;
- inline ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::MapRequest_Buffers >*
- mutable_buffers();
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.MapRequest)
- private:
- inline void set_has_sid();
- inline void clear_has_sid();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::MapRequest_Buffers > buffers_;
- ::google::protobuf::uint32 sid_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static MapRequest* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class MapResponse_Buffers : public ::google::protobuf::MessageLite {
- public:
- MapResponse_Buffers();
- virtual ~MapResponse_Buffers();
-
- MapResponse_Buffers(const MapResponse_Buffers& from);
-
- inline MapResponse_Buffers& operator=(const MapResponse_Buffers& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const MapResponse_Buffers& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const MapResponse_Buffers* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(MapResponse_Buffers* other);
-
- // implements Message ----------------------------------------------
-
- MapResponse_Buffers* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const MapResponse_Buffers& from);
- void MergeFrom(const MapResponse_Buffers& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint64 sva = 1;
- inline bool has_sva() const;
- inline void clear_sva();
- static const int kSvaFieldNumber = 1;
- inline ::google::protobuf::uint64 sva() const;
- inline void set_sva(::google::protobuf::uint64 value);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.MapResponse.Buffers)
- private:
- inline void set_has_sva();
- inline void clear_has_sva();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::uint64 sva_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static MapResponse_Buffers* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class MapResponse : public ::google::protobuf::MessageLite {
- public:
- MapResponse();
- virtual ~MapResponse();
-
- MapResponse(const MapResponse& from);
-
- inline MapResponse& operator=(const MapResponse& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const MapResponse& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const MapResponse* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(MapResponse* other);
-
- // implements Message ----------------------------------------------
-
- MapResponse* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const MapResponse& from);
- void MergeFrom(const MapResponse& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- typedef MapResponse_Buffers Buffers;
-
- // accessors -------------------------------------------------------
-
- // repeated .com.trustonic.tee_proxy.MapResponse.Buffers buffers = 1;
- inline int buffers_size() const;
- inline void clear_buffers();
- static const int kBuffersFieldNumber = 1;
- inline const ::com::trustonic::tee_proxy::MapResponse_Buffers& buffers(int index) const;
- inline ::com::trustonic::tee_proxy::MapResponse_Buffers* mutable_buffers(int index);
- inline ::com::trustonic::tee_proxy::MapResponse_Buffers* add_buffers();
- inline const ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::MapResponse_Buffers >&
- buffers() const;
- inline ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::MapResponse_Buffers >*
- mutable_buffers();
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.MapResponse)
- private:
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::MapResponse_Buffers > buffers_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static MapResponse* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class UnmapRequest_Buffers : public ::google::protobuf::MessageLite {
- public:
- UnmapRequest_Buffers();
- virtual ~UnmapRequest_Buffers();
-
- UnmapRequest_Buffers(const UnmapRequest_Buffers& from);
-
- inline UnmapRequest_Buffers& operator=(const UnmapRequest_Buffers& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const UnmapRequest_Buffers& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const UnmapRequest_Buffers* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(UnmapRequest_Buffers* other);
-
- // implements Message ----------------------------------------------
-
- UnmapRequest_Buffers* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const UnmapRequest_Buffers& from);
- void MergeFrom(const UnmapRequest_Buffers& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint64 sva = 1;
- inline bool has_sva() const;
- inline void clear_sva();
- static const int kSvaFieldNumber = 1;
- inline ::google::protobuf::uint64 sva() const;
- inline void set_sva(::google::protobuf::uint64 value);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.UnmapRequest.Buffers)
- private:
- inline void set_has_sva();
- inline void clear_has_sva();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::uint64 sva_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static UnmapRequest_Buffers* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class UnmapRequest : public ::google::protobuf::MessageLite {
- public:
- UnmapRequest();
- virtual ~UnmapRequest();
-
- UnmapRequest(const UnmapRequest& from);
-
- inline UnmapRequest& operator=(const UnmapRequest& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const UnmapRequest& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const UnmapRequest* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(UnmapRequest* other);
-
- // implements Message ----------------------------------------------
-
- UnmapRequest* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const UnmapRequest& from);
- void MergeFrom(const UnmapRequest& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- typedef UnmapRequest_Buffers Buffers;
-
- // accessors -------------------------------------------------------
-
- // required uint32 sid = 1;
- inline bool has_sid() const;
- inline void clear_sid();
- static const int kSidFieldNumber = 1;
- inline ::google::protobuf::uint32 sid() const;
- inline void set_sid(::google::protobuf::uint32 value);
-
- // repeated .com.trustonic.tee_proxy.UnmapRequest.Buffers buffers = 2;
- inline int buffers_size() const;
- inline void clear_buffers();
- static const int kBuffersFieldNumber = 2;
- inline const ::com::trustonic::tee_proxy::UnmapRequest_Buffers& buffers(int index) const;
- inline ::com::trustonic::tee_proxy::UnmapRequest_Buffers* mutable_buffers(int index);
- inline ::com::trustonic::tee_proxy::UnmapRequest_Buffers* add_buffers();
- inline const ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::UnmapRequest_Buffers >&
- buffers() const;
- inline ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::UnmapRequest_Buffers >*
- mutable_buffers();
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.UnmapRequest)
- private:
- inline void set_has_sid();
- inline void clear_has_sid();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::UnmapRequest_Buffers > buffers_;
- ::google::protobuf::uint32 sid_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static UnmapRequest* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class UnmapResponse : public ::google::protobuf::MessageLite {
- public:
- UnmapResponse();
- virtual ~UnmapResponse();
-
- UnmapResponse(const UnmapResponse& from);
-
- inline UnmapResponse& operator=(const UnmapResponse& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const UnmapResponse& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const UnmapResponse* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(UnmapResponse* other);
-
- // implements Message ----------------------------------------------
-
- UnmapResponse* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const UnmapResponse& from);
- void MergeFrom(const UnmapResponse& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.UnmapResponse)
- private:
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static UnmapResponse* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class GetErrorRequest : public ::google::protobuf::MessageLite {
- public:
- GetErrorRequest();
- virtual ~GetErrorRequest();
-
- GetErrorRequest(const GetErrorRequest& from);
-
- inline GetErrorRequest& operator=(const GetErrorRequest& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const GetErrorRequest& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const GetErrorRequest* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(GetErrorRequest* other);
-
- // implements Message ----------------------------------------------
-
- GetErrorRequest* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const GetErrorRequest& from);
- void MergeFrom(const GetErrorRequest& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint32 sid = 1;
- inline bool has_sid() const;
- inline void clear_sid();
- static const int kSidFieldNumber = 1;
- inline ::google::protobuf::uint32 sid() const;
- inline void set_sid(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.GetErrorRequest)
- private:
- inline void set_has_sid();
- inline void clear_has_sid();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::uint32 sid_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static GetErrorRequest* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class GetErrorResponse : public ::google::protobuf::MessageLite {
- public:
- GetErrorResponse();
- virtual ~GetErrorResponse();
-
- GetErrorResponse(const GetErrorResponse& from);
-
- inline GetErrorResponse& operator=(const GetErrorResponse& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const GetErrorResponse& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const GetErrorResponse* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(GetErrorResponse* other);
-
- // implements Message ----------------------------------------------
-
- GetErrorResponse* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const GetErrorResponse& from);
- void MergeFrom(const GetErrorResponse& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required sint32 exit_code = 1;
- inline bool has_exit_code() const;
- inline void clear_exit_code();
- static const int kExitCodeFieldNumber = 1;
- inline ::google::protobuf::int32 exit_code() const;
- inline void set_exit_code(::google::protobuf::int32 value);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.GetErrorResponse)
- private:
- inline void set_has_exit_code();
- inline void clear_has_exit_code();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::int32 exit_code_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static GetErrorResponse* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class GetVersionRequest : public ::google::protobuf::MessageLite {
- public:
- GetVersionRequest();
- virtual ~GetVersionRequest();
-
- GetVersionRequest(const GetVersionRequest& from);
-
- inline GetVersionRequest& operator=(const GetVersionRequest& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const GetVersionRequest& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const GetVersionRequest* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(GetVersionRequest* other);
-
- // implements Message ----------------------------------------------
-
- GetVersionRequest* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const GetVersionRequest& from);
- void MergeFrom(const GetVersionRequest& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.GetVersionRequest)
- private:
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static GetVersionRequest* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class GetVersionResponse : public ::google::protobuf::MessageLite {
- public:
- GetVersionResponse();
- virtual ~GetVersionResponse();
-
- GetVersionResponse(const GetVersionResponse& from);
-
- inline GetVersionResponse& operator=(const GetVersionResponse& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const GetVersionResponse& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const GetVersionResponse* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(GetVersionResponse* other);
-
- // implements Message ----------------------------------------------
-
- GetVersionResponse* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const GetVersionResponse& from);
- void MergeFrom(const GetVersionResponse& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required string product_id = 1;
- inline bool has_product_id() const;
- inline void clear_product_id();
- static const int kProductIdFieldNumber = 1;
- inline const ::std::string& product_id() const;
- inline void set_product_id(const ::std::string& value);
- inline void set_product_id(const char* value);
- inline void set_product_id(const char* value, size_t size);
- inline ::std::string* mutable_product_id();
- inline ::std::string* release_product_id();
- inline void set_allocated_product_id(::std::string* product_id);
-
- // required uint32 mci = 2;
- inline bool has_mci() const;
- inline void clear_mci();
- static const int kMciFieldNumber = 2;
- inline ::google::protobuf::uint32 mci() const;
- inline void set_mci(::google::protobuf::uint32 value);
-
- // required uint32 so = 3;
- inline bool has_so() const;
- inline void clear_so();
- static const int kSoFieldNumber = 3;
- inline ::google::protobuf::uint32 so() const;
- inline void set_so(::google::protobuf::uint32 value);
-
- // required uint32 mclf = 4;
- inline bool has_mclf() const;
- inline void clear_mclf();
- static const int kMclfFieldNumber = 4;
- inline ::google::protobuf::uint32 mclf() const;
- inline void set_mclf(::google::protobuf::uint32 value);
-
- // required uint32 container = 5;
- inline bool has_container() const;
- inline void clear_container();
- static const int kContainerFieldNumber = 5;
- inline ::google::protobuf::uint32 container() const;
- inline void set_container(::google::protobuf::uint32 value);
-
- // required uint32 mc_config = 6;
- inline bool has_mc_config() const;
- inline void clear_mc_config();
- static const int kMcConfigFieldNumber = 6;
- inline ::google::protobuf::uint32 mc_config() const;
- inline void set_mc_config(::google::protobuf::uint32 value);
-
- // required uint32 tl_api = 7;
- inline bool has_tl_api() const;
- inline void clear_tl_api();
- static const int kTlApiFieldNumber = 7;
- inline ::google::protobuf::uint32 tl_api() const;
- inline void set_tl_api(::google::protobuf::uint32 value);
-
- // required uint32 dr_api = 8;
- inline bool has_dr_api() const;
- inline void clear_dr_api();
- static const int kDrApiFieldNumber = 8;
- inline ::google::protobuf::uint32 dr_api() const;
- inline void set_dr_api(::google::protobuf::uint32 value);
-
- // required uint32 nwd = 9;
- inline bool has_nwd() const;
- inline void clear_nwd();
- static const int kNwdFieldNumber = 9;
- inline ::google::protobuf::uint32 nwd() const;
- inline void set_nwd(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.GetVersionResponse)
- private:
- inline void set_has_product_id();
- inline void clear_has_product_id();
- inline void set_has_mci();
- inline void clear_has_mci();
- inline void set_has_so();
- inline void clear_has_so();
- inline void set_has_mclf();
- inline void clear_has_mclf();
- inline void set_has_container();
- inline void clear_has_container();
- inline void set_has_mc_config();
- inline void clear_has_mc_config();
- inline void set_has_tl_api();
- inline void clear_has_tl_api();
- inline void set_has_dr_api();
- inline void clear_has_dr_api();
- inline void set_has_nwd();
- inline void clear_has_nwd();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::std::string* product_id_;
- ::google::protobuf::uint32 mci_;
- ::google::protobuf::uint32 so_;
- ::google::protobuf::uint32 mclf_;
- ::google::protobuf::uint32 container_;
- ::google::protobuf::uint32 mc_config_;
- ::google::protobuf::uint32 tl_api_;
- ::google::protobuf::uint32 dr_api_;
- ::google::protobuf::uint32 nwd_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static GetVersionResponse* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class GpRequestCancellationRequest : public ::google::protobuf::MessageLite {
- public:
- GpRequestCancellationRequest();
- virtual ~GpRequestCancellationRequest();
-
- GpRequestCancellationRequest(const GpRequestCancellationRequest& from);
-
- inline GpRequestCancellationRequest& operator=(const GpRequestCancellationRequest& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const GpRequestCancellationRequest& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const GpRequestCancellationRequest* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(GpRequestCancellationRequest* other);
-
- // implements Message ----------------------------------------------
-
- GpRequestCancellationRequest* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const GpRequestCancellationRequest& from);
- void MergeFrom(const GpRequestCancellationRequest& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required uint32 sid = 1;
- inline bool has_sid() const;
- inline void clear_sid();
- static const int kSidFieldNumber = 1;
- inline ::google::protobuf::uint32 sid() const;
- inline void set_sid(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.GpRequestCancellationRequest)
- private:
- inline void set_has_sid();
- inline void clear_has_sid();
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- ::google::protobuf::uint32 sid_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static GpRequestCancellationRequest* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class GpRequestCancellationResponse : public ::google::protobuf::MessageLite {
- public:
- GpRequestCancellationResponse();
- virtual ~GpRequestCancellationResponse();
-
- GpRequestCancellationResponse(const GpRequestCancellationResponse& from);
-
- inline GpRequestCancellationResponse& operator=(const GpRequestCancellationResponse& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::std::string& unknown_fields() const {
- return _unknown_fields_;
- }
-
- inline ::std::string* mutable_unknown_fields() {
- return &_unknown_fields_;
- }
-
- static const GpRequestCancellationResponse& default_instance();
-
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- // Returns the internal default instance pointer. This function can
- // return NULL thus should not be used by the user. This is intended
- // for Protobuf internal code. Please use default_instance() declared
- // above instead.
- static inline const GpRequestCancellationResponse* internal_default_instance() {
- return default_instance_;
- }
- #endif
-
- void Swap(GpRequestCancellationResponse* other);
-
- // implements Message ----------------------------------------------
-
- GpRequestCancellationResponse* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const GpRequestCancellationResponse& from);
- void MergeFrom(const GpRequestCancellationResponse& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- void DiscardUnknownFields();
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // @@protoc_insertion_point(class_scope:com.trustonic.tee_proxy.GpRequestCancellationResponse)
- private:
-
- ::std::string _unknown_fields_;
-
- ::google::protobuf::uint32 _has_bits_[1];
- mutable int _cached_size_;
- #ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
- friend void protobuf_AddDesc_mc_2eproto_impl();
- #else
- friend void protobuf_AddDesc_mc_2eproto();
- #endif
- friend void protobuf_AssignDesc_mc_2eproto();
- friend void protobuf_ShutdownFile_mc_2eproto();
-
- void InitAsDefaultInstance();
- static GpRequestCancellationResponse* default_instance_;
-};
-// ===================================================================
-
-
-// ===================================================================
-
-// OpenSessionRequest
-
-// required bytes uuid = 1;
-inline bool OpenSessionRequest::has_uuid() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void OpenSessionRequest::set_has_uuid() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void OpenSessionRequest::clear_has_uuid() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void OpenSessionRequest::clear_uuid() {
- if (uuid_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- uuid_->clear();
- }
- clear_has_uuid();
-}
-inline const ::std::string& OpenSessionRequest::uuid() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.OpenSessionRequest.uuid)
- return *uuid_;
-}
-inline void OpenSessionRequest::set_uuid(const ::std::string& value) {
- set_has_uuid();
- if (uuid_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- uuid_ = new ::std::string;
- }
- uuid_->assign(value);
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.OpenSessionRequest.uuid)
-}
-inline void OpenSessionRequest::set_uuid(const char* value) {
- set_has_uuid();
- if (uuid_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- uuid_ = new ::std::string;
- }
- uuid_->assign(value);
- // @@protoc_insertion_point(field_set_char:com.trustonic.tee_proxy.OpenSessionRequest.uuid)
-}
-inline void OpenSessionRequest::set_uuid(const void* value, size_t size) {
- set_has_uuid();
- if (uuid_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- uuid_ = new ::std::string;
- }
- uuid_->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:com.trustonic.tee_proxy.OpenSessionRequest.uuid)
-}
-inline ::std::string* OpenSessionRequest::mutable_uuid() {
- set_has_uuid();
- if (uuid_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- uuid_ = new ::std::string;
- }
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.OpenSessionRequest.uuid)
- return uuid_;
-}
-inline ::std::string* OpenSessionRequest::release_uuid() {
- clear_has_uuid();
- if (uuid_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- return NULL;
- } else {
- ::std::string* temp = uuid_;
- uuid_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- return temp;
- }
-}
-inline void OpenSessionRequest::set_allocated_uuid(::std::string* uuid) {
- if (uuid_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete uuid_;
- }
- if (uuid) {
- set_has_uuid();
- uuid_ = uuid;
- } else {
- clear_has_uuid();
- uuid_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- // @@protoc_insertion_point(field_set_allocated:com.trustonic.tee_proxy.OpenSessionRequest.uuid)
-}
-
-// required bool is_gp_uuid = 2;
-inline bool OpenSessionRequest::has_is_gp_uuid() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void OpenSessionRequest::set_has_is_gp_uuid() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void OpenSessionRequest::clear_has_is_gp_uuid() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void OpenSessionRequest::clear_is_gp_uuid() {
- is_gp_uuid_ = false;
- clear_has_is_gp_uuid();
-}
-inline bool OpenSessionRequest::is_gp_uuid() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.OpenSessionRequest.is_gp_uuid)
- return is_gp_uuid_;
-}
-inline void OpenSessionRequest::set_is_gp_uuid(bool value) {
- set_has_is_gp_uuid();
- is_gp_uuid_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.OpenSessionRequest.is_gp_uuid)
-}
-
-// optional bytes tci = 3;
-inline bool OpenSessionRequest::has_tci() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void OpenSessionRequest::set_has_tci() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void OpenSessionRequest::clear_has_tci() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void OpenSessionRequest::clear_tci() {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_->clear();
- }
- clear_has_tci();
-}
-inline const ::std::string& OpenSessionRequest::tci() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.OpenSessionRequest.tci)
- return *tci_;
-}
-inline void OpenSessionRequest::set_tci(const ::std::string& value) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(value);
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.OpenSessionRequest.tci)
-}
-inline void OpenSessionRequest::set_tci(const char* value) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(value);
- // @@protoc_insertion_point(field_set_char:com.trustonic.tee_proxy.OpenSessionRequest.tci)
-}
-inline void OpenSessionRequest::set_tci(const void* value, size_t size) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:com.trustonic.tee_proxy.OpenSessionRequest.tci)
-}
-inline ::std::string* OpenSessionRequest::mutable_tci() {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.OpenSessionRequest.tci)
- return tci_;
-}
-inline ::std::string* OpenSessionRequest::release_tci() {
- clear_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- return NULL;
- } else {
- ::std::string* temp = tci_;
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- return temp;
- }
-}
-inline void OpenSessionRequest::set_allocated_tci(::std::string* tci) {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete tci_;
- }
- if (tci) {
- set_has_tci();
- tci_ = tci;
- } else {
- clear_has_tci();
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- // @@protoc_insertion_point(field_set_allocated:com.trustonic.tee_proxy.OpenSessionRequest.tci)
-}
-
-// required .com.trustonic.tee_proxy.LoginType login_type = 4;
-inline bool OpenSessionRequest::has_login_type() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void OpenSessionRequest::set_has_login_type() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void OpenSessionRequest::clear_has_login_type() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void OpenSessionRequest::clear_login_type() {
- login_type_ = 0;
- clear_has_login_type();
-}
-inline ::com::trustonic::tee_proxy::LoginType OpenSessionRequest::login_type() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.OpenSessionRequest.login_type)
- return static_cast< ::com::trustonic::tee_proxy::LoginType >(login_type_);
-}
-inline void OpenSessionRequest::set_login_type(::com::trustonic::tee_proxy::LoginType value) {
- assert(::com::trustonic::tee_proxy::LoginType_IsValid(value));
- set_has_login_type();
- login_type_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.OpenSessionRequest.login_type)
-}
-
-// required bytes login_data = 5;
-inline bool OpenSessionRequest::has_login_data() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void OpenSessionRequest::set_has_login_data() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void OpenSessionRequest::clear_has_login_data() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void OpenSessionRequest::clear_login_data() {
- if (login_data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- login_data_->clear();
- }
- clear_has_login_data();
-}
-inline const ::std::string& OpenSessionRequest::login_data() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.OpenSessionRequest.login_data)
- return *login_data_;
-}
-inline void OpenSessionRequest::set_login_data(const ::std::string& value) {
- set_has_login_data();
- if (login_data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- login_data_ = new ::std::string;
- }
- login_data_->assign(value);
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.OpenSessionRequest.login_data)
-}
-inline void OpenSessionRequest::set_login_data(const char* value) {
- set_has_login_data();
- if (login_data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- login_data_ = new ::std::string;
- }
- login_data_->assign(value);
- // @@protoc_insertion_point(field_set_char:com.trustonic.tee_proxy.OpenSessionRequest.login_data)
-}
-inline void OpenSessionRequest::set_login_data(const void* value, size_t size) {
- set_has_login_data();
- if (login_data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- login_data_ = new ::std::string;
- }
- login_data_->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:com.trustonic.tee_proxy.OpenSessionRequest.login_data)
-}
-inline ::std::string* OpenSessionRequest::mutable_login_data() {
- set_has_login_data();
- if (login_data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- login_data_ = new ::std::string;
- }
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.OpenSessionRequest.login_data)
- return login_data_;
-}
-inline ::std::string* OpenSessionRequest::release_login_data() {
- clear_has_login_data();
- if (login_data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- return NULL;
- } else {
- ::std::string* temp = login_data_;
- login_data_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- return temp;
- }
-}
-inline void OpenSessionRequest::set_allocated_login_data(::std::string* login_data) {
- if (login_data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete login_data_;
- }
- if (login_data) {
- set_has_login_data();
- login_data_ = login_data;
- } else {
- clear_has_login_data();
- login_data_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- // @@protoc_insertion_point(field_set_allocated:com.trustonic.tee_proxy.OpenSessionRequest.login_data)
-}
-
-// -------------------------------------------------------------------
-
-// OpenSessionResponse
-
-// required uint32 id = 1;
-inline bool OpenSessionResponse::has_id() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void OpenSessionResponse::set_has_id() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void OpenSessionResponse::clear_has_id() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void OpenSessionResponse::clear_id() {
- id_ = 0u;
- clear_has_id();
-}
-inline ::google::protobuf::uint32 OpenSessionResponse::id() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.OpenSessionResponse.id)
- return id_;
-}
-inline void OpenSessionResponse::set_id(::google::protobuf::uint32 value) {
- set_has_id();
- id_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.OpenSessionResponse.id)
-}
-
-// -------------------------------------------------------------------
-
-// OpenTrustletRequest
-
-// required uint32 spid = 1;
-inline bool OpenTrustletRequest::has_spid() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void OpenTrustletRequest::set_has_spid() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void OpenTrustletRequest::clear_has_spid() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void OpenTrustletRequest::clear_spid() {
- spid_ = 0u;
- clear_has_spid();
-}
-inline ::google::protobuf::uint32 OpenTrustletRequest::spid() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.OpenTrustletRequest.spid)
- return spid_;
-}
-inline void OpenTrustletRequest::set_spid(::google::protobuf::uint32 value) {
- set_has_spid();
- spid_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.OpenTrustletRequest.spid)
-}
-
-// required bytes trustapp = 2;
-inline bool OpenTrustletRequest::has_trustapp() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void OpenTrustletRequest::set_has_trustapp() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void OpenTrustletRequest::clear_has_trustapp() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void OpenTrustletRequest::clear_trustapp() {
- if (trustapp_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- trustapp_->clear();
- }
- clear_has_trustapp();
-}
-inline const ::std::string& OpenTrustletRequest::trustapp() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.OpenTrustletRequest.trustapp)
- return *trustapp_;
-}
-inline void OpenTrustletRequest::set_trustapp(const ::std::string& value) {
- set_has_trustapp();
- if (trustapp_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- trustapp_ = new ::std::string;
- }
- trustapp_->assign(value);
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.OpenTrustletRequest.trustapp)
-}
-inline void OpenTrustletRequest::set_trustapp(const char* value) {
- set_has_trustapp();
- if (trustapp_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- trustapp_ = new ::std::string;
- }
- trustapp_->assign(value);
- // @@protoc_insertion_point(field_set_char:com.trustonic.tee_proxy.OpenTrustletRequest.trustapp)
-}
-inline void OpenTrustletRequest::set_trustapp(const void* value, size_t size) {
- set_has_trustapp();
- if (trustapp_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- trustapp_ = new ::std::string;
- }
- trustapp_->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:com.trustonic.tee_proxy.OpenTrustletRequest.trustapp)
-}
-inline ::std::string* OpenTrustletRequest::mutable_trustapp() {
- set_has_trustapp();
- if (trustapp_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- trustapp_ = new ::std::string;
- }
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.OpenTrustletRequest.trustapp)
- return trustapp_;
-}
-inline ::std::string* OpenTrustletRequest::release_trustapp() {
- clear_has_trustapp();
- if (trustapp_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- return NULL;
- } else {
- ::std::string* temp = trustapp_;
- trustapp_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- return temp;
- }
-}
-inline void OpenTrustletRequest::set_allocated_trustapp(::std::string* trustapp) {
- if (trustapp_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete trustapp_;
- }
- if (trustapp) {
- set_has_trustapp();
- trustapp_ = trustapp;
- } else {
- clear_has_trustapp();
- trustapp_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- // @@protoc_insertion_point(field_set_allocated:com.trustonic.tee_proxy.OpenTrustletRequest.trustapp)
-}
-
-// optional bytes tci = 3;
-inline bool OpenTrustletRequest::has_tci() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void OpenTrustletRequest::set_has_tci() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void OpenTrustletRequest::clear_has_tci() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void OpenTrustletRequest::clear_tci() {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_->clear();
- }
- clear_has_tci();
-}
-inline const ::std::string& OpenTrustletRequest::tci() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.OpenTrustletRequest.tci)
- return *tci_;
-}
-inline void OpenTrustletRequest::set_tci(const ::std::string& value) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(value);
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.OpenTrustletRequest.tci)
-}
-inline void OpenTrustletRequest::set_tci(const char* value) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(value);
- // @@protoc_insertion_point(field_set_char:com.trustonic.tee_proxy.OpenTrustletRequest.tci)
-}
-inline void OpenTrustletRequest::set_tci(const void* value, size_t size) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:com.trustonic.tee_proxy.OpenTrustletRequest.tci)
-}
-inline ::std::string* OpenTrustletRequest::mutable_tci() {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.OpenTrustletRequest.tci)
- return tci_;
-}
-inline ::std::string* OpenTrustletRequest::release_tci() {
- clear_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- return NULL;
- } else {
- ::std::string* temp = tci_;
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- return temp;
- }
-}
-inline void OpenTrustletRequest::set_allocated_tci(::std::string* tci) {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete tci_;
- }
- if (tci) {
- set_has_tci();
- tci_ = tci;
- } else {
- clear_has_tci();
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- // @@protoc_insertion_point(field_set_allocated:com.trustonic.tee_proxy.OpenTrustletRequest.tci)
-}
-
-// -------------------------------------------------------------------
-
-// OpenTrustletResponse
-
-// required uint32 id = 1;
-inline bool OpenTrustletResponse::has_id() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void OpenTrustletResponse::set_has_id() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void OpenTrustletResponse::clear_has_id() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void OpenTrustletResponse::clear_id() {
- id_ = 0u;
- clear_has_id();
-}
-inline ::google::protobuf::uint32 OpenTrustletResponse::id() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.OpenTrustletResponse.id)
- return id_;
-}
-inline void OpenTrustletResponse::set_id(::google::protobuf::uint32 value) {
- set_has_id();
- id_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.OpenTrustletResponse.id)
-}
-
-// -------------------------------------------------------------------
-
-// CloseSessionRequest
-
-// required uint32 id = 1;
-inline bool CloseSessionRequest::has_id() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void CloseSessionRequest::set_has_id() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void CloseSessionRequest::clear_has_id() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void CloseSessionRequest::clear_id() {
- id_ = 0u;
- clear_has_id();
-}
-inline ::google::protobuf::uint32 CloseSessionRequest::id() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.CloseSessionRequest.id)
- return id_;
-}
-inline void CloseSessionRequest::set_id(::google::protobuf::uint32 value) {
- set_has_id();
- id_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.CloseSessionRequest.id)
-}
-
-// -------------------------------------------------------------------
-
-// CloseSessionResponse
-
-// -------------------------------------------------------------------
-
-// NotifyRequest_Buffers
-
-// required uint64 sva = 1;
-inline bool NotifyRequest_Buffers::has_sva() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void NotifyRequest_Buffers::set_has_sva() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void NotifyRequest_Buffers::clear_has_sva() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void NotifyRequest_Buffers::clear_sva() {
- sva_ = GOOGLE_ULONGLONG(0);
- clear_has_sva();
-}
-inline ::google::protobuf::uint64 NotifyRequest_Buffers::sva() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.NotifyRequest.Buffers.sva)
- return sva_;
-}
-inline void NotifyRequest_Buffers::set_sva(::google::protobuf::uint64 value) {
- set_has_sva();
- sva_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.NotifyRequest.Buffers.sva)
-}
-
-// required bytes data = 2;
-inline bool NotifyRequest_Buffers::has_data() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void NotifyRequest_Buffers::set_has_data() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void NotifyRequest_Buffers::clear_has_data() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void NotifyRequest_Buffers::clear_data() {
- if (data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_->clear();
- }
- clear_has_data();
-}
-inline const ::std::string& NotifyRequest_Buffers::data() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.NotifyRequest.Buffers.data)
- return *data_;
-}
-inline void NotifyRequest_Buffers::set_data(const ::std::string& value) {
- set_has_data();
- if (data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_ = new ::std::string;
- }
- data_->assign(value);
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.NotifyRequest.Buffers.data)
-}
-inline void NotifyRequest_Buffers::set_data(const char* value) {
- set_has_data();
- if (data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_ = new ::std::string;
- }
- data_->assign(value);
- // @@protoc_insertion_point(field_set_char:com.trustonic.tee_proxy.NotifyRequest.Buffers.data)
-}
-inline void NotifyRequest_Buffers::set_data(const void* value, size_t size) {
- set_has_data();
- if (data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_ = new ::std::string;
- }
- data_->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:com.trustonic.tee_proxy.NotifyRequest.Buffers.data)
-}
-inline ::std::string* NotifyRequest_Buffers::mutable_data() {
- set_has_data();
- if (data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_ = new ::std::string;
- }
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.NotifyRequest.Buffers.data)
- return data_;
-}
-inline ::std::string* NotifyRequest_Buffers::release_data() {
- clear_has_data();
- if (data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- return NULL;
- } else {
- ::std::string* temp = data_;
- data_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- return temp;
- }
-}
-inline void NotifyRequest_Buffers::set_allocated_data(::std::string* data) {
- if (data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete data_;
- }
- if (data) {
- set_has_data();
- data_ = data;
- } else {
- clear_has_data();
- data_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- // @@protoc_insertion_point(field_set_allocated:com.trustonic.tee_proxy.NotifyRequest.Buffers.data)
-}
-
-// -------------------------------------------------------------------
-
-// NotifyRequest
-
-// required uint32 sid = 1;
-inline bool NotifyRequest::has_sid() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void NotifyRequest::set_has_sid() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void NotifyRequest::clear_has_sid() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void NotifyRequest::clear_sid() {
- sid_ = 0u;
- clear_has_sid();
-}
-inline ::google::protobuf::uint32 NotifyRequest::sid() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.NotifyRequest.sid)
- return sid_;
-}
-inline void NotifyRequest::set_sid(::google::protobuf::uint32 value) {
- set_has_sid();
- sid_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.NotifyRequest.sid)
-}
-
-// optional bytes tci = 2;
-inline bool NotifyRequest::has_tci() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void NotifyRequest::set_has_tci() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void NotifyRequest::clear_has_tci() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void NotifyRequest::clear_tci() {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_->clear();
- }
- clear_has_tci();
-}
-inline const ::std::string& NotifyRequest::tci() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.NotifyRequest.tci)
- return *tci_;
-}
-inline void NotifyRequest::set_tci(const ::std::string& value) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(value);
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.NotifyRequest.tci)
-}
-inline void NotifyRequest::set_tci(const char* value) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(value);
- // @@protoc_insertion_point(field_set_char:com.trustonic.tee_proxy.NotifyRequest.tci)
-}
-inline void NotifyRequest::set_tci(const void* value, size_t size) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:com.trustonic.tee_proxy.NotifyRequest.tci)
-}
-inline ::std::string* NotifyRequest::mutable_tci() {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.NotifyRequest.tci)
- return tci_;
-}
-inline ::std::string* NotifyRequest::release_tci() {
- clear_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- return NULL;
- } else {
- ::std::string* temp = tci_;
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- return temp;
- }
-}
-inline void NotifyRequest::set_allocated_tci(::std::string* tci) {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete tci_;
- }
- if (tci) {
- set_has_tci();
- tci_ = tci;
- } else {
- clear_has_tci();
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- // @@protoc_insertion_point(field_set_allocated:com.trustonic.tee_proxy.NotifyRequest.tci)
-}
-
-// repeated .com.trustonic.tee_proxy.NotifyRequest.Buffers buffers = 3;
-inline int NotifyRequest::buffers_size() const {
- return buffers_.size();
-}
-inline void NotifyRequest::clear_buffers() {
- buffers_.Clear();
-}
-inline const ::com::trustonic::tee_proxy::NotifyRequest_Buffers& NotifyRequest::buffers(int index) const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.NotifyRequest.buffers)
- return buffers_.Get(index);
-}
-inline ::com::trustonic::tee_proxy::NotifyRequest_Buffers* NotifyRequest::mutable_buffers(int index) {
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.NotifyRequest.buffers)
- return buffers_.Mutable(index);
-}
-inline ::com::trustonic::tee_proxy::NotifyRequest_Buffers* NotifyRequest::add_buffers() {
- // @@protoc_insertion_point(field_add:com.trustonic.tee_proxy.NotifyRequest.buffers)
- return buffers_.Add();
-}
-inline const ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::NotifyRequest_Buffers >&
-NotifyRequest::buffers() const {
- // @@protoc_insertion_point(field_list:com.trustonic.tee_proxy.NotifyRequest.buffers)
- return buffers_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::NotifyRequest_Buffers >*
-NotifyRequest::mutable_buffers() {
- // @@protoc_insertion_point(field_mutable_list:com.trustonic.tee_proxy.NotifyRequest.buffers)
- return &buffers_;
-}
-
-// -------------------------------------------------------------------
-
-// NotifyResponse
-
-// -------------------------------------------------------------------
-
-// WaitNotificationRequest
-
-// required uint32 sid = 1;
-inline bool WaitNotificationRequest::has_sid() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void WaitNotificationRequest::set_has_sid() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void WaitNotificationRequest::clear_has_sid() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void WaitNotificationRequest::clear_sid() {
- sid_ = 0u;
- clear_has_sid();
-}
-inline ::google::protobuf::uint32 WaitNotificationRequest::sid() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.WaitNotificationRequest.sid)
- return sid_;
-}
-inline void WaitNotificationRequest::set_sid(::google::protobuf::uint32 value) {
- set_has_sid();
- sid_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.WaitNotificationRequest.sid)
-}
-
-// required sint32 timeout = 2;
-inline bool WaitNotificationRequest::has_timeout() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void WaitNotificationRequest::set_has_timeout() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void WaitNotificationRequest::clear_has_timeout() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void WaitNotificationRequest::clear_timeout() {
- timeout_ = 0;
- clear_has_timeout();
-}
-inline ::google::protobuf::int32 WaitNotificationRequest::timeout() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.WaitNotificationRequest.timeout)
- return timeout_;
-}
-inline void WaitNotificationRequest::set_timeout(::google::protobuf::int32 value) {
- set_has_timeout();
- timeout_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.WaitNotificationRequest.timeout)
-}
-
-// required bool partial = 3;
-inline bool WaitNotificationRequest::has_partial() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void WaitNotificationRequest::set_has_partial() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void WaitNotificationRequest::clear_has_partial() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void WaitNotificationRequest::clear_partial() {
- partial_ = false;
- clear_has_partial();
-}
-inline bool WaitNotificationRequest::partial() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.WaitNotificationRequest.partial)
- return partial_;
-}
-inline void WaitNotificationRequest::set_partial(bool value) {
- set_has_partial();
- partial_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.WaitNotificationRequest.partial)
-}
-
-// -------------------------------------------------------------------
-
-// WaitNotificationResponse_Buffers
-
-// required uint64 sva = 1;
-inline bool WaitNotificationResponse_Buffers::has_sva() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void WaitNotificationResponse_Buffers::set_has_sva() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void WaitNotificationResponse_Buffers::clear_has_sva() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void WaitNotificationResponse_Buffers::clear_sva() {
- sva_ = GOOGLE_ULONGLONG(0);
- clear_has_sva();
-}
-inline ::google::protobuf::uint64 WaitNotificationResponse_Buffers::sva() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers.sva)
- return sva_;
-}
-inline void WaitNotificationResponse_Buffers::set_sva(::google::protobuf::uint64 value) {
- set_has_sva();
- sva_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers.sva)
-}
-
-// required bytes data = 2;
-inline bool WaitNotificationResponse_Buffers::has_data() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void WaitNotificationResponse_Buffers::set_has_data() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void WaitNotificationResponse_Buffers::clear_has_data() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void WaitNotificationResponse_Buffers::clear_data() {
- if (data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_->clear();
- }
- clear_has_data();
-}
-inline const ::std::string& WaitNotificationResponse_Buffers::data() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers.data)
- return *data_;
-}
-inline void WaitNotificationResponse_Buffers::set_data(const ::std::string& value) {
- set_has_data();
- if (data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_ = new ::std::string;
- }
- data_->assign(value);
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers.data)
-}
-inline void WaitNotificationResponse_Buffers::set_data(const char* value) {
- set_has_data();
- if (data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_ = new ::std::string;
- }
- data_->assign(value);
- // @@protoc_insertion_point(field_set_char:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers.data)
-}
-inline void WaitNotificationResponse_Buffers::set_data(const void* value, size_t size) {
- set_has_data();
- if (data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_ = new ::std::string;
- }
- data_->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers.data)
-}
-inline ::std::string* WaitNotificationResponse_Buffers::mutable_data() {
- set_has_data();
- if (data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- data_ = new ::std::string;
- }
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers.data)
- return data_;
-}
-inline ::std::string* WaitNotificationResponse_Buffers::release_data() {
- clear_has_data();
- if (data_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- return NULL;
- } else {
- ::std::string* temp = data_;
- data_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- return temp;
- }
-}
-inline void WaitNotificationResponse_Buffers::set_allocated_data(::std::string* data) {
- if (data_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete data_;
- }
- if (data) {
- set_has_data();
- data_ = data;
- } else {
- clear_has_data();
- data_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- // @@protoc_insertion_point(field_set_allocated:com.trustonic.tee_proxy.WaitNotificationResponse.Buffers.data)
-}
-
-// -------------------------------------------------------------------
-
-// WaitNotificationResponse
-
-// optional bytes tci = 1;
-inline bool WaitNotificationResponse::has_tci() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void WaitNotificationResponse::set_has_tci() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void WaitNotificationResponse::clear_has_tci() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void WaitNotificationResponse::clear_tci() {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_->clear();
- }
- clear_has_tci();
-}
-inline const ::std::string& WaitNotificationResponse::tci() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.WaitNotificationResponse.tci)
- return *tci_;
-}
-inline void WaitNotificationResponse::set_tci(const ::std::string& value) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(value);
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.WaitNotificationResponse.tci)
-}
-inline void WaitNotificationResponse::set_tci(const char* value) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(value);
- // @@protoc_insertion_point(field_set_char:com.trustonic.tee_proxy.WaitNotificationResponse.tci)
-}
-inline void WaitNotificationResponse::set_tci(const void* value, size_t size) {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- tci_->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:com.trustonic.tee_proxy.WaitNotificationResponse.tci)
-}
-inline ::std::string* WaitNotificationResponse::mutable_tci() {
- set_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- tci_ = new ::std::string;
- }
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.WaitNotificationResponse.tci)
- return tci_;
-}
-inline ::std::string* WaitNotificationResponse::release_tci() {
- clear_has_tci();
- if (tci_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- return NULL;
- } else {
- ::std::string* temp = tci_;
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- return temp;
- }
-}
-inline void WaitNotificationResponse::set_allocated_tci(::std::string* tci) {
- if (tci_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete tci_;
- }
- if (tci) {
- set_has_tci();
- tci_ = tci;
- } else {
- clear_has_tci();
- tci_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- // @@protoc_insertion_point(field_set_allocated:com.trustonic.tee_proxy.WaitNotificationResponse.tci)
-}
-
-// repeated .com.trustonic.tee_proxy.WaitNotificationResponse.Buffers buffers = 2;
-inline int WaitNotificationResponse::buffers_size() const {
- return buffers_.size();
-}
-inline void WaitNotificationResponse::clear_buffers() {
- buffers_.Clear();
-}
-inline const ::com::trustonic::tee_proxy::WaitNotificationResponse_Buffers& WaitNotificationResponse::buffers(int index) const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.WaitNotificationResponse.buffers)
- return buffers_.Get(index);
-}
-inline ::com::trustonic::tee_proxy::WaitNotificationResponse_Buffers* WaitNotificationResponse::mutable_buffers(int index) {
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.WaitNotificationResponse.buffers)
- return buffers_.Mutable(index);
-}
-inline ::com::trustonic::tee_proxy::WaitNotificationResponse_Buffers* WaitNotificationResponse::add_buffers() {
- // @@protoc_insertion_point(field_add:com.trustonic.tee_proxy.WaitNotificationResponse.buffers)
- return buffers_.Add();
-}
-inline const ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::WaitNotificationResponse_Buffers >&
-WaitNotificationResponse::buffers() const {
- // @@protoc_insertion_point(field_list:com.trustonic.tee_proxy.WaitNotificationResponse.buffers)
- return buffers_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::WaitNotificationResponse_Buffers >*
-WaitNotificationResponse::mutable_buffers() {
- // @@protoc_insertion_point(field_mutable_list:com.trustonic.tee_proxy.WaitNotificationResponse.buffers)
- return &buffers_;
-}
-
-// -------------------------------------------------------------------
-
-// MapRequest_Buffers
-
-// required uint32 len = 1;
-inline bool MapRequest_Buffers::has_len() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void MapRequest_Buffers::set_has_len() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void MapRequest_Buffers::clear_has_len() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void MapRequest_Buffers::clear_len() {
- len_ = 0u;
- clear_has_len();
-}
-inline ::google::protobuf::uint32 MapRequest_Buffers::len() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.MapRequest.Buffers.len)
- return len_;
-}
-inline void MapRequest_Buffers::set_len(::google::protobuf::uint32 value) {
- set_has_len();
- len_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.MapRequest.Buffers.len)
-}
-
-// required uint32 flags = 2;
-inline bool MapRequest_Buffers::has_flags() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void MapRequest_Buffers::set_has_flags() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void MapRequest_Buffers::clear_has_flags() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void MapRequest_Buffers::clear_flags() {
- flags_ = 0u;
- clear_has_flags();
-}
-inline ::google::protobuf::uint32 MapRequest_Buffers::flags() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.MapRequest.Buffers.flags)
- return flags_;
-}
-inline void MapRequest_Buffers::set_flags(::google::protobuf::uint32 value) {
- set_has_flags();
- flags_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.MapRequest.Buffers.flags)
-}
-
-// -------------------------------------------------------------------
-
-// MapRequest
-
-// required uint32 sid = 1;
-inline bool MapRequest::has_sid() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void MapRequest::set_has_sid() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void MapRequest::clear_has_sid() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void MapRequest::clear_sid() {
- sid_ = 0u;
- clear_has_sid();
-}
-inline ::google::protobuf::uint32 MapRequest::sid() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.MapRequest.sid)
- return sid_;
-}
-inline void MapRequest::set_sid(::google::protobuf::uint32 value) {
- set_has_sid();
- sid_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.MapRequest.sid)
-}
-
-// repeated .com.trustonic.tee_proxy.MapRequest.Buffers buffers = 2;
-inline int MapRequest::buffers_size() const {
- return buffers_.size();
-}
-inline void MapRequest::clear_buffers() {
- buffers_.Clear();
-}
-inline const ::com::trustonic::tee_proxy::MapRequest_Buffers& MapRequest::buffers(int index) const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.MapRequest.buffers)
- return buffers_.Get(index);
-}
-inline ::com::trustonic::tee_proxy::MapRequest_Buffers* MapRequest::mutable_buffers(int index) {
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.MapRequest.buffers)
- return buffers_.Mutable(index);
-}
-inline ::com::trustonic::tee_proxy::MapRequest_Buffers* MapRequest::add_buffers() {
- // @@protoc_insertion_point(field_add:com.trustonic.tee_proxy.MapRequest.buffers)
- return buffers_.Add();
-}
-inline const ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::MapRequest_Buffers >&
-MapRequest::buffers() const {
- // @@protoc_insertion_point(field_list:com.trustonic.tee_proxy.MapRequest.buffers)
- return buffers_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::MapRequest_Buffers >*
-MapRequest::mutable_buffers() {
- // @@protoc_insertion_point(field_mutable_list:com.trustonic.tee_proxy.MapRequest.buffers)
- return &buffers_;
-}
-
-// -------------------------------------------------------------------
-
-// MapResponse_Buffers
-
-// required uint64 sva = 1;
-inline bool MapResponse_Buffers::has_sva() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void MapResponse_Buffers::set_has_sva() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void MapResponse_Buffers::clear_has_sva() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void MapResponse_Buffers::clear_sva() {
- sva_ = GOOGLE_ULONGLONG(0);
- clear_has_sva();
-}
-inline ::google::protobuf::uint64 MapResponse_Buffers::sva() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.MapResponse.Buffers.sva)
- return sva_;
-}
-inline void MapResponse_Buffers::set_sva(::google::protobuf::uint64 value) {
- set_has_sva();
- sva_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.MapResponse.Buffers.sva)
-}
-
-// -------------------------------------------------------------------
-
-// MapResponse
-
-// repeated .com.trustonic.tee_proxy.MapResponse.Buffers buffers = 1;
-inline int MapResponse::buffers_size() const {
- return buffers_.size();
-}
-inline void MapResponse::clear_buffers() {
- buffers_.Clear();
-}
-inline const ::com::trustonic::tee_proxy::MapResponse_Buffers& MapResponse::buffers(int index) const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.MapResponse.buffers)
- return buffers_.Get(index);
-}
-inline ::com::trustonic::tee_proxy::MapResponse_Buffers* MapResponse::mutable_buffers(int index) {
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.MapResponse.buffers)
- return buffers_.Mutable(index);
-}
-inline ::com::trustonic::tee_proxy::MapResponse_Buffers* MapResponse::add_buffers() {
- // @@protoc_insertion_point(field_add:com.trustonic.tee_proxy.MapResponse.buffers)
- return buffers_.Add();
-}
-inline const ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::MapResponse_Buffers >&
-MapResponse::buffers() const {
- // @@protoc_insertion_point(field_list:com.trustonic.tee_proxy.MapResponse.buffers)
- return buffers_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::MapResponse_Buffers >*
-MapResponse::mutable_buffers() {
- // @@protoc_insertion_point(field_mutable_list:com.trustonic.tee_proxy.MapResponse.buffers)
- return &buffers_;
-}
-
-// -------------------------------------------------------------------
-
-// UnmapRequest_Buffers
-
-// required uint64 sva = 1;
-inline bool UnmapRequest_Buffers::has_sva() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void UnmapRequest_Buffers::set_has_sva() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void UnmapRequest_Buffers::clear_has_sva() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void UnmapRequest_Buffers::clear_sva() {
- sva_ = GOOGLE_ULONGLONG(0);
- clear_has_sva();
-}
-inline ::google::protobuf::uint64 UnmapRequest_Buffers::sva() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.UnmapRequest.Buffers.sva)
- return sva_;
-}
-inline void UnmapRequest_Buffers::set_sva(::google::protobuf::uint64 value) {
- set_has_sva();
- sva_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.UnmapRequest.Buffers.sva)
-}
-
-// -------------------------------------------------------------------
-
-// UnmapRequest
-
-// required uint32 sid = 1;
-inline bool UnmapRequest::has_sid() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void UnmapRequest::set_has_sid() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void UnmapRequest::clear_has_sid() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void UnmapRequest::clear_sid() {
- sid_ = 0u;
- clear_has_sid();
-}
-inline ::google::protobuf::uint32 UnmapRequest::sid() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.UnmapRequest.sid)
- return sid_;
-}
-inline void UnmapRequest::set_sid(::google::protobuf::uint32 value) {
- set_has_sid();
- sid_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.UnmapRequest.sid)
-}
-
-// repeated .com.trustonic.tee_proxy.UnmapRequest.Buffers buffers = 2;
-inline int UnmapRequest::buffers_size() const {
- return buffers_.size();
-}
-inline void UnmapRequest::clear_buffers() {
- buffers_.Clear();
-}
-inline const ::com::trustonic::tee_proxy::UnmapRequest_Buffers& UnmapRequest::buffers(int index) const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.UnmapRequest.buffers)
- return buffers_.Get(index);
-}
-inline ::com::trustonic::tee_proxy::UnmapRequest_Buffers* UnmapRequest::mutable_buffers(int index) {
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.UnmapRequest.buffers)
- return buffers_.Mutable(index);
-}
-inline ::com::trustonic::tee_proxy::UnmapRequest_Buffers* UnmapRequest::add_buffers() {
- // @@protoc_insertion_point(field_add:com.trustonic.tee_proxy.UnmapRequest.buffers)
- return buffers_.Add();
-}
-inline const ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::UnmapRequest_Buffers >&
-UnmapRequest::buffers() const {
- // @@protoc_insertion_point(field_list:com.trustonic.tee_proxy.UnmapRequest.buffers)
- return buffers_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::com::trustonic::tee_proxy::UnmapRequest_Buffers >*
-UnmapRequest::mutable_buffers() {
- // @@protoc_insertion_point(field_mutable_list:com.trustonic.tee_proxy.UnmapRequest.buffers)
- return &buffers_;
-}
-
-// -------------------------------------------------------------------
-
-// UnmapResponse
-
-// -------------------------------------------------------------------
-
-// GetErrorRequest
-
-// required uint32 sid = 1;
-inline bool GetErrorRequest::has_sid() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void GetErrorRequest::set_has_sid() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void GetErrorRequest::clear_has_sid() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void GetErrorRequest::clear_sid() {
- sid_ = 0u;
- clear_has_sid();
-}
-inline ::google::protobuf::uint32 GetErrorRequest::sid() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GetErrorRequest.sid)
- return sid_;
-}
-inline void GetErrorRequest::set_sid(::google::protobuf::uint32 value) {
- set_has_sid();
- sid_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GetErrorRequest.sid)
-}
-
-// -------------------------------------------------------------------
-
-// GetErrorResponse
-
-// required sint32 exit_code = 1;
-inline bool GetErrorResponse::has_exit_code() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void GetErrorResponse::set_has_exit_code() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void GetErrorResponse::clear_has_exit_code() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void GetErrorResponse::clear_exit_code() {
- exit_code_ = 0;
- clear_has_exit_code();
-}
-inline ::google::protobuf::int32 GetErrorResponse::exit_code() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GetErrorResponse.exit_code)
- return exit_code_;
-}
-inline void GetErrorResponse::set_exit_code(::google::protobuf::int32 value) {
- set_has_exit_code();
- exit_code_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GetErrorResponse.exit_code)
-}
-
-// -------------------------------------------------------------------
-
-// GetVersionRequest
-
-// -------------------------------------------------------------------
-
-// GetVersionResponse
-
-// required string product_id = 1;
-inline bool GetVersionResponse::has_product_id() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void GetVersionResponse::set_has_product_id() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void GetVersionResponse::clear_has_product_id() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void GetVersionResponse::clear_product_id() {
- if (product_id_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- product_id_->clear();
- }
- clear_has_product_id();
-}
-inline const ::std::string& GetVersionResponse::product_id() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GetVersionResponse.product_id)
- return *product_id_;
-}
-inline void GetVersionResponse::set_product_id(const ::std::string& value) {
- set_has_product_id();
- if (product_id_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- product_id_ = new ::std::string;
- }
- product_id_->assign(value);
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GetVersionResponse.product_id)
-}
-inline void GetVersionResponse::set_product_id(const char* value) {
- set_has_product_id();
- if (product_id_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- product_id_ = new ::std::string;
- }
- product_id_->assign(value);
- // @@protoc_insertion_point(field_set_char:com.trustonic.tee_proxy.GetVersionResponse.product_id)
-}
-inline void GetVersionResponse::set_product_id(const char* value, size_t size) {
- set_has_product_id();
- if (product_id_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- product_id_ = new ::std::string;
- }
- product_id_->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:com.trustonic.tee_proxy.GetVersionResponse.product_id)
-}
-inline ::std::string* GetVersionResponse::mutable_product_id() {
- set_has_product_id();
- if (product_id_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- product_id_ = new ::std::string;
- }
- // @@protoc_insertion_point(field_mutable:com.trustonic.tee_proxy.GetVersionResponse.product_id)
- return product_id_;
-}
-inline ::std::string* GetVersionResponse::release_product_id() {
- clear_has_product_id();
- if (product_id_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- return NULL;
- } else {
- ::std::string* temp = product_id_;
- product_id_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- return temp;
- }
-}
-inline void GetVersionResponse::set_allocated_product_id(::std::string* product_id) {
- if (product_id_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
- delete product_id_;
- }
- if (product_id) {
- set_has_product_id();
- product_id_ = product_id;
- } else {
- clear_has_product_id();
- product_id_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- // @@protoc_insertion_point(field_set_allocated:com.trustonic.tee_proxy.GetVersionResponse.product_id)
-}
-
-// required uint32 mci = 2;
-inline bool GetVersionResponse::has_mci() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void GetVersionResponse::set_has_mci() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void GetVersionResponse::clear_has_mci() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void GetVersionResponse::clear_mci() {
- mci_ = 0u;
- clear_has_mci();
-}
-inline ::google::protobuf::uint32 GetVersionResponse::mci() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GetVersionResponse.mci)
- return mci_;
-}
-inline void GetVersionResponse::set_mci(::google::protobuf::uint32 value) {
- set_has_mci();
- mci_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GetVersionResponse.mci)
-}
-
-// required uint32 so = 3;
-inline bool GetVersionResponse::has_so() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void GetVersionResponse::set_has_so() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void GetVersionResponse::clear_has_so() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void GetVersionResponse::clear_so() {
- so_ = 0u;
- clear_has_so();
-}
-inline ::google::protobuf::uint32 GetVersionResponse::so() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GetVersionResponse.so)
- return so_;
-}
-inline void GetVersionResponse::set_so(::google::protobuf::uint32 value) {
- set_has_so();
- so_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GetVersionResponse.so)
-}
-
-// required uint32 mclf = 4;
-inline bool GetVersionResponse::has_mclf() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void GetVersionResponse::set_has_mclf() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void GetVersionResponse::clear_has_mclf() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void GetVersionResponse::clear_mclf() {
- mclf_ = 0u;
- clear_has_mclf();
-}
-inline ::google::protobuf::uint32 GetVersionResponse::mclf() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GetVersionResponse.mclf)
- return mclf_;
-}
-inline void GetVersionResponse::set_mclf(::google::protobuf::uint32 value) {
- set_has_mclf();
- mclf_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GetVersionResponse.mclf)
-}
-
-// required uint32 container = 5;
-inline bool GetVersionResponse::has_container() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void GetVersionResponse::set_has_container() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void GetVersionResponse::clear_has_container() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void GetVersionResponse::clear_container() {
- container_ = 0u;
- clear_has_container();
-}
-inline ::google::protobuf::uint32 GetVersionResponse::container() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GetVersionResponse.container)
- return container_;
-}
-inline void GetVersionResponse::set_container(::google::protobuf::uint32 value) {
- set_has_container();
- container_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GetVersionResponse.container)
-}
-
-// required uint32 mc_config = 6;
-inline bool GetVersionResponse::has_mc_config() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void GetVersionResponse::set_has_mc_config() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void GetVersionResponse::clear_has_mc_config() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void GetVersionResponse::clear_mc_config() {
- mc_config_ = 0u;
- clear_has_mc_config();
-}
-inline ::google::protobuf::uint32 GetVersionResponse::mc_config() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GetVersionResponse.mc_config)
- return mc_config_;
-}
-inline void GetVersionResponse::set_mc_config(::google::protobuf::uint32 value) {
- set_has_mc_config();
- mc_config_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GetVersionResponse.mc_config)
-}
-
-// required uint32 tl_api = 7;
-inline bool GetVersionResponse::has_tl_api() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void GetVersionResponse::set_has_tl_api() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void GetVersionResponse::clear_has_tl_api() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void GetVersionResponse::clear_tl_api() {
- tl_api_ = 0u;
- clear_has_tl_api();
-}
-inline ::google::protobuf::uint32 GetVersionResponse::tl_api() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GetVersionResponse.tl_api)
- return tl_api_;
-}
-inline void GetVersionResponse::set_tl_api(::google::protobuf::uint32 value) {
- set_has_tl_api();
- tl_api_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GetVersionResponse.tl_api)
-}
-
-// required uint32 dr_api = 8;
-inline bool GetVersionResponse::has_dr_api() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void GetVersionResponse::set_has_dr_api() {
- _has_bits_[0] |= 0x00000080u;
-}
-inline void GetVersionResponse::clear_has_dr_api() {
- _has_bits_[0] &= ~0x00000080u;
-}
-inline void GetVersionResponse::clear_dr_api() {
- dr_api_ = 0u;
- clear_has_dr_api();
-}
-inline ::google::protobuf::uint32 GetVersionResponse::dr_api() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GetVersionResponse.dr_api)
- return dr_api_;
-}
-inline void GetVersionResponse::set_dr_api(::google::protobuf::uint32 value) {
- set_has_dr_api();
- dr_api_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GetVersionResponse.dr_api)
-}
-
-// required uint32 nwd = 9;
-inline bool GetVersionResponse::has_nwd() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-inline void GetVersionResponse::set_has_nwd() {
- _has_bits_[0] |= 0x00000100u;
-}
-inline void GetVersionResponse::clear_has_nwd() {
- _has_bits_[0] &= ~0x00000100u;
-}
-inline void GetVersionResponse::clear_nwd() {
- nwd_ = 0u;
- clear_has_nwd();
-}
-inline ::google::protobuf::uint32 GetVersionResponse::nwd() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GetVersionResponse.nwd)
- return nwd_;
-}
-inline void GetVersionResponse::set_nwd(::google::protobuf::uint32 value) {
- set_has_nwd();
- nwd_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GetVersionResponse.nwd)
-}
-
-// -------------------------------------------------------------------
-
-// GpRequestCancellationRequest
-
-// required uint32 sid = 1;
-inline bool GpRequestCancellationRequest::has_sid() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void GpRequestCancellationRequest::set_has_sid() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void GpRequestCancellationRequest::clear_has_sid() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void GpRequestCancellationRequest::clear_sid() {
- sid_ = 0u;
- clear_has_sid();
-}
-inline ::google::protobuf::uint32 GpRequestCancellationRequest::sid() const {
- // @@protoc_insertion_point(field_get:com.trustonic.tee_proxy.GpRequestCancellationRequest.sid)
- return sid_;
-}
-inline void GpRequestCancellationRequest::set_sid(::google::protobuf::uint32 value) {
- set_has_sid();
- sid_ = value;
- // @@protoc_insertion_point(field_set:com.trustonic.tee_proxy.GpRequestCancellationRequest.sid)
-}
-
-// -------------------------------------------------------------------
-
-// GpRequestCancellationResponse
-
-
-// @@protoc_insertion_point(namespace_scope)
-
-} // namespace tee_proxy
-} // namespace trustonic
-} // namespace com
-
-// @@protoc_insertion_point(global_scope)
-
-#endif // PROTOBUF_mc_2eproto__INCLUDED
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <pthread.h>
-#include <stdbool.h>
-
-#undef LOG_TAG
-#define LOG_TAG "TeeMcClient"
-#include "log.h"
-#include "MobiCoreDriverApi.h"
-#include "common_client.h"
-#include "buildTag.h"
-
-static const __attribute__((used)) char* buildtag =
- MOBICORE_COMPONENT_BUILD_TAG;
-
-//------------------------------------------------------------------------------
-
-/*
- * On mcCloseDevice(), all mappings need to be removed, which means we need to
- * keep them somewhere. We keep them in an array, resized when needed.
- * Both map and length must be kept in user-space, as after a fork another
- * mapping with same address may have appeared from the other process(es).
- */
-struct maplen {
- uint8_t* wsm;
- uint32_t len;
-};
-
-static struct maplen* wsms;
-static size_t wsms_capacity, wsms_length;
-static pthread_mutex_t wsms_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static CommonClient& client = CommonClient::getInstance();
-
-static inline int wsms_add(uint8_t* wsm, uint32_t len) {
- int ret = 0;
- pthread_mutex_lock(&wsms_mutex);
- if (wsms_length == wsms_capacity) {
- size_t new_wsms_capacity = wsms_capacity;
- /* Need some room */
- if (new_wsms_capacity == 0) {
- new_wsms_capacity = 16;
- } else {
- new_wsms_capacity *= 2;
- }
- struct maplen* new_wsms = static_cast<struct maplen*>(realloc(wsms,
- new_wsms_capacity * sizeof(*wsms)));
- if (!new_wsms) {
- LOG_ERRNO("resize WSMs array");
- ret = -1;
- } else {
- wsms = new_wsms;
- wsms_capacity = new_wsms_capacity;
- }
- }
- if (ret == 0) {
- wsms[wsms_length].wsm = wsm;
- wsms[wsms_length].len = len;
- wsms_length++;
- LOG_D("add %p %d", wsm, len);
- }
- pthread_mutex_unlock(&wsms_mutex);
- return ret;
-}
-
-static inline int wsms_remove(uint8_t* wsm) {
- int ret = 0;
- pthread_mutex_lock(&wsms_mutex);
- /* Find position of WSM */
- size_t i;
- for (i = 0; i < wsms_length; i++) {
- if (wsms[i].wsm == wsm) {
- break;
- }
- }
- if (i == wsms_length) {
- LOG_E("WSM %p not found in array", wsm);
- ret = -1;
- } else {
- /* Replace WSM with last so the first free element remains wsms[wsms_length] */
- wsms[i] = wsms[--wsms_length];
- LOG_D("rm %p", wsm);
- }
- pthread_mutex_unlock(&wsms_mutex);
- return ret;
-}
-
-static inline int wsms_len(uint8_t* wsm) {
- int len = -1;
- pthread_mutex_lock(&wsms_mutex);
- for (size_t i = 0; i < wsms_length; i++) {
- if (wsms[i].wsm == wsm) {
- len = wsms[i].len;
- LOG_D("rm len %p %d", wsm, len);
- break;
- }
- }
- pthread_mutex_unlock(&wsms_mutex);
- return len;
-}
-
-static inline struct maplen wsms_getLast(void) {
- struct maplen wsm;
- pthread_mutex_lock(&wsms_mutex);
- if (wsms_length > 0) {
- wsm = wsms[wsms_length - 1];
- LOG_D("rm last %p", wsm.wsm);
- } else {
- wsm.wsm = NULL;
- // To make Coverity happy
- wsm.len = 0;
- }
- pthread_mutex_unlock(&wsms_mutex);
- return wsm;
-}
-
-/* Only 1 device is supported */
-static inline bool isValidDevice(uint32_t deviceId) {
- return (MC_DEVICE_ID_DEFAULT == deviceId);
-}
-
-/* Convert driver errors into tbase set */
-static mcResult_t convert_syscall_error(int32_t ret) {
- switch (ret) {
- case 0:
- return MC_DRV_OK;
- case -1:
- switch (errno) {
- case ENOMSG:
- return MC_DRV_NO_NOTIFICATION;
- case EBADMSG:
- return MC_DRV_ERR_NOTIFICATION;
- case ENOSPC:
- return MC_DRV_ERR_OUT_OF_RESOURCES;
- case EHOSTDOWN:
- return MC_DRV_ERR_INIT;
- case ENODEV:
- return MC_DRV_ERR_UNKNOWN_DEVICE;
- case ENXIO:
- return MC_DRV_ERR_UNKNOWN_SESSION;
- case EPERM:
- return MC_DRV_ERR_INVALID_OPERATION;
- case EBADE:
- return MC_DRV_ERR_INVALID_RESPONSE;
- case ETIME:
- return MC_DRV_ERR_TIMEOUT;
- case ENOMEM:
- return MC_DRV_ERR_NO_FREE_MEMORY;
- case EUCLEAN:
- return MC_DRV_ERR_FREE_MEMORY_FAILED;
- case ENOTEMPTY:
- return MC_DRV_ERR_SESSION_PENDING;
- case EHOSTUNREACH:
- return MC_DRV_ERR_DAEMON_UNREACHABLE;
- case ENOENT:
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- case EINVAL:
- return MC_DRV_ERR_INVALID_PARAMETER;
- case EPROTO:
- return MC_DRV_ERR_KERNEL_MODULE;
- case EADDRINUSE:
- return MC_DRV_ERR_BULK_MAPPING;
- case EADDRNOTAVAIL:
- return MC_DRV_ERR_BULK_UNMAPPING;
- case ECOMM:
- return MC_DRV_INFO_NOTIFICATION;
- case EUNATCH:
- return MC_DRV_ERR_NQ_FAILED;
- case EBADF:
- return MC_DRV_ERR_DAEMON_DEVICE_NOT_OPEN;
- case EINTR:
- return MC_DRV_ERR_INTERRUPTED_BY_SIGNAL;
- case EKEYREJECTED:
- return MC_DRV_ERR_WRONG_PUBLIC_KEY;
- case ECONNREFUSED:
- return MC_DRV_ERR_SERVICE_BLOCKED;
- case ECONNABORTED:
- return MC_DRV_ERR_SERVICE_LOCKED;
- case ECONNRESET:
- return MC_DRV_ERR_SERVICE_KILLED;
- default:
- LOG_ERRNO("syscall");
- return MC_DRV_ERR_UNKNOWN;
- }
- default:
- LOG_E("Unknown code %d", ret);
- return MC_DRV_ERR_UNKNOWN;
- }
-}
-
-//------------------------------------------------------------------------------
-// CLIENT API
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcOpenDevice(
- uint32_t deviceId
-) {
- LOG_D("===%s(%i)===", __FUNCTION__, deviceId);
-
- // Check parameters
- if (!isValidDevice(deviceId) &&
- (deviceId != CommonClient::DRIVER) &&
- (deviceId != CommonClient::PROXY)) {
- return MC_DRV_ERR_UNKNOWN_DEVICE;
- }
-
- // For test purpose
- switch (deviceId) {
- case CommonClient::DRIVER:
- client.setOpenMode(CommonClient::DRIVER);
- break;
- case CommonClient::PROXY:
- client.setOpenMode(CommonClient::PROXY);
- break;
- }
-
- if (client.open()) {
- return convert_syscall_error(-1);
- }
-
- return MC_DRV_OK;
-}
-
-
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcCloseDevice(
- uint32_t deviceId
-) {
- LOG_D("===%s(%i)===", __FUNCTION__, deviceId);
-
- // Check parameters
- if (!isValidDevice(deviceId)) {
- return MC_DRV_ERR_UNKNOWN_DEVICE;
- }
-
- // Check whether there are still some 'devices open'
- if (client.closeCheck() == 0) {
- return MC_DRV_OK;
- }
-
- // Check that all sessions are closed for client
- mcResult_t mcResult = convert_syscall_error(client.hasOpenSessions());
- if (mcResult != MC_DRV_OK) {
- return mcResult;
- }
-
- // Free all remaining WSMs
- while (true) {
- struct maplen wsm = wsms_getLast();
- if (wsm.wsm == NULL) {
- break;
- }
- mcFreeWsm(deviceId, wsm.wsm);
- }
-
- // Close the device
- client.close();
- return MC_DRV_OK;
-}
-
-
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcOpenSession(
- mcSessionHandle_t* session,
- const mcUuid_t* uuid,
- uint8_t* tci,
- uint32_t len
-) {
- mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
- struct mc_ioctl_open_session sess;
- int ret;
-
- LOG_D("===%s()===", __FUNCTION__);
-
- do {
- // Check parameters
- if (!session) {
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
- if (!isValidDevice(session->deviceId)) {
- mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
- break;
- }
- if (!uuid) {
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
-
- // Call ioctl
- sess.sid = 0;
- memcpy( (void*)&sess.uuid, uuid, sizeof(sess.uuid) );
- sess.tci = (uintptr_t)tci;
- sess.tcilen = len;
- sess.is_gp_uuid = false;
- sess.identity.login_type = LOGIN_PUBLIC;
- sess.identity.pid = 0;
- ret = client.openSession(sess);
- mcResult = convert_syscall_error(ret);
- if (MC_DRV_OK != mcResult) {
- break;
- }
-
- // Fill in return parameters
- session->sessionId = sess.sid;
- } while (false);
-
- /* Legacy error matching */
- if (MC_DRV_OK != mcResult) {
- if (MC_DRV_ERR_UNKNOWN == mcResult) {
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- }
-
- LOG_E("return 0x%x", mcResult);
- }
-
- return mcResult;
-}
-
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcOpenTrustlet(
- mcSessionHandle_t* session,
- mcSpid_t spid,
- uint8_t* trustlet,
- uint32_t tLen,
- uint8_t* tci,
- uint32_t tciLen
-) {
- mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
- struct mc_ioctl_open_trustlet trus;
- int ret;
-
- LOG_D("===%s()===", __FUNCTION__);
-
- do {
- // Check parameters
- if (!session) {
- LOG_E("Session handle is null");
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
- if (!isValidDevice(session->deviceId)) {
- mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
- break;
- }
-
- // Call ioctl
- trus.sid = 0;
- trus.spid = spid;
- trus.buffer = (uintptr_t)trustlet;
- trus.tlen = tLen;
- trus.tci = (uintptr_t)tci;
- trus.tcilen = tciLen;
- ret = client.openTrustlet(trus);
- mcResult = convert_syscall_error(ret);
-
- // Fill in return parameters
- if (MC_DRV_OK == mcResult) {
- session->sessionId = trus.sid;
- }
-
- } while (false);
-
- /* Legacy error matching */
- if (MC_DRV_OK != mcResult) {
- if (MC_DRV_ERR_UNKNOWN == mcResult) {
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- }
-
- LOG_E("return 0x%x", mcResult);
- }
-
- return mcResult;
-}
-
-
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcCloseSession(
- mcSessionHandle_t* session
-) {
- mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
- int ret;
-
- LOG_D("===%s()===", __FUNCTION__);
-
- do {
- // Check parameters
- if (!session) {
- LOG_E("Session handle is null");
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
- if (!isValidDevice(session->deviceId)) {
- mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
- break;
- }
-
- // Call ioctl
- ret = client.closeSession(session->sessionId);
- mcResult = convert_syscall_error(ret);
-
- } while (false);
-
- return mcResult;
-}
-
-
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcNotify(
- mcSessionHandle_t* session
-) {
- mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
- int ret;
-
- LOG_D("===%s()===", __FUNCTION__);
-
- do {
- // Check parameters
- if (!session) {
- LOG_E("Session handle is null");
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
- if (!isValidDevice(session->deviceId)) {
- mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
- break;
- }
-
- // Call ioctl
- ret = client.notify(session->sessionId);
- mcResult = convert_syscall_error(ret);
-
- } while (false);
-
- return mcResult;
-}
-
-
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcWaitNotification(
- mcSessionHandle_t* session,
- int32_t timeout
-) {
- mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
- struct mc_ioctl_wait wait;
- int ret;
-
- LOG_D("===%s()===", __FUNCTION__);
-
- do {
- // Check parameters
- if (!session) {
- LOG_E("Session handle is null");
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
- if (!isValidDevice(session->deviceId)) {
- mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
- break;
- }
-
- // Call ioctl
- wait.sid = session->sessionId;
- wait.timeout = timeout;
- do {
- ret = client.waitNotification(wait);
- mcResult = convert_syscall_error(ret);
- } while (MC_INFINITE_TIMEOUT == timeout &&
- MC_DRV_ERR_INTERRUPTED_BY_SIGNAL == mcResult);
-
- } while (false);
-
- return mcResult;
-}
-
-
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcMallocWsm(
- uint32_t deviceId,
- uint32_t align,
- uint32_t len,
- uint8_t** wsm,
- uint32_t wsmFlags
-) {
- (void) align;
- (void) wsmFlags;
- mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
- LOG_D("===%s(len=%i)===", __FUNCTION__, len);
-
- do {
- // Check parameters
- if (!isValidDevice(deviceId)) {
- mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
- break;
- }
- if (!client.isOpen()) {
- LOG_E("Client not open");
- mcResult = MC_DRV_ERR_DAEMON_DEVICE_NOT_OPEN;
- break;
- }
- if (!wsm) {
- LOG_E("Wsm pointer is null");
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
- // Alloc and map kernel buffer into user space
- if (client.malloc(wsm, len)) {
- mcResult = convert_syscall_error(-1);
- break;
- }
- wsms_add(*wsm, len);
- mcResult = MC_DRV_OK;
-
- } while (false);
-
- return mcResult;
-}
-
-
-//------------------------------------------------------------------------------
-// Note: mcFreeWsm() only succeeds if wsm is as returned by mcMallocWsm().
-__MC_CLIENT_LIB_API mcResult_t mcFreeWsm(
- uint32_t deviceId,
- uint8_t* wsm
-) {
- mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
-
- LOG_D("===%s(%p)===", __FUNCTION__, wsm);
-
- do {
- // Check parameters
- if (!isValidDevice(deviceId)) {
- mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
- break;
- }
- if (!client.isOpen()) {
- LOG_E("Client not open");
- mcResult = MC_DRV_ERR_DAEMON_DEVICE_NOT_OPEN;
- break;
- }
- // Get mapping length
- int len = wsms_len(wsm);
- if (len == -1) {
- LOG_E("wsm %p buffer not available", wsm);
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- } else {
- // Unmap and free kernel buffer
- int ret = client.free(wsm, len);
- mcResult = convert_syscall_error(ret);
- if (ret == 0) {
- wsms_remove(wsm);
- }
- }
- } while (false);
-
- return mcResult;
-}
-
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcMap(
- mcSessionHandle_t* session,
- void* buf,
- uint32_t bufLen,
- mcBulkMap_t* mapInfo
-) {
- mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
- struct mc_ioctl_map map;
- int ret;
-
- LOG_D("===%s()===", __FUNCTION__);
-
- do {
- // Check parameters
- if (!session) {
- LOG_E("Session handle is null");
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
- if (!isValidDevice(session->deviceId)) {
- mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
- break;
- }
- if (!mapInfo) {
- LOG_E("mapInfo pointer is null");
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
-
- // Call ioctl
- map.sid = session->sessionId;
- map.bufs[0].va = (uintptr_t)buf;
- map.bufs[0].len = bufLen;
- map.bufs[0].flags = MC_IO_MAP_INPUT_OUTPUT;
- LOG_D("map va=%llx len=%u", map.bufs[0].va, map.bufs[0].len);
- for (int i = 1; i < MC_MAP_MAX; i++) {
- map.bufs[i].va = 0;
- }
- ret = client.map(map);
- mcResult = convert_syscall_error(ret);
- if (MC_DRV_OK != mcResult) {
- break;
- }
- LOG_D("map'd va=%llx len=%u sva=%llx",
- map.bufs[0].va, map.bufs[0].len, map.bufs[0].sva);
-
- // Fill in return parameters
-#if ( __WORDSIZE != 64 )
- mapInfo->sVirtualAddr = (void*)(uintptr_t)map.bufs[0].sva;
-#else
- mapInfo->sVirtualAddr = (uint32_t)map.bufs[0].sva;
-#endif
- mapInfo->sVirtualLen = map.bufs[0].len;
- } while (false);
-
- /* Legacy error matching */
- if (MC_DRV_OK != mcResult) {
- if (MC_DRV_ERR_UNKNOWN == mcResult) {
- mcResult = MC_DRV_ERR_BULK_MAPPING;
- }
-
- LOG_E("return 0x%x", mcResult);
- }
-
- return mcResult;
-}
-
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcUnmap(
- mcSessionHandle_t* session,
- void* buf,
- mcBulkMap_t* mapInfo
-) {
- mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
- struct mc_ioctl_map map;
- int ret;
-
- LOG_D("===%s()===", __FUNCTION__);
-
- do {
- // Check parameters
- if (!session) {
- LOG_E("Session handle is null");
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
- if (!isValidDevice(session->deviceId)) {
- mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
- break;
- }
- if (!mapInfo) {
- LOG_E("mapInfo pointer is null");
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
-
- // Call ioctl
- map.sid = session->sessionId;
- map.bufs[0].va = (uintptr_t)buf;
- map.bufs[0].sva = (uintptr_t)mapInfo->sVirtualAddr;
- map.bufs[0].len = mapInfo->sVirtualLen;
- LOG_D("unmap va=%llx len=%u sva=%llx",
- map.bufs[0].va, map.bufs[0].len, map.bufs[0].sva);
- for (int i = 1; i < MC_MAP_MAX; i++) {
- map.bufs[i].va = 0;
- }
- ret = client.unmap(map);
- mcResult = convert_syscall_error(ret);
-
- } while (false);
-
- if (MC_DRV_OK != mcResult) {
- if (MC_DRV_ERR_UNKNOWN == mcResult) {
- mcResult = MC_DRV_ERR_BULK_UNMAPPING;
- }
-
- LOG_E("return 0x%x", mcResult);
- }
-
- return mcResult;
-}
-
-
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcGetSessionErrorCode(
- mcSessionHandle_t* session,
- int32_t* lastErr
-) {
- mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
- struct mc_ioctl_geterr err;
- int ret;
-
- LOG_D("===%s()===", __FUNCTION__);
-
- do {
- // Check parameters
- if (!session) {
- LOG_E("Session handle is null");
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
- if (!isValidDevice(session->deviceId)) {
- mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
- break;
- }
- if (!lastErr) {
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
-
- // Call ioctl
- err.sid = session->sessionId;
- ret = client.getError(err);
- mcResult = convert_syscall_error(ret);
- if (MC_DRV_OK != mcResult) {
- break;
- }
-
- // Fill in return parameters
- *lastErr = err.value;
-
- } while (false);
-
- return mcResult;
-}
-
-//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcGetMobiCoreVersion(
- uint32_t deviceId,
- mcVersionInfo_t* versionInfo
-) {
- mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
- int ret;
-
- LOG_D("===%s()===", __FUNCTION__);
-
- do {
- // Check parameters
- if (!isValidDevice(deviceId)) {
- mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
- break;
- }
- if (!versionInfo) {
- LOG_E("versionInfo pointer is null");
- mcResult = MC_DRV_ERR_INVALID_PARAMETER;
- break;
- }
-
- struct mc_version_info version_info;
- ret = client.getVersion(version_info);
- if (!ret) {
- memcpy(versionInfo, &version_info, sizeof(*versionInfo));
- }
- mcResult = convert_syscall_error(ret);
- } while (false);
-
- return mcResult;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _MC_USER_H_
-#define _MC_USER_H_
-
-#define MCDRVMODULEAPI_VERSION_MAJOR 2
-#define MCDRVMODULEAPI_VERSION_MINOR 10
-
-#include <linux/types.h>
-
-#define MC_USER_DEVNODE "mobicore-user"
-
-/** Maximum length of MobiCore product ID string. */
-#define MC_PRODUCT_ID_LEN 64
-
-/** Number of buffers that can be mapped at once */
-#define MC_MAP_MAX 4
-
-/** Max length for buffers */
-#define BUFFER_LENGTH_MAX 0x100000
-
-/** Flags for buffers to map (aligned on GP) */
-#define MC_IO_MAP_INPUT 0x1
-#define MC_IO_MAP_OUTPUT 0x2
-#define MC_IO_MAP_INPUT_OUTPUT (MC_IO_MAP_INPUT | MC_IO_MAP_OUTPUT)
-
-/*
- * Universally Unique Identifier (UUID) according to ISO/IEC 11578.
- */
-struct mc_uuid_t {
- __u8 value[16]; /* Value of the UUID. */
-};
-
-/*
- * GP TA login types.
- */
-enum mc_login_type {
- LOGIN_PUBLIC = 0,
- LOGIN_USER,
- LOGIN_GROUP,
- LOGIN_APPLICATION = 4,
- LOGIN_USER_APPLICATION,
- LOGIN_GROUP_APPLICATION,
-};
-
-/*
- * GP TA identity structure.
- */
-struct mc_identity {
- enum mc_login_type login_type;
- union {
- __u8 login_data[16];
- gid_t gid; /* Requested group id */
- struct {
- uid_t euid;
- uid_t ruid;
- } uid;
- };
- pid_t pid; /* Client, when using proxy */
-};
-
-/*
- * Data exchange structure of the MC_IO_OPEN_SESSION ioctl command.
- */
-struct mc_ioctl_open_session {
- struct mc_uuid_t uuid; /* trustlet uuid */
- __u32 is_gp_uuid; /* uuid is for GP TA */
- __u32 sid; /* session id (out) */
- __u64 tci; /* tci buffer pointer */
- __u32 tcilen; /* tci length */
- struct mc_identity identity; /* GP TA identity */
-};
-
-/*
- * Data exchange structure of the MC_IO_OPEN_TRUSTLET ioctl command.
- */
-struct mc_ioctl_open_trustlet {
- __u32 sid; /* session id (out) */
- __u32 spid; /* trustlet spid */
- __u64 buffer; /* trustlet binary pointer */
- __u32 tlen; /* binary length */
- __u64 tci; /* tci buffer pointer */
- __u32 tcilen; /* tci length */
-};
-
-/*
- * Data exchange structure of the MC_IO_WAIT ioctl command.
- */
-struct mc_ioctl_wait {
- __u32 sid; /* session id (in) */
- __s32 timeout; /* notification timeout */
- __u32 partial; /* for proxy server to retry silently */
-};
-
-/*
- * Data exchange structure of the MC_IO_ALLOC ioctl command.
- */
-struct mc_ioctl_alloc {
- __u32 len; /* buffer length */
- __u32 handle; /* user handle for the buffer (out) */
-};
-
-/*
- * Buffer mapping incoming and outgoing information.
- */
-struct mc_ioctl_buffer {
- __u64 va; /* user space address of buffer */
- __u32 len; /* buffer length */
- __u64 sva; /* SWd virt address of buffer (out) */
- __u32 flags; /* buffer flags */
-};
-
-/*
- * Data exchange structure of the MC_IO_MAP and MC_IO_UNMAP ioctl commands.
- */
-struct mc_ioctl_map {
- __u32 sid; /* session id */
- struct mc_ioctl_buffer bufs[MC_MAP_MAX]; /* buffers info */
-};
-
-/*
- * Data exchange structure of the MC_IO_ERR ioctl command.
- */
-struct mc_ioctl_geterr {
- __u32 sid; /* session id */
- __s32 value; /* error value (out) */
-};
-
-/*
- * Global MobiCore Version Information.
- */
-struct mc_version_info {
- char product_id[MC_PRODUCT_ID_LEN]; /** Product ID string */
- __u32 version_mci; /** Mobicore Control Interface */
- __u32 version_so; /** Secure Objects */
- __u32 version_mclf; /** MobiCore Load Format */
- __u32 version_container; /** MobiCore Container Format */
- __u32 version_mc_config; /** MobiCore Config. Block Format */
- __u32 version_tl_api; /** MobiCore Trustlet API */
- __u32 version_dr_api; /** MobiCore Driver API */
- __u32 version_nwd; /** This Driver */
-};
-
-/*
- * defines for the ioctl mobicore driver module function call from user space.
- */
-/* MobiCore IOCTL magic number */
-#define MC_IOC_MAGIC 'M'
-
-/*
- * Implement corresponding functions from user api
- */
-#define MC_IO_OPEN_SESSION \
- _IOWR(MC_IOC_MAGIC, 0, struct mc_ioctl_open_session)
-#define MC_IO_OPEN_TRUSTLET \
- _IOWR(MC_IOC_MAGIC, 1, struct mc_ioctl_open_trustlet)
-#define MC_IO_CLOSE_SESSION _IO(MC_IOC_MAGIC, 2)
-#define MC_IO_NOTIFY _IO(MC_IOC_MAGIC, 3)
-#define MC_IO_WAIT _IOW(MC_IOC_MAGIC, 4, struct mc_ioctl_wait)
-#define MC_IO_MAP _IOWR(MC_IOC_MAGIC, 5, struct mc_ioctl_map)
-#define MC_IO_UNMAP _IOW(MC_IOC_MAGIC, 6, struct mc_ioctl_map)
-#define MC_IO_ERR _IOWR(MC_IOC_MAGIC, 7, struct mc_ioctl_geterr)
-#define MC_IO_HAS_SESSIONS _IO(MC_IOC_MAGIC, 8)
-#define MC_IO_VERSION _IOR(MC_IOC_MAGIC, 9, struct mc_version_info)
-
-#endif /* _MC_USER_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <memory>
-#include <mutex>
-#include <string>
-#include <vector>
-
-#include <string.h> // strncpy
-#include <sys/mman.h> // mmap, munmap
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#undef LOG_TAG
-#define LOG_TAG "TeeProxyClient"
-#include "log.h"
-#include "mcVersionHelper.h"
-#include "proxy_common.h"
-#include "proxy_client.h"
-
-using namespace com::trustonic::tee_proxy;
-
-class ClientConnection {
- std::string buffer_;
- std::mutex comm_mutex_;
- std::mutex comm_queue_mutex_;
- int socket_ = -1;
- bool is_open_ = false;
- bool is_broken_ = false;
- Session* session_ = nullptr;
-public:
- ~ClientConnection() {
- if (is_open_) {
- close();
- }
- delete session_;
- }
- int open() {
- socket_ = ::socket(AF_UNIX, SOCK_STREAM, 0);
- if (socket_ < 0) {
- LOG_ERRNO("socket");
- return -1;
- }
- struct sockaddr_un sock_un;
- sock_un.sun_family = AF_UNIX;
- ::strncpy(sock_un.sun_path, SOCKET_PATH, sizeof(sock_un.sun_path) - 1);
- socklen_t len = static_cast<socklen_t>(strlen(sock_un.sun_path) +
- sizeof(sock_un.sun_family));
- sock_un.sun_path[0] = '\0'; // Abstract
- if (::connect(socket_, reinterpret_cast<struct sockaddr*>(&sock_un),
- len) < 0) {
- LOG_ERRNO("connect");
- return -1;
- }
- is_open_ = true;
- LOG_D("socket %d connected", socket_);
- return 0;
- }
- int close() {
- ::close(socket_);
- is_open_ = false;
- LOG_D("socket %d session %x closed", socket_, session_ ? session_->id() : 0);
- return 0;
- }
- bool isBroken() const {
- return is_broken_;
- }
- void setSession(Session* session) {
- session_ = session;
- }
- Session* session() const {
- return session_;
- }
- int call(RpcMethod method, const ::google::protobuf::MessageLite& request,
- ::google::protobuf::MessageLite& response) {
- // Trick to ensure round-robin access to two callers
- comm_queue_mutex_.lock();
- std::lock_guard<std::mutex> comm_lock(comm_mutex_);
- comm_queue_mutex_.unlock();
- LOG_D("socket %d session %x call %s", socket_,
- session_ ? session_->id() : 0, methodToString(method));
-
- // Request
- {
- // Serialize request
- if (!request.SerializeToString(&buffer_)) {
- LOG_E("Failed to serialize");
- is_broken_ = true;
- return -1;
- }
-
- // Send request header
- RequestHeader header;
- ::memcpy(header.magic, PROTOCOL_MAGIC, sizeof(header.magic));
- header.version = PROTOCOL_VERSION;
- header.method = static_cast<uint16_t>(method);
- header.length = static_cast<uint32_t>(buffer_.length());
- if (send_all(socket_, "header", &header, sizeof(header))) {
- is_broken_ = true;
- return -1;
- }
-
- // Send request data
- LOG_D("send %u bytes of data", header.length);
- if (send_all(socket_, "data", &buffer_[0], header.length)) {
- is_broken_ = true;
- return -1;
- }
- }
-
- // Response
- {
- // Receive response header
- ResponseHeader header;
- if (recv_all(socket_, "header", &header, sizeof(header))) {
- is_broken_ = true;
- return -1;
- }
-
- // Check header
- if (::memcmp(header.magic, PROTOCOL_MAGIC, sizeof(header.magic))) {
- LOG_E("Wrong magic");
- is_broken_ = true;
- return -1;
- }
- if (header.version != PROTOCOL_VERSION) {
- LOG_E("Wrong version");
- is_broken_ = true;
- return -1;
- }
- if (header.proto_rc < 0) {
- errno = -header.proto_rc;
- LOG_E("Protocol error reported: %s",
- strerror(-header.proto_rc));
- is_broken_ = true;
- return -1;
- }
-
- // Receive response data
- LOG_D("receive %d bytes of data", header.proto_rc);
- if (header.proto_rc != 0) {
- // Receive response data
- int length = header.proto_rc;
- buffer_.resize(length);
- if (recv_all(socket_, "data", &buffer_[0], length)) {
- is_broken_ = true;
- return -1;
- }
-
- // Parse response
- if (!response.ParseFromString(buffer_)) {
- LOG_E("Failed to parse");
- is_broken_ = true;
- return -1;
- }
- }
-
- // Method errors do not require specific method action
- if (header.method_rc) {
- errno = header.method_rc;
- LOG_D("Error reported: %s", strerror(errno));
- return -1;
- }
- }
- LOG_D("socket %d session %x call done", socket_,
- session_ ? session_->id() : 0);
- return 0;
- }
-};
-
-class SessionConnectionsList {
- std::mutex mutex_;
- std::vector<ClientConnection*> connections_;
-public:
- ClientConnection* find(uint32_t id) {
- std::lock_guard<std::mutex> lock(mutex_);
- for (auto& connection: connections_) {
- if (connection->session()->id() == id) {
- return connection;
- }
- }
- return nullptr;
- }
- int deleteConnection(uint32_t id) {
- LOG_D("%s %p: %x", __FUNCTION__, this, id);
- std::lock_guard<std::mutex> lock(mutex_);
- auto it = std::find_if(connections_.begin(), connections_.end(),
- [this, id](ClientConnection* connection) {
- return connection->session()->id() == id;
- });
- if (it == connections_.end()) {
- // Not found
- return -1;
- }
- delete *it;
- connections_.erase(it);
- return 0;
- }
- void push_back(ClientConnection* connection) {
- LOG_D("%s %p: %x", __FUNCTION__, this, connection->session()->id());
- std::lock_guard<std::mutex> lock(mutex_);
- connections_.push_back(connection);
- }
- bool empty() const {
- return connections_.empty();
- }
-};
-
-struct ProxyClient::Impl {
- bool is_open_;
- // Versions
- mc_version_info version_info;
- // Sessions
- SessionConnectionsList connections;
- Impl(): is_open_(false) {
- ::memset(&version_info, 0, sizeof(version_info));
- }
- int getVersion(ClientConnection& conn, struct mc_version_info& version_info);
-};
-
-ProxyClient::ProxyClient(): pimpl_(new Impl) {
-}
-
-ProxyClient::~ProxyClient() {
- delete pimpl_;
-}
-
-int ProxyClient::open() {
- ClientConnection conn;
- if (conn.open()) {
- return -1;
- }
- // Cache versions
- if (pimpl_->getVersion(conn, pimpl_->version_info)) {
- return -1;
- }
- conn.close();
- pimpl_->is_open_ = true;
- LOG_I("proxy client open");
- return 0;
-}
-
-int ProxyClient::close() {
- pimpl_->is_open_ = false;
- LOG_I("proxy client closed");
- return 0;
-}
-
-bool ProxyClient::isOpen() const {
- return pimpl_->is_open_;
-}
-
-int ProxyClient::hasOpenSessions() const {
- int ret = 0;
- if (!pimpl_->connections.empty()) {
- ret = -1;
- errno = ENOTEMPTY;
- }
- LOG_D("%s rc=%d", __FUNCTION__, ret);
- return ret;
-}
-
-int ProxyClient::openSession(struct mc_ioctl_open_session& session) {
- LOG_D("tci 0x%llx len %u", session.tci, session.tcilen);
- if ((session.tci && !session.tcilen) ||
- (!session.tci && session.tcilen)) {
- LOG_E("TCI and its length are inconsistent");
- errno = EINVAL;
- return -1;
- }
- // So we return the correct error code
- if (session.tcilen > BUFFER_LENGTH_MAX) {
- errno = EINVAL;
- return -1;
- }
- // Open the session
- void* tci = reinterpret_cast<void*>(static_cast<uintptr_t>(session.tci));
- int saved_errno = errno;
- errno = EHOSTUNREACH;
- // Request
- OpenSessionRequest request;
- request.set_uuid(static_cast<void*>(&session.uuid), sizeof(session.uuid));
- request.set_is_gp_uuid(session.is_gp_uuid);
- if (tci) {
- request.set_tci(tci, session.tcilen);
- }
- request.set_login_type(static_cast<LoginType>(session.identity.login_type));
- request.set_login_data(static_cast<void*>(session.identity.login_data),
- sizeof(session.identity.login_data));
- // Create connection
- std::unique_ptr<ClientConnection> conn(new ClientConnection);
- if (conn->open()) {
- LOG_E("Failed to open connection");
- return -1;
- }
- // Exchange
- OpenSessionResponse response;
- if (conn->call(OPEN_SESSION, request, response)) {
- // Error logged in call()
- return -1;
- }
- // Response
- if (!response.has_id()) {
- LOG_E("Required parameter missing");
- return -1;
- }
- // Success
- errno = saved_errno;
- session.sid = response.id();
- LOG_D("session %x open", session.sid);
- Session::Buffer* buffer;
- if (tci) {
- buffer = new Session::Buffer(tci, session.tcilen);
- } else {
- buffer = nullptr;
- }
- conn->setSession(new Session(session.sid, buffer));
- pimpl_->connections.push_back(conn.release());
- return 0;
-}
-
-int ProxyClient::openTrustlet(struct mc_ioctl_open_trustlet& trustlet) {
- LOG_D("tci 0x%llx len %u", trustlet.tci, trustlet.tcilen);
- if ((trustlet.tci && !trustlet.tcilen) ||
- (!trustlet.tci && trustlet.tcilen)) {
- LOG_E("TCI and its length are inconsistent");
- return -1;
- }
- // So we return the correct error code
- if (trustlet.tcilen > BUFFER_LENGTH_MAX) {
- errno = EINVAL;
- return -1;
- }
- // Open the trustlet
- void* app = reinterpret_cast<void*>(static_cast<uintptr_t>(trustlet.buffer));
- void* tci = reinterpret_cast<void*>(static_cast<uintptr_t>(trustlet.tci));
- int saved_errno = errno;
- errno = EHOSTUNREACH;
- // Request
- OpenTrustletRequest request;
- request.set_spid(trustlet.spid);
- request.set_trustapp(app, trustlet.tlen);
- if (tci) {
- request.set_tci(tci, trustlet.tcilen);
- }
- // Create connection
- std::unique_ptr<ClientConnection> conn(new ClientConnection);
- if (conn->open()) {
- LOG_E("Failed to open connection");
- return -1;
- }
- // Exchange
- OpenTrustletResponse response;
- if (conn->call(OPEN_TRUSTLET, request, response)) {
- // Error logged in call()
- return -1;
- }
- // Response
- if (!response.has_id()) {
- LOG_E("Required parameter missing");
- return -1;
- }
- // Success
- errno = saved_errno;
- trustlet.sid = response.id();
- LOG_D("session %x open", trustlet.sid);
- // Create session management object
- Session::Buffer* buffer;
- if (tci) {
- buffer = new Session::Buffer(tci, trustlet.tcilen);
- } else {
- buffer = nullptr;
- }
- conn->setSession(new Session(trustlet.sid, buffer));
- pimpl_->connections.push_back(conn.release());
- return 0;
-}
-
-int ProxyClient::closeSession(uint32_t session_id) {
- LOG_D("session %x close", session_id);
- // Find session connection
- auto connection = pimpl_->connections.find(session_id);
- if (!connection) {
- errno = ENXIO;
- return -1;
- }
- int saved_errno = errno;
- errno = EHOSTUNREACH;
- // Request
- CloseSessionRequest request;
- request.set_id(session_id);
- // Exchange
- CloseSessionResponse response;
- if (connection->call(CLOSE_SESSION, request, response)) {
- // Error logged in call()
- if (connection->isBroken()) {
- pimpl_->connections.deleteConnection(session_id);
- }
- return -1;
- }
- // No response
- // Success
- errno = saved_errno;
- if (pimpl_->connections.deleteConnection(session_id)) {
- errno = ENXIO;
- return -1;
- }
- LOG_D("session %x closed", session_id);
- return 0;
-}
-
-int ProxyClient::notify(uint32_t session_id) {
- LOG_D("session %x notify", session_id);
- // Find session connection
- auto connection = pimpl_->connections.find(session_id);
- if (!connection) {
- errno = ENXIO;
- return -1;
- }
- int saved_errno = errno;
- errno = EHOSTUNREACH;
- // Request
- NotifyRequest request;
- request.set_sid(session_id);
- auto session = connection->session();
- if (session->hasTci()) {
- request.set_tci(session->tci(), session->tciLen());
- }
- std::lock_guard<std::mutex> buffers_lock(session->buffersMutex());
- auto& buffers = session->buffers();
- for (auto& buf: buffers) {
- if (buf->info().flags & MC_IO_MAP_INPUT) {
- NotifyRequest_Buffers* buffer = request.add_buffers();
- buffer->set_sva(buf->info().sva);
- buffer->set_data(buf->address(), buf->info().len);
- }
- }
- // Exchange
- NotifyResponse response;
- if (connection->call(NOTIFY, request, response)) {
- // Error logged in call()
- if (connection->isBroken()) {
- pimpl_->connections.deleteConnection(session_id);
- }
- return -1;
- }
- // No response
- // Success
- errno = saved_errno;
- LOG_D("session %x notification sent", session_id);
- return 0;
-}
-
-int ProxyClient::waitNotification(const struct mc_ioctl_wait& wait) {
- LOG_D("session %x wait for notification", wait.sid);
- // Find session connection
- auto connection = pimpl_->connections.find(wait.sid);
- if (!connection) {
- errno = ENXIO;
- return -1;
- }
- int saved_errno = errno;
- errno = EHOSTUNREACH;
- // Request
- WaitNotificationRequest request;
- request.set_sid(wait.sid);
- // Timeout to server cannot exceed a few seconds, retry every 5s
- int32_t timeout_left = wait.timeout;
- WaitNotificationResponse response;
- bool failed = false;
- while (true) {
- if (wait.timeout < 0) {
- // Infinite
- request.set_timeout(timeout_max);
- request.set_partial(true);
- } else if (timeout_left > timeout_max) {
- // Big
- request.set_timeout(timeout_max);
- request.set_partial(true);
- timeout_left -= timeout_max;
- } else {
- // Small enough
- request.set_timeout(timeout_left);
- request.set_partial(false);
- timeout_left = 0;
- }
- LOG_D("timeout: asked=%d left=%d set=%d",
- wait.timeout, timeout_left, request.timeout());
- // Exchange
- if (!connection->call(WAIT, request, response)) {
- LOG_D("done");
- break;
- }
- // Real timeout or other error
- if ((errno != ETIME) || !request.partial()) {
- // Error logged in call()
- if (connection->isBroken()) {
- pimpl_->connections.deleteConnection(wait.sid);
- LOG_D("abort");
- return -1;
- }
- LOG_D("give up, but update buffers");
- failed = true;
- break;
- }
- LOG_D("retry");
- }
- // Response
- auto session = connection->session();
- if (response.has_tci() && session->updateTci(response.tci())) {
- LOG_E("Could not update TCI");
- return -1;
- }
- for (int i = 0; i < response.buffers_size(); i++) {
- const WaitNotificationResponse_Buffers& buffer = response.buffers(i);
- if (!buffer.has_sva() || !buffer.has_data()) {
- LOG_E("Required parameter missing");
- return -1;
- }
- std::lock_guard<std::mutex> buffers_lock(session->buffersMutex());
- auto buf = session->findBuffer(buffer.sva());
- if (!buf) {
- LOG_E("Buffer not found for SVA %jx", buffer.sva());
- return -1;
- }
- if (buffer.data().length() != buf->info().len) {
- LOG_E("Buffer sizes differ for SVA %jx: %zu != %u",
- buffer.sva(), buffer.data().length(), buf->info().len);
- return -1;
- }
- ::memcpy(buf->address(), buffer.data().c_str(), buf->info().len);
- }
- if (failed) {
- return -1;
- }
- // Success
- errno = saved_errno;
- LOG_D("session %x notification received", wait.sid);
- return 0;
-}
-
-int ProxyClient::malloc(uint8_t** buffer, uint32_t length) {
- // Cannot share kernel buffers through the proxy
- *buffer = (uint8_t*)::mmap(0, length, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_ANONYMOUS, -1, 0);
- if (*buffer == MAP_FAILED) {
- errno = ENOMEM;
- return -1;
- }
- LOG_D("mmap'd buffer %p len %u", *buffer, length);
- return 0;
-}
-
-int ProxyClient::free(uint8_t* buffer, uint32_t length) {
- LOG_D("munmap'd buffer %p len %u", buffer, length);
- ::munmap(buffer, length);
- return 0;
-}
-
-int ProxyClient::map(struct mc_ioctl_map& map) {
- LOG_D("map buffer(s) to session %x", map.sid);
- // Find session connection
- auto connection = pimpl_->connections.find(map.sid);
- if (!connection) {
- errno = ENXIO;
- return -1;
- }
- int saved_errno = errno;
- errno = EHOSTUNREACH;
- // Request
- MapRequest request;
- request.set_sid(map.sid);
- for (int i = 0; i < MC_MAP_MAX; i++) {
- if (map.bufs[i].va) {
- if (map.bufs[i].len > BUFFER_LENGTH_MAX) {
- LOG_E("Incorrect length for buffer: %u", map.bufs[i].len);
- errno = -EINVAL;
- return -1;
- }
- auto buffer = request.add_buffers();
- buffer->set_len(map.bufs[i].len);
- buffer->set_flags(map.bufs[i].flags);
- }
- }
- // Exchange
- MapResponse response;
- if (connection->call(MAP, request, response)) {
- // Error logged in call()
- if (connection->isBroken()) {
- pimpl_->connections.deleteConnection(map.sid);
- }
- return -1;
- }
- // Response
- if (response.buffers_size() != request.buffers_size()) {
- LOG_E("Response buffers size (%d) does not match request's (%d)",
- response.buffers_size(), request.buffers_size());
- return -1;
- }
- int buffer_index = 0;
- for (int i = 0; i < MC_MAP_MAX; i++) {
- if (map.bufs[i].va) {
- const MapResponse_Buffers& buf = response.buffers(buffer_index++);
- if (!buf.has_sva()) {
- LOG_E("Required parameter missing");
- return -1;
- }
- map.bufs[i].sva = buf.sva();
- }
- }
- // Success
- errno = saved_errno;
- auto session = connection->session();
- for (int i = 0; i < MC_MAP_MAX; i++) {
- if (map.bufs[i].va) {
- session->addBuffer(map.bufs[i]);
- }
- }
- LOG_D("session %x buffer(s) mapped", map.sid);
- return 0;
-}
-
-int ProxyClient::unmap(const struct mc_ioctl_map& map) {
- LOG_D("unmap buffer(s) to session %x", map.sid);
- // Find session connection
- auto connection = pimpl_->connections.find(map.sid);
- if (!connection) {
- errno = ENXIO;
- return -1;
- }
- int saved_errno = errno;
- errno = EHOSTUNREACH;
- // Request
- UnmapRequest request;
- request.set_sid(map.sid);
- for (int i = 0; i < MC_MAP_MAX; i++) {
- if (map.bufs[i].va) {
- if (!map.bufs[i].sva) {
- errno = EINVAL;
- return -1;
- }
- UnmapRequest_Buffers* buffer = request.add_buffers();
- buffer->set_sva(map.bufs[i].sva);
- }
- }
- // Exchange
- UnmapResponse response;
- if (connection->call(UNMAP, request, response)) {
- // Error logged in call()
- if (connection->isBroken()) {
- pimpl_->connections.deleteConnection(map.sid);
- }
- return -1;
- }
- // No response
- // Success
- errno = saved_errno;
- auto session = connection->session();
- for (int i = 0; i < MC_MAP_MAX; i++) {
- if (map.bufs[i].va) {
- if (session->removeBuffer(map.bufs[i].sva)) {
- LOG_E("Unmapped buffer not found in session: %llu",
- map.bufs[i].sva);
- return -1;
- }
- }
- }
- LOG_D("session %x buffer(s) unmapped", map.sid);
- return 0;
-}
-
-int ProxyClient::getError(struct mc_ioctl_geterr& err) {
- LOG_D("get session %x exit code", err.sid);
- // Find session connection
- auto connection = pimpl_->connections.find(err.sid);
- if (!connection) {
- errno = ENXIO;
- return -1;
- }
- int saved_errno = errno;
- errno = EHOSTUNREACH;
- // Request
- GetErrorRequest request;
- request.set_sid(err.sid);
- // Exchange
- GetErrorResponse response;
- if (connection->call(GET_ERROR, request, response)) {
- // Error logged in call()
- if (connection->isBroken()) {
- pimpl_->connections.deleteConnection(err.sid);
- }
- return -1;
- }
- // Response
- if (!response.has_exit_code()) {
- LOG_E("Required parameter missing");
- return -1;
- }
- // Success
- errno = saved_errno;
- err.value = response.exit_code();
- LOG_D("session %x exit code %d", err.sid, err.value);
- return 0;
-}
-
-int ProxyClient::Impl::getVersion(ClientConnection& conn,
- struct mc_version_info& version_info) {
- LOG_D("get version");
- int saved_errno = errno;
- errno = EHOSTUNREACH;
- // Request
- GetVersionRequest request;
- // No inputs to set
- // Exchange
- GetVersionResponse response;
- if (conn.call(GET_VERSION, request, response)) {
- // Error logged in call()
- return -1;
- }
- // Response
- if (!response.has_product_id() ||
- !response.has_mci() ||
- !response.has_so() ||
- !response.has_mclf() ||
- !response.has_container() ||
- !response.has_mc_config() ||
- !response.has_tl_api() ||
- !response.has_dr_api() ||
- !response.has_nwd()) {
- LOG_E("Required parameter missing");
- return -1;
- }
- // Success
- errno = saved_errno;
- ::strncpy(version_info.product_id, response.product_id().c_str(),
- MC_PRODUCT_ID_LEN);
- version_info.product_id[MC_PRODUCT_ID_LEN - 1] = '\0';
- version_info.version_mci = response.mci();
- version_info.version_so = response.so();
- version_info.version_mclf = response.mclf();
- version_info.version_container = response.container();
- version_info.version_mc_config = response.mc_config();
- version_info.version_tl_api = response.tl_api();
- version_info.version_dr_api = response.dr_api();
- version_info.version_nwd = response.nwd();
- return 0;
-}
-
-int ProxyClient::getVersion(struct mc_version_info& version_info) {
- if (!pimpl_->is_open_) {
- errno = EBADF;
- return -1;
- }
- version_info = pimpl_->version_info;
- return 0;
-}
-
-int ProxyClient::gpRequestCancellation(uint32_t session_id) {
- LOG_D("cancel GP operation on session %x", session_id);
- // Find session connection
- auto connection = pimpl_->connections.find(session_id);
- if (!connection) {
- errno = ENXIO;
- return -1;
- }
- int saved_errno = errno;
- errno = EHOSTUNREACH;
- // Request
- GpRequestCancellationRequest request;
- request.set_sid(session_id);
- // Exchange
- GpRequestCancellationResponse response;
- if (connection->call(GP_REQUESTCANCELLATION, request, response)) {
- // Error logged in call()
- if (connection->isBroken()) {
- pimpl_->connections.deleteConnection(session_id);
- }
- return -1;
- }
- // No response
- // Success
- errno = saved_errno;
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __PROXY_CLIENT_H__
-#define __PROXY_CLIENT_H__
-
-#include "iclient.h"
-
-class ProxyClient: public IClient {
- struct Impl;
- Impl* const pimpl_;
-public:
- ProxyClient();
- ~ProxyClient();
- virtual int open() override;
- virtual int close() override;
- virtual bool isOpen() const override;
- virtual int hasOpenSessions() const override;
- virtual int openSession(struct mc_ioctl_open_session& session) override;
- virtual int openTrustlet(struct mc_ioctl_open_trustlet& trustlet) override;
- virtual int closeSession(uint32_t session_id) override;
- virtual int notify(uint32_t session_id) override;
- virtual int waitNotification(const struct mc_ioctl_wait& wait) override;
- virtual int malloc(uint8_t** buffer, uint32_t length) override;
- virtual int free(uint8_t* buffer, uint32_t length) override;
- virtual int map(struct mc_ioctl_map& map) override;
- virtual int unmap(const struct mc_ioctl_map& map) override;
- virtual int getError(struct mc_ioctl_geterr& err) override;
- virtual int getVersion(struct mc_version_info& version_info) override;
- virtual int gpRequestCancellation(uint32_t session_id) override;
-};
-
-#endif // __PROXY_CLIENT_H__
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <algorithm>
-#include <mutex>
-#include <string>
-#include <vector>
-
-#include <stdlib.h> // malloc, free
-#include <sys/mman.h> // mmap, munmap
-
-#include "mc_user.h" // mc_ioctl_buffer
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#include "mc.pb.h"
-#pragma GCC diagnostic pop
-
-#define SOCKET_PATH "@/com/trustonic/tee_proxy"
-#define PROTOCOL_MAGIC "T7e3"
-#define PROTOCOL_VERSION 1
-
-/*
- * ProtoBuf gives us the serialisation mechanism, but that's not enough to send
- * our RPC messages: we also need to pass the method we want to call, the total
- * length of the data, and a magic number is usually welcome too. While at it,
- * we'll throw a version number just in case.
- *
- * Hence:
- * ----------------------
- * | Magic number | 4 bytes (text)
- * ----------------------
- * | Method | Version | 2 + 2 bytes (LE)
- * ----------------------
- * | Message length | 4 bytes (LE)
- * ----------------------
- * | |
- * | Message data | N bytes (text)
- * ~ ~
- * | |
- * ----------------------
- */
-
-namespace com {
-namespace trustonic {
-namespace tee_proxy {
-
-struct RequestHeader {
- char magic[4];
- uint16_t version;
- uint16_t method;
- uint32_t length;
-};
-
-struct ResponseHeader {
- char magic[4];
- uint16_t version;
- uint16_t method;
- int32_t proto_rc; // -errno if negative, length of data otherwise
- uint32_t method_rc; // errno from called method on server side
-};
-
-enum RpcMethod {
- OPEN_SESSION = 0,
- OPEN_TRUSTLET = 1,
- CLOSE_SESSION = 2,
- NOTIFY = 3,
- WAIT = 4,
- MAP = 5,
- UNMAP = 6,
- GET_ERROR = 7,
- GET_VERSION = 9,
- GP_REQUESTCANCELLATION = 27,
-};
-
-class Session {
-public:
- class Buffer {
- enum Type {
- NONE, // No buffer
- CLIENT, // Buffer managed by caller (client side)
- SERVER, // Buffer mmap'd (server side)
- };
- mc_ioctl_buffer info_;
- void* address_;
- Type type_;
- int alloc(size_t length, uint32_t flags = MC_IO_MAP_INPUT_OUTPUT) {
- // No posix_memalign, aligned_alloc, valloc, memalign, pvalloc in
- // Android so we rely on mmap to give us page-aligned memory
- size_t page_mask = sysconf(_SC_PAGESIZE) - 1;
- size_t aligned_length = (length + page_mask) & ~page_mask;
- void* buf = ::mmap(0, aligned_length, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- if (buf == MAP_FAILED) {
- LOG_E("Failed to allocate");
- return -1;
- }
- type_ = SERVER;
- address_ = buf;
- info_.va = reinterpret_cast<uintptr_t>(address_);
- info_.len = static_cast<uint32_t>(length);
- info_.flags = flags;
- LOG_D("alloc'd buffer %p:%u:%x", address_, info_.len, info_.flags);
- return 0;
- }
- public:
- Buffer(const Buffer&) = delete;
- Buffer& operator=(const Buffer&) = delete;
- // Constructor from buffer: allocate and fill in
- Buffer(std::string buffer): address_(nullptr) {
- if (!alloc(buffer.length())) {
- update(buffer);
- }
- }
- // Constructor for client TCI: pointer and length (can be null) given
- Buffer(void* address, size_t length): address_(address) {
- if (address_) {
- info_.va = reinterpret_cast<uintptr_t>(address_);
- info_.len = static_cast<uint32_t>(length);
- info_.flags = MC_IO_MAP_INPUT_OUTPUT;
- type_ = CLIENT;
- LOG_D("use buffer %p:%u:%x", address_, info_.len, info_.flags);
- } else {
- info_.va = 0;
- info_.len = 0;
- info_.flags = 0;
- type_ = NONE;
- }
- info_.sva = 0;
- }
- // Constructor for server buffer: allocate
- Buffer(uint32_t length, uint32_t flags): address_(nullptr) {
- alloc(length, flags);
- }
- // Constructor for client buffer: info given
- Buffer(mc_ioctl_buffer info): info_(info) {
- address_ = reinterpret_cast<void*>(
- static_cast<uintptr_t>(info_.va));
- type_ = CLIENT;
- LOG_D("use buffer %p:%u:%x", address_, info_.len, info_.flags);
- }
- ~Buffer() {
- if (type_ == Buffer::SERVER) {
- LOG_D("unmap buffer %p:%u:%x", address_, info_.len,
- info_.flags);
- ::munmap(address_, info_.len);
- }
- }
- // Accessors
- const mc_ioctl_buffer& info() const {
- return info_;
- }
- void* address() const {
- return address_;
- }
- void setSva(uint64_t sva) {
- info_.sva = sva;
- }
- int update(const std::string& buf) {
- if (buf.length() != info_.len) {
- LOG_E("Failed to update TCI");
- return -1;
- }
- if (type_ != NONE) {
- ::memcpy(address_, buf.c_str(), info_.len);
- }
- return 0;
- }
- };
-private:
- uint32_t id_;
- Buffer* tci_;
- std::mutex buffers_mutex_;
- std::vector<Buffer*> buffers_;
-public:
- Session(uint32_t id, Buffer* tci): id_(id), tci_(tci) {}
- ~Session() {
- delete tci_;
- for (auto& buf: buffers_) {
- delete buf;
- }
- }
- uint32_t id() const {
- return id_;
- }
- bool hasTci() const {
- return tci_;
- }
- const void* tci() const {
- return tci_->address();
- }
- size_t tciLen() const {
- return tci_->info().len;
- }
- int updateTci(const std::string& buf) {
- return tci_->update(buf);
- }
- void addBuffer(Buffer* buffer) {
- LOG_D("%p %s: 0x%llx", this, __FUNCTION__, buffer->info().sva);
- std::lock_guard<std::mutex> buffers_lock(buffers_mutex_);
- buffers_.push_back(buffer);
- }
- void addBuffer(mc_ioctl_buffer& info) {
- LOG_D("%p %s: 0x%llx", this, __FUNCTION__, info.sva);
- std::lock_guard<std::mutex> buffers_lock(buffers_mutex_);
- auto buffer = new Buffer(info);
- buffers_.push_back(buffer);
- }
- int removeBuffer(uint64_t sva) {
- LOG_D("%p %s: %jx", this, __FUNCTION__, sva);
- std::lock_guard<std::mutex> buffers_lock(buffers_mutex_);
- auto it = std::find_if(buffers_.begin(), buffers_.end(),
- [this, sva](Buffer* buffer) {
- return buffer->info().sva == sva;
- });
- if (it == buffers_.end()) {
- // Not found
- return -1;
- }
- delete *it;
- buffers_.erase(it);
- return 0;
- }
- // Must be called under buffers_mutex_
- Buffer* findBuffer(uint64_t sva) {
- for (auto& buf: buffers_) {
- if (buf->info().sva == sva) {
- return buf;
- }
- }
- return nullptr;
- }
- std::mutex& buffersMutex() {
- return buffers_mutex_;
- }
- const std::vector<Buffer*>& buffers() {
- return buffers_;
- }
-};
-
-static int recv_all(int sock, const char* what, void* buffer, size_t length,
- bool may_close = false) {
- auto cbuffer = static_cast<char*>(buffer);
- size_t count = 0;
- while (count < length) {
- ssize_t rc = ::recv(sock, &cbuffer[count], length - count, 0);
- if (rc <= 0) {
- if (rc == 0) {
- if (may_close) {
- LOG_D("socket closed");
- } else {
- LOG_E("socket closed while receiving %s", what);
- }
- return -1;
- }
- if (errno != EINTR) {
- LOG_ERRNO(what);
- return -1;
- }
- LOG_D("signal ignored while sending %s", what);
- continue;
- } else {
- count += rc;
- }
- }
- return 0;
-}
-
-static const int32_t timeout_max = 1000; // 1s
-
-static int send_all(int sock, const char* what, const void* buffer,
- size_t length) {
- auto cbuffer = static_cast<const char*>(buffer);
- size_t count = 0;
- while (count < length) {
- ssize_t rc = ::send(sock, &cbuffer[count], length - count,
- MSG_NOSIGNAL);
- if (rc <= 0) {
- if (rc == 0) {
- LOG_E("socket closed while sending %s", what);
- return -1;
- }
- if (errno != EINTR) {
- LOG_ERRNO(what);
- return -1;
- }
- LOG_D("signal ignored while sending %s", what);
- continue;
- } else {
- count += rc;
- }
- }
- return 0;
-}
-
-#ifndef NDEBUG
-static const char* methodToString(enum RpcMethod method) {
- switch (method) {
- case OPEN_SESSION:
- return "openSession";
- case OPEN_TRUSTLET:
- return "openTruslet";
- case CLOSE_SESSION:
- return "closeSession";
- case NOTIFY:
- return "notify";
- case WAIT:
- return "waitNotification";
- case MAP:
- return "map";
- case UNMAP:
- return "unmap";
- case GET_ERROR:
- return "getError";
- case GET_VERSION:
- return "getVersion";
- case GP_REQUESTCANCELLATION:
- return "gpRequestCancellation";
- }
- return "unknown";
-}
-#endif
-
-} // namespace tee_proxy
-} // namespace trustonic
-} // namespace com
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <memory>
-#include <mutex>
-#include <thread>
-#include <string>
-
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <errno.h>
-
-#include "driver_client.h"
-#undef LOG_TAG
-#define LOG_TAG "TeeProxyServer"
-#include "log.h"
-#include "proxy_common.h"
-#include "proxy_server.h"
-
-using namespace com::trustonic::tee_proxy;
-
-template <class T>
-class FreeMe {
- T* t_;
-public:
- FreeMe(T* t): t_(t) {}
- ~FreeMe() {
- ::free(t_);
- }
- operator T* () {
- return t_;
- }
- operator uintptr_t () {
- return reinterpret_cast<uintptr_t>(t_);
- }
-};
-
-class ServerConnection {
- int listen_socket_;
- int socket_ = -1;
- pid_t pid_ = 0;
- DriverClient driver;
- std::mutex connection_mutex; // Protects is_running_ and session_
- bool is_running_ = false;
- Session* session_ = nullptr;
- std::thread thread_;
- int receiveCredentials() {
- // Make sure we can receive credentials
- int enable = 1;
- if (::setsockopt(socket_, SOL_SOCKET, SO_PASSCRED, &enable,
- sizeof(enable))) {
- LOG_ERRNO("setsockopt");
- return -1;
- }
-
- struct ucred credentials;
- char ctrl[CMSG_SPACE(sizeof(credentials))];
- struct iovec iov[1] = { { 0, 0 } };
- struct msghdr msg = { 0, 0, iov, 1, ctrl, sizeof(ctrl), 0 };
-
- msg.msg_iov->iov_base = nullptr;
- msg.msg_iov->iov_len = 0;
- do {
- if (::recvmsg(socket_, &msg, 0) == 0) {
- break;
- }
- if ((errno != EINTR) && (errno != EAGAIN)) {
- LOG_ERRNO("recvmsg");
- return -1;
- }
- } while (true);
-
- if (msg.msg_controllen < sizeof(struct cmsghdr)) {
- errno = EINVAL;
- LOG_ERRNO("check");
- return -1;
- }
- struct cmsghdr* cmptr = CMSG_FIRSTHDR(&msg);
- size_t size = sizeof(credentials);
- if ((cmptr->cmsg_len != CMSG_LEN(size)) ||
- (cmptr->cmsg_level != SOL_SOCKET) ||
- (cmptr->cmsg_type != SCM_CREDENTIALS)) {
- errno = EINVAL;
- LOG_ERRNO("check");
- return -1;
- }
-
- credentials = *(struct ucred*)CMSG_DATA(cmptr);
- pid_ = credentials.pid;
- return 0;
- }
- void connectionThread() {
- LOG_D("thread entered %p", this);
- std::string buffer;
- do {
- // Request
- RpcMethod method;
- {
- // Receive request header
- RequestHeader header;
- if (recv_all(socket_, "header", &header, sizeof(header),
- true)) {
- break;
- }
- if (::memcmp(header.magic, PROTOCOL_MAGIC,
- sizeof(header.magic))) {
- LOG_E("Wrong magic");
- break;
- }
- if (header.version != PROTOCOL_VERSION) {
- LOG_E("Wrong version");
- break;
- }
- method = static_cast<RpcMethod>(header.method);
- buffer.resize(header.length);
- LOG_D("receive %u bytes of data for method %s",
- header.length, methodToString(method));
-
- // Receive request data
- if (recv_all(socket_, "data", &buffer[0], header.length)) {
- break;
- }
- }
-
- // Dispatch:
- // * method_rc is return code from lower layer
- // * call returns -errno in case of error, length of data otherwise
- int method_rc = 0;
- int proto_rc = call(method, buffer, method_rc);
-
- // Response
- {
- // Send response header
- ResponseHeader header;
- ::memcpy(header.magic, PROTOCOL_MAGIC, sizeof(header.magic));
- header.version = PROTOCOL_VERSION;
- header.method = static_cast<uint16_t>(method);
- header.proto_rc = proto_rc;
- header.method_rc = method_rc;
- if (send_all(socket_, "header", &header, sizeof(header))) {
- break;
- }
-
- // Send response data
- if (header.proto_rc > 0) {
- LOG_D("send %d bytes of data", header.proto_rc);
- if (send_all(socket_, "data", &buffer[0],
- header.proto_rc)) {
- break;
- }
- }
- }
- } while (driver.isOpen());
- LOG_D("thread exiting %p", this);
-
- // Close associated client
- driver.close();
- ::close(socket_);
- is_running_ = false;
- LOG_D("thread exited %p", this);
- }
-public:
- ServerConnection(int listen_socket): listen_socket_(listen_socket) {}
- ~ServerConnection() {
- delete session_;
- }
- int open() {
- socket_ = ::accept(listen_socket_, nullptr, nullptr);
- if (socket_ < 0) {
- return -1;
- }
- if (receiveCredentials() < 0) {
- ::close(socket_);
- return -1;
- }
- // Create specific client for this connection
- if (driver.open()) {
- LOG_ERRNO("open driver");
- ::close(socket_);
- return -1;
- }
- // Start thread
- is_running_ = true;
- thread_ = std::thread(&ServerConnection::connectionThread, this);
- LOG_I("proxy server open, client PID: %d", pid_);
- return 0;
- }
- int close() {
- thread_.join();
- // driver and socket are closed at end of thread
- LOG_I("proxy server closed, client PID: %d", pid_);
- return 0;
- }
- bool isRunning() const {
- return is_running_;
- }
- int call(RpcMethod method, std::string& buffer, int& method_rc) {
- switch (method) {
- case OPEN_SESSION:
- return openSession(buffer, method_rc);
- case OPEN_TRUSTLET:
- return openTrustlet(buffer, method_rc);
- case CLOSE_SESSION:
- return closeSession(buffer, method_rc);
- case NOTIFY:
- return notify(buffer, method_rc);
- case WAIT:
- return waitNotification(buffer, method_rc);
- case MAP:
- return map(buffer, method_rc);
- case UNMAP:
- return unmap(buffer, method_rc);
- case GET_ERROR:
- return getError(buffer, method_rc);
- case GET_VERSION:
- return getVersion(buffer, method_rc);
- case GP_REQUESTCANCELLATION:
- return gpRequestCancellation(buffer, method_rc);
- }
- LOG_E("unkown method %d", method);
- return -1;
- }
- // Actions
- int openSession(std::string& buffer, int& method_rc);
- int openTrustlet(std::string& buffer, int& method_rc);
- int closeSession(std::string& buffer, int& method_rc);
- int notify(std::string& buffer, int& method_rc);
- int waitNotification(std::string& buffer, int& method_rc);
- int map(std::string& buffer, int& method_rc);
- int unmap(std::string& buffer, int& method_rc);
- int getError(std::string& buffer, int& method_rc);
- int getVersion(std::string& buffer, int& method_rc);
- int gpRequestCancellation(std::string& buffer, int& method_rc);
-};
-
-struct ProxyServer::Impl {
- int listen_socket = -1;
- int signal_pipe[2];
- std::thread thread;
-};
-
-ProxyServer::ProxyServer(): pimpl_(new Impl) {
-}
-
-ProxyServer::~ProxyServer() {
- delete pimpl_;
-}
-
-int ProxyServer::open() {
- // Make sure we have access to the driver
- DriverClient driver;
- if (driver.open()) {
- LOG_ERRNO("open driver");
- return -1;
- }
- driver.close();
-
- // Make sure we're alone
- int sock = ::socket(AF_UNIX, SOCK_STREAM, 0);
- if (sock < 0) {
- LOG_ERRNO("socket");
- return -1;
- }
- struct sockaddr_un sock_un;
- sock_un.sun_family = AF_UNIX;
- ::strncpy(sock_un.sun_path, SOCKET_PATH, sizeof(sock_un.sun_path) - 1);
- socklen_t len = static_cast<socklen_t>(strlen(sock_un.sun_path) +
- sizeof(sock_un.sun_family));
- sock_un.sun_path[0] = '\0'; // Abstract
- if (::bind(sock, reinterpret_cast<struct sockaddr*>(&sock_un), len) == 0) {
- if (::listen(sock, 5) == 0) {
- if (pipe(pimpl_->signal_pipe) == 0) {
- pimpl_->listen_socket = sock;
- pimpl_->thread = std::thread(&ProxyServer::run, this);
- LOG_D("proxy open");
- return 0;
- } else {
- LOG_ERRNO("pipe");
- }
- } else {
- LOG_ERRNO("listen");
- }
- } else {
- LOG_ERRNO("bind");
- }
- ::close(sock);
- return -1;
-}
-
-int ProxyServer::close() {
- if (pimpl_->listen_socket < 0) {
- errno = EBADF;
- return -1;
- }
- ::close(pimpl_->listen_socket);
- pimpl_->listen_socket = -1;
- // Make thread stop
- if (pimpl_->thread.joinable()) {
- ::write(pimpl_->signal_pipe[1], "c", 1);
- ::close(pimpl_->signal_pipe[1]);
- pimpl_->thread.join();
- }
- LOG_D("proxy closed");
- return 0;
-}
-
-void ProxyServer::run() {
- std::vector<ServerConnection*> connections;
-
- LOG_D("proxy ready");
- while (pimpl_->listen_socket >= 0) {
- // Wait for new connections
- fd_set fds;
- FD_ZERO(&fds);
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wold-style-cast"
- FD_SET(pimpl_->signal_pipe[0], &fds);
- FD_SET(pimpl_->listen_socket, &fds);
-#pragma GCC diagnostic pop
- if ((::select(FD_SETSIZE, &fds, nullptr, nullptr, nullptr) < 0) &&
- (errno != EINTR)) {
- LOG_ERRNO("listen on server socket");
- break;
- }
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wold-style-cast"
- if (FD_ISSET(pimpl_->signal_pipe[0], &fds)) {
-#pragma GCC diagnostic pop
- LOG_I("thread received stop message");
- // Wait for client threads to stop
- for (auto& connection: connections) {
- connection->close();
- LOG_D("delete connection %p", connection);
- delete connection;
- }
- break;
- }
- auto connection = new ServerConnection(pimpl_->listen_socket);
- if (connection->open() < 0) {
- LOG_ERRNO("new connection");
- delete connection;
- // Relax
- usleep(100000);
- } else {
- LOG_D("new connection %p", connection);
- connections.push_back(connection);
- }
- // Cleanup dead connections
- auto it = connections.begin();
- while (it != connections.end()) {
- auto connection = *it;
- if (!connection->isRunning()) {
- it = connections.erase(it);
- connection->close();
- LOG_D("delete connection %p", connection);
- delete connection;
- } else {
- it++;
- }
- }
- }
- LOG_D("proxy exited");
-}
-
-int ServerConnection::openSession(std::string& buffer, int& method_rc) {
- LOG_D("enter %s", __FUNCTION__);
- std::lock_guard<std::mutex> connection_lock(connection_mutex);
- if (session_) {
- LOG_E("Session exists");
- return -EBUSY;
- }
- // Request
- OpenSessionRequest request;
- if (!request.ParseFromString(buffer)) {
- LOG_E("Failed to parse");
- return -EPIPE;
- }
- if (!request.has_uuid() || !request.has_is_gp_uuid() ||
- !request.has_login_type() || !request.has_login_data()) {
- LOG_E("Required parameter missing");
- return -EINVAL;
- }
- // Call driver
- struct mc_ioctl_open_session session;
- if (request.uuid().length() != sizeof(session.uuid)) {
- LOG_E("Incorrect parameter uuid");
- return -EINVAL;
- }
- ::memcpy(&session.uuid, request.uuid().c_str(), sizeof(session.uuid));
- session.is_gp_uuid = request.is_gp_uuid();
- Session::Buffer* tci;
- if (request.has_tci()) {
- tci = new Session::Buffer(request.tci());
- session.tcilen = tci->info().len;
- session.tci = tci->info().va;
- } else {
- tci = nullptr;
- session.tcilen = 0;
- session.tci = 0;
- }
- std::unique_ptr<Session::Buffer> tci_ptr(tci);
- session.identity.login_type =
- static_cast<mc_login_type>(request.login_type());
- session.identity.pid = pid_;
- if (request.login_data().length() != sizeof(session.identity.login_data)) {
- LOG_E("Incorrect parameter login_data");
- return -EINVAL;
- }
- ::memcpy(&session.identity.login_data, request.login_data().c_str(),
- sizeof(session.identity.login_data));
-
- // Call
- if (driver.openSession(session)) {
- method_rc = errno;
- LOG_D("Error reported %s", strerror(errno));
- return 0;
- }
-
- // Response
- OpenSessionResponse response;
- response.set_id(session.sid);
- if (!response.SerializeToString(&buffer)) {
- LOG_E("Failed to serialize");
- return -EPIPE;
- }
- LOG_D("session %x open", session.sid);
- session_ = new Session(session.sid, tci_ptr.release());
- return static_cast<int>(buffer.length());
-}
-
-int ServerConnection::openTrustlet(std::string& buffer, int& method_rc) {
- LOG_D("enter %s", __FUNCTION__);
- std::lock_guard<std::mutex> connection_lock(connection_mutex);
- if (session_) {
- LOG_E("Session exists");
- return -EBUSY;
- }
- // Request
- OpenTrustletRequest request;
- if (!request.ParseFromString(buffer)) {
- LOG_E("Failed to parse");
- return -EPIPE;
- }
- if (!request.has_spid() || !request.has_trustapp()) {
- LOG_E("Required parameter missing");
- return -EINVAL;
- }
- // Call driver
- struct mc_ioctl_open_trustlet trustlet;
- trustlet.spid = request.spid();
- trustlet.tlen = static_cast<int>(request.trustapp().length());
- // Create TrustApp buffer
- FreeMe<void> trustapp = ::malloc(trustlet.tlen);
- if (!trustapp) {
- LOG_E("Failed to allocate TrustApp");
- return -ENOMEM;
- }
- ::memcpy(trustapp, request.trustapp().c_str(), trustlet.tlen);
- trustlet.buffer = trustapp;
- Session::Buffer* tci;
- if (request.has_tci()) {
- tci = new Session::Buffer(request.tci());
- trustlet.tcilen = tci->info().len;
- trustlet.tci = tci->info().va;
- } else {
- tci = nullptr;
- trustlet.tcilen = 0;
- trustlet.tci = 0;
- }
- std::unique_ptr<Session::Buffer> tci_ptr(tci);
-
- // Call
- if (driver.openTrustlet(trustlet)) {
- method_rc = errno;
- LOG_D("Error reported %s", strerror(errno));
- return 0;
- }
-
- // Response
- OpenTrustletResponse response;
- response.set_id(trustlet.sid);
- if (!response.SerializeToString(&buffer)) {
- LOG_E("Failed to serialize");
- return -EPIPE;
- }
- LOG_D("session %x open", trustlet.sid);
- session_ = new Session(trustlet.sid, tci_ptr.release());
- return static_cast<int>(buffer.length());
-}
-
-int ServerConnection::closeSession(std::string& buffer, int& method_rc) {
- // Request
- CloseSessionRequest request;
- if (!request.ParseFromString(buffer)) {
- LOG_E("Failed to parse");
- return -EPIPE;
- }
- if (!request.has_id()) {
- LOG_E("Required parameter missing");
- return -EINVAL;
- }
- // Check session
- std::lock_guard<std::mutex> connection_lock(connection_mutex);
- if (!session_) {
- LOG_E("No session");
- return -ENOENT;
- }
-
- // Call
- if (driver.closeSession(request.id())) {
- method_rc = errno;
- LOG_D("Error reported %s", strerror(errno));
- return 0;
- }
-
- // No response
- LOG_D("session %x closed", request.id());
- delete session_;
- session_ = nullptr;
- return 0;
-}
-
-int ServerConnection::notify(std::string& buffer, int& method_rc) {
- // Request
- NotifyRequest request;
- if (!request.ParseFromString(buffer)) {
- LOG_E("Failed to parse");
- return -EPIPE;
- }
- // Check session
- std::lock_guard<std::mutex> connection_lock(connection_mutex);
- if (!session_) {
- LOG_E("No session");
- return -ENOENT;
- }
- if (!request.has_sid() || (session_->hasTci() && !request.has_tci())) {
- LOG_E("Required parameter missing");
- return -EINVAL;
- }
- // Update TCI
- if (session_->hasTci() && session_->updateTci(request.tci())) {
- LOG_E("Failed to update TCI");
- return -EINVAL;
- }
- // Update mapped buffers
- if (request.buffers_size() > static_cast<int>(session_->buffers().size())) {
- LOG_E("Too many buffers: %d > %zu", request.buffers_size(),
- session_->buffers().size());
- return -EINVAL;
- }
- for (int i = 0; i < request.buffers_size(); i++) {
- const NotifyRequest_Buffers& session_buffer = request.buffers(i);
- if (!session_buffer.has_sva()) {
- LOG_E("Given buffer has no SVA");
- return -EINVAL;
- }
- if (!session_buffer.has_data()) {
- LOG_E("Given buffer has no data");
- return -EINVAL;
- }
- auto buf = session_->findBuffer(session_buffer.sva());
- if (!buf) {
- LOG_E("No buffer record for SVA %jx in session %x",
- session_buffer.sva(), request.sid());
- return -EPIPE;
- }
- buf->update(session_buffer.data());
- }
-
- // Call
- if (driver.notify(request.sid())) {
- method_rc = errno;
- return 0;
- }
-
- // No response
- LOG_D("session %x notification sent", request.sid());
- return 0;
-}
-
-int ServerConnection::waitNotification(std::string& buffer, int& method_rc) {
- // Request
- WaitNotificationRequest request;
- if (!request.ParseFromString(buffer)) {
- LOG_E("Failed to parse");
- return -EPIPE;
- }
- if (!request.has_sid() || !request.has_timeout() ||
- !request.has_partial()) {
- LOG_E("Required parameter missing");
- return -EINVAL;
- }
- // Refuse big timeouts (client shall retry so we know it's still around)
- if ((request.timeout() < 0) || (request.timeout() > timeout_max)) {
- LOG_E("Timeout exceeds 10s");
- return -ENOENT;
- }
-
- // Find session
- LOG_D("session %x wait for notification", request.sid());
- // Check session
- std::lock_guard<std::mutex> connection_lock(connection_mutex);
- if (!session_) {
- LOG_E("No session");
- return -ENOENT;
- }
- // Call driver
- struct mc_ioctl_wait wait;
- wait.sid = request.sid();
- wait.timeout = request.timeout();
-
- // Call
- if (driver.waitNotification(wait)) {
- method_rc = errno;
- if ((errno == ETIME) && request.partial()) {
- // No point sending buffers on partial timeout
- return 0;
- }
- // Send potentially modified buffers back on failure too
- LOG_ERRNO("waitNotification");
- }
-
- // Response
- WaitNotificationResponse response;
- // Send updated TCI
- if (session_->hasTci()) {
- response.set_tci(session_->tci(), session_->tciLen());
- }
- // Send updated mapped buffers
- auto& buffers = session_->buffers();
- for (auto& buf: buffers) {
- if (buf->info().flags & MC_IO_MAP_OUTPUT) {
- auto session_buffer = response.add_buffers();
- session_buffer->set_sva(buf->info().sva);
- session_buffer->set_data(buf->address(), buf->info().len);
- }
- }
- if (!response.SerializeToString(&buffer)) {
- LOG_E("Failed to serialize");
- return -EPIPE;
- }
- LOG_D("session %x notification received", request.sid());
- return static_cast<int>(buffer.length());
-}
-
-int ServerConnection::map(std::string& buffer, int& method_rc) {
- // Request
- MapRequest request;
- if (!request.ParseFromString(buffer)) {
- LOG_E("Failed to parse");
- return -EPIPE;
- }
- if (!request.has_sid()) {
- LOG_E("Required parameter missing");
- return -EINVAL;
- }
- // Check session
- std::lock_guard<std::mutex> connection_lock(connection_mutex);
- if (!session_) {
- LOG_E("No session");
- return -ENOENT;
- }
- if (request.buffers_size() > MC_MAP_MAX) {
- LOG_E("Incorrect number of buffers: %d > %d", request.buffers_size(),
- MC_MAP_MAX);
- return -EINVAL;
- }
- // Prepare local buffers
- struct mc_ioctl_map map;
- map.sid = request.sid();
- LOG_D("map %d buffers to session %x", request.buffers_size(), map.sid);
- std::vector<std::unique_ptr<Session::Buffer>> buffers;
- for (int i = 0; i < request.buffers_size(); i++) {
- const MapRequest_Buffers& session_buffer = request.buffers(i);
- if (!session_buffer.has_len() || !session_buffer.has_flags()) {
- LOG_E("Required parameter missing");
- return -EINVAL;
- }
- if (!(session_buffer.flags() & MC_IO_MAP_INPUT_OUTPUT) ||
- (session_buffer.flags() & ~MC_IO_MAP_INPUT_OUTPUT)) {
- LOG_E("Incorrect flags for buffer: %x", session_buffer.flags());
- return -EINVAL;
- }
- buffers.emplace_back(new Session::Buffer(session_buffer.len(),
- session_buffer.flags()));
- map.bufs[i] = buffers.back()->info();
- }
- for (int i = request.buffers_size(); i < MC_MAP_MAX; i++) {
- map.bufs[i].va = 0;
- }
-
- // Call
- if (driver.map(map)) {
- method_rc = errno;
- LOG_D("Error reported %s", strerror(errno));
- return 0;
- }
-
- // Response
- MapResponse response;
- // Confirm/return buffers
- for (int i = 0; i < request.buffers_size(); i++) {
- Session::Buffer* buf = buffers[i].release();
- buf->setSva(map.bufs[i].sva);
- session_->addBuffer(buf);
- auto session_buffer = response.add_buffers();
- session_buffer->set_sva(map.bufs[i].sva);
- }
- if (!response.SerializeToString(&buffer)) {
- LOG_E("Failed to serialize");
- return -EPIPE;
- }
- LOG_D("session %x %d buffer(s) mapped", map.sid, request.buffers_size());
- return static_cast<int>(buffer.length());
-}
-
-int ServerConnection::unmap(std::string& buffer, int& method_rc) {
- // Request
- UnmapRequest request;
- if (!request.ParseFromString(buffer)) {
- LOG_E("Failed to parse");
- return -EPIPE;
- }
- if (!request.has_sid()) {
- LOG_E("Required parameter missing");
- return -EINVAL;
- }
- if (request.buffers_size() > MC_MAP_MAX) {
- LOG_E("Incorrect number of buffers: %d", request.buffers_size());
- return -EINVAL;
- }
- // Check session
- std::lock_guard<std::mutex> connection_lock(connection_mutex);
- if (!session_) {
- LOG_E("No session");
- return -ENOENT;
- }
- // Find local buffers
- struct mc_ioctl_map map;
- map.sid = request.sid();
- LOG_D("unmap %d buffers from session %x", request.buffers_size(), map.sid);
- if (request.buffers_size() > static_cast<int>(session_->buffers().size())) {
- LOG_E("More buffers to unmap than we have: %d > %zu",
- request.buffers_size(), session_->buffers().size());
- return -EINVAL;
- }
- std::vector<Session::Buffer*> buffers;
- for (int i = 0; i < request.buffers_size(); i++) {
- // Need to find buffer to get VA/length
- const UnmapRequest_Buffers& session_buffer = request.buffers(i);
- if (!session_buffer.has_sva()) {
- LOG_E("Given buffer has no SVA");
- return -EINVAL;
- }
- auto buf = session_->findBuffer(session_buffer.sva());
- if (!buf) {
- LOG_E("No buffer record for SVA %jx in session %x",
- session_buffer.sva(), request.sid());
- method_rc = EINVAL;
- return 0;
- }
- map.bufs[i] = buf->info();
- buffers.push_back(buf);
- }
- for (int i = request.buffers_size(); i < MC_MAP_MAX; i++) {
- map.bufs[i].va = 0;
- }
-
- // Call
- if (driver.unmap(map)) {
- method_rc = errno;
- LOG_D("Error reported %s", strerror(errno));
- return 0;
- }
-
- // No response
- // Delete buffers
- for (size_t i = 0; i < buffers.size(); i++) {
- if (session_->removeBuffer(buffers[i]->info().sva)) {
- LOG_E("Did not find our buffer anymore!?!");
- return -EPIPE;
- }
- }
- LOG_D("session %x %d buffer(s) unmapped", map.sid, request.buffers_size());
- return 0;
-}
-
-int ServerConnection::getError(std::string& buffer, int& method_rc) {
- // Request
- GetErrorRequest request;
- if (!request.ParseFromString(buffer)) {
- LOG_E("Failed to parse");
- return -EPIPE;
- }
- if (!request.has_sid()) {
- LOG_E("Required parameter missing");
- return -EINVAL;
- }
- struct mc_ioctl_geterr err;
- err.sid = request.sid();
-
- // Call
- if (driver.getError(err)) {
- method_rc = errno;
- LOG_D("Error reported %s", strerror(errno));
- return 0;
- }
-
- // Response
- GetErrorResponse response;
- response.set_exit_code(err.value);
- if (!response.SerializeToString(&buffer)) {
- LOG_E("Failed to serialize");
- return -EPIPE;
- }
- LOG_D("session %x exit code %d", err.sid, err.value);
- return static_cast<int>(buffer.length());
-}
-
-int ServerConnection::getVersion(std::string& buffer, int& method_rc) {
- // Request
- GetVersionRequest request;
- if (!request.ParseFromString(buffer)) {
- LOG_E("Failed to parse");
- return -EPIPE;
- }
- // No inputs to check
- struct mc_version_info version_info;
-
- // Call
- if (driver.getVersion(version_info)) {
- method_rc = errno;
- LOG_D("Error reported %s", strerror(errno));
- return 0;
- }
-
- // Response
- GetVersionResponse response;
- response.set_product_id(version_info.product_id);
- response.set_mci(version_info.version_mci);
- response.set_so(version_info.version_so);
- response.set_mclf(version_info.version_mclf);
- response.set_container(version_info.version_container);
- response.set_mc_config(version_info.version_mc_config);
- response.set_tl_api(version_info.version_tl_api);
- response.set_dr_api(version_info.version_dr_api);
- response.set_nwd(version_info.version_nwd);
- if (!response.SerializeToString(&buffer)) {
- LOG_E("Failed to serialize");
- return -EPIPE;
- }
- return static_cast<int>(buffer.length());
-}
-
-int ServerConnection::gpRequestCancellation(std::string& buffer,
- int& method_rc) {
- // Request
- GetErrorRequest request;
- if (!request.ParseFromString(buffer)) {
- LOG_E("Failed to parse");
- return -EPIPE;
- }
- if (!request.has_sid()) {
- LOG_E("Required parameter missing");
- return -EINVAL;
- }
-
- // Call
- if (driver.gpRequestCancellation(request.sid())) {
- method_rc = errno;
- LOG_D("Error reported %s", strerror(errno));
- return 0;
- }
-
- // No response
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include "Mci/mcinq.h" /* TA termination codes */
-
-#undef LOG_TAG
-#define LOG_TAG "TeeGpClient"
-#include "log.h"
-#include "common_client.h"
-#include "tee_client_api.h"
-#include "GpTci.h" /* Needs stuff from tee_client_api.h or its includes */
-
-//------------------------------------------------------------------------------
-// Macros
-#define _TEEC_GET_PARAM_TYPE(t, i) (((t) >> (4*i)) & 0xF)
-
-//Parameter number
-#define _TEEC_PARAMETER_NUMBER 4
-
-/**
- * These error codes are still to be decided by GP and as we do not wish to
- * expose any part of the GP TAF as of yet, for now they will have to live here
- * until we decide what to do about them.
- */
-#define TEEC_ERROR_TA_LOCKED 0xFFFF0257
-#define TEEC_ERROR_SD_BLOCKED 0xFFFF0258
-#define TEEC_ERROR_TARGET_KILLED 0xFFFF0259
-
-static const size_t page_size = static_cast<size_t>(sysconf(_SC_PAGESIZE));
-static CommonClient& client = CommonClient::getInstance();
-
-//------------------------------------------------------------------------------
-// Local functions
-static TEEC_Result _TEEC_UnwindOperation(
- TEEC_Session_IMP* session,
- _TEEC_TCI* tci,
- TEEC_Operation* operation,
- bool copyValues,
- uint32_t* returnOrigin);
-
-//------------------------------------------------------------------------------
-static void _libUuidToArray(
- const TEEC_UUID* uuid,
- uint8_t* uuidArr) {
- uint8_t* pIdentifierCursor = (uint8_t*)uuid;
- /* offsets and syntax constants. See explanations above */
-#ifdef S_BIG_ENDIAN
- uint32_t offsets = 0;
-#else
- uint32_t offsets = 0xF1F1DF13;
-#endif
- uint32_t i;
-
- for (i = 0; i < sizeof(TEEC_UUID); i++) {
- /* Two-digit hex number */
- uint8_t number;
- int32_t offset = ((int32_t)((offsets & 0xF) << 28)) >> 28;
- number = pIdentifierCursor[offset];
- offsets >>= 4;
- pIdentifierCursor++;
-
- uuidArr[i] = number;
- }
-}
-
-//------------------------------------------------------------------------------
-static TEEC_Result _TEEC_SetupOperation(
- TEEC_Session_IMP* session,
- _TEEC_TCI* tci,
- TEEC_Operation* operation,
- uint32_t* returnOrigin) {
- uint32_t i;
- _TEEC_ParameterInternal* imp;
- TEEC_Parameter* ext;
- TEEC_Result teecResult = TEEC_SUCCESS;
-
- LOG_D(" %s()", __func__);
-
- tci->operation.isCancelled = false;
- tci->operation.paramTypes = 0;
-
- //operation can be NULL
- if (operation) {
- uint32_t n_buf = 0;
- operation->started = 1;
- // Buffers to map to SWd
- struct mc_ioctl_map map;
- map.sid = session->sessionId;
- // Operation parameters for the buffers above
- _TEEC_ParameterInternal* imps[_TEEC_PARAMETER_NUMBER] = { NULL };
-
- //This design allows a non-NULL buffer with a size of 0 bytes to allow trivial integration with any
- //implementations of the C library malloc, in which is valid to allocate a zero byte buffer and receive a non-
- //NULL pointer which may not be de-referenced in return.
-
- for (i = 0; i < _TEEC_PARAMETER_NUMBER && teecResult == TEEC_SUCCESS; i++) {
- uint8_t paramType = _TEEC_GET_PARAM_TYPE(operation->paramTypes, i);
-
- imp = &tci->operation.params[i];
- ext = &operation->params[i];
-
- switch (paramType) {
- case TEEC_VALUE_OUTPUT:
- LOG_D(" cycle %d, TEEC_VALUE_OUTPUT", i);
- break;
- case TEEC_NONE:
- LOG_D(" cycle %d, TEEC_NONE", i);
- break;
- case TEEC_VALUE_INPUT:
- case TEEC_VALUE_INOUT: {
- LOG_D(" cycle %d, TEEC_VALUE_IN*", i);
- imp->value.a = ext->value.a;
- imp->value.b = ext->value.b;
- break;
- }
- case TEEC_MEMREF_TEMP_INPUT:
- case TEEC_MEMREF_TEMP_OUTPUT:
- case TEEC_MEMREF_TEMP_INOUT: {
- // A Temporary Memory Reference may be null, which can be used
- // to denote a special case for the parameter. Output Memory
- // References that are null are typically used to request the
- // required output size.
- LOG_D(" cycle %d, TEEC_MEMREF_TEMP_*", i);
- if ((ext->tmpref.size) && (ext->tmpref.buffer)) {
- map.bufs[n_buf].va = (uintptr_t)ext->tmpref.buffer;
- map.bufs[n_buf].len = (uint32_t)ext->tmpref.size;
- map.bufs[n_buf].flags = paramType & TEEC_MEM_INOUT;
- imps[n_buf] = imp;
- n_buf++;
- } else {
- LOG_D(" cycle %d, TEEC_TEMP_IN* - zero pointer or size", i);
- }
- break;
- }
- case TEEC_MEMREF_WHOLE: {
- LOG_D(" cycle %d, TEEC_MEMREF_WHOLE", i);
- if (ext->memref.parent->size) {
- map.bufs[n_buf].va = (uintptr_t)ext->memref.parent->buffer;
- map.bufs[n_buf].len = (uint32_t)ext->memref.parent->size;
- map.bufs[n_buf].flags = ext->memref.parent->flags & TEEC_MEM_INOUT;
- imps[n_buf] = imp;
- n_buf++;
- }
- /* We don't transmit that the mem ref is the whole shared mem */
- /* Magic number 4 means that it is a mem ref */
- paramType = (uint8_t)ext->memref.parent->flags | 4;
- break;
- }
- case TEEC_MEMREF_PARTIAL_INPUT:
- case TEEC_MEMREF_PARTIAL_OUTPUT:
- case TEEC_MEMREF_PARTIAL_INOUT: {
- LOG_D(" cycle %d, TEEC_MEMREF_PARTIAL_*", i);
- //Check data flow consistency
- if ((((ext->memref.parent->flags & TEEC_MEM_INOUT) == TEEC_MEM_INPUT) &&
- (paramType == TEEC_MEMREF_PARTIAL_OUTPUT)) ||
- (((ext->memref.parent->flags & TEEC_MEM_INOUT) == TEEC_MEM_OUTPUT) &&
- (paramType == TEEC_MEMREF_PARTIAL_INPUT))) {
- LOG_E("PARTIAL data flow inconsistency");
- *returnOrigin = TEEC_ORIGIN_API;
- teecResult = TEEC_ERROR_BAD_PARAMETERS;
- break;
- }
- /* We don't transmit that the mem ref is partial */
- paramType &= TEEC_MEMREF_TEMP_INOUT;
-
- if (ext->memref.offset + ext->memref.size > ext->memref.parent->size) {
- LOG_E("PARTIAL offset/size error");
- *returnOrigin = TEEC_ORIGIN_API;
- teecResult = TEEC_ERROR_BAD_PARAMETERS;
- break;
- }
- if (ext->memref.size) {
- map.bufs[n_buf].va = (uintptr_t)ext->memref.parent->buffer + ext->memref.offset;
- map.bufs[n_buf].len = (uint32_t)ext->memref.size;
- map.bufs[n_buf].flags = paramType & TEEC_MEM_INOUT;
- imps[n_buf] = imp;
- n_buf++;
- }
- break;
- }
- default:
- LOG_E("cycle %d, default", i);
- *returnOrigin = TEEC_ORIGIN_API;
- teecResult = TEEC_ERROR_BAD_PARAMETERS;
- break;
- }
- tci->operation.paramTypes |= (uint32_t)(paramType << i * 4);
- }
-
- if (n_buf > MC_MAP_MAX) {
- LOG_E("too many buffers: %s", strerror(errno));
- teecResult = TEEC_ERROR_EXCESS_DATA;
- }
-
- if ((teecResult == TEEC_SUCCESS) && (tci->operation.isCancelled)) {
- LOG_E("the operation has been cancelled in COMMS");
- *returnOrigin = TEEC_ORIGIN_COMMS;
- teecResult = TEEC_ERROR_CANCEL;
- }
-
- // Map buffers
- if ((teecResult == TEEC_SUCCESS) && (n_buf > 0)) {
- for (i = n_buf; i < MC_MAP_MAX; i++) {
- map.bufs[i].va = 0;
- }
- if (client.map(map) == 0) {
- for (i = 0; i < MC_MAP_MAX; i++) {
- if (map.bufs[i].va) {
- imps[i]->memref.sVirtualAddr = (uint32_t)map.bufs[i].sva;
- imps[i]->memref.sVirtualLen = map.bufs[i].len;
- }
- }
- } else {
- LOG_E("client map failed: %s", strerror(errno));
- *returnOrigin = TEEC_ORIGIN_COMMS;
- teecResult = TEEC_ERROR_GENERIC;
- }
- }
-
- if (teecResult != TEEC_SUCCESS) {
- uint32_t retOrigIgnored;
- _TEEC_UnwindOperation(session, tci, operation, false, &retOrigIgnored);
- //Zeroing out tci->operation
- ::memset(&tci->operation, 0, sizeof(tci->operation));
- return teecResult;
- }
- }
-
- //Copy version indicator field
- ::memcpy(tci->header, "TCIGP000", sizeof(tci->header));
-
- // Fill in invalid values for secure world to overwrite
- tci->returnStatus = TEEC_ERROR_BAD_STATE;
-
- // Signal completion of request writing
- tci->ready = 1;
-
- return teecResult;
-}
-
-//------------------------------------------------------------------------------
-static TEEC_Result _TEEC_UnwindOperation(
- TEEC_Session_IMP* session,
- _TEEC_TCI* tci,
- TEEC_Operation* operation,
- bool copyValues,
- uint32_t* returnOrigin) {
- uint32_t i;
- _TEEC_ParameterInternal* imp;
- TEEC_Parameter* ext;
- uint32_t n_buf = 0;
-
- //operation can be NULL
- if (operation == NULL) {
- return TEEC_SUCCESS;
- }
-
- LOG_D(" %s()", __func__);
-
- operation->started = 2;
- // Buffers to unmap from SWd
- struct mc_ioctl_map map;
- map.sid = session->sessionId;
- // Some sanity checks
- if (tci->returnOrigin == 0 ||
- ((tci->returnOrigin != TEEC_ORIGIN_TRUSTED_APP) &&
- (tci->returnStatus != TEEC_SUCCESS))) {
- *returnOrigin = TEEC_ORIGIN_COMMS;
- return TEEC_ERROR_COMMUNICATION;
- }
- *returnOrigin = tci->returnOrigin;
-
- //Clear sVirtualLen to unMap further
- for (i = 0; i < _TEEC_PARAMETER_NUMBER; i++) {
- imp = &tci->operation.params[i];
- ext = &operation->params[i];
-
- switch (_TEEC_GET_PARAM_TYPE(operation->paramTypes, i)) {
- case TEEC_VALUE_INPUT:
- LOG_D(" cycle %d, TEEC_VALUE_INPUT", i);
- break;
- case TEEC_NONE:
- LOG_D(" cycle %d, TEEC_NONE", i);
- break;
- case TEEC_VALUE_OUTPUT:
- case TEEC_VALUE_INOUT: {
- LOG_D(" cycle %d, TEEC_VALUE_*OUT", i);
- if (copyValues) {
- ext->value.a = imp->value.a;
- ext->value.b = imp->value.b;
- }
- break;
- }
- case TEEC_MEMREF_TEMP_OUTPUT:
- case TEEC_MEMREF_TEMP_INPUT:
- case TEEC_MEMREF_TEMP_INOUT: {
- LOG_D(" cycle %d, TEEC_TEMP*", i);
- if ((copyValues) &&
- (_TEEC_GET_PARAM_TYPE(operation->paramTypes, i) != TEEC_MEMREF_TEMP_INPUT)) {
- ext->tmpref.size = imp->memref.outputSize;
- }
- if (imp->memref.sVirtualLen > 0) {
- map.bufs[n_buf].va = (uintptr_t)ext->tmpref.buffer;
- map.bufs[n_buf].sva = imp->memref.sVirtualAddr;
- map.bufs[n_buf].len = imp->memref.sVirtualLen;
- n_buf++;
- }
- break;
- }
- case TEEC_MEMREF_WHOLE: {
- LOG_D(" cycle %d, TEEC_MEMREF_WHOLE", i);
- if ((copyValues) && (ext->memref.parent->flags != TEEC_MEM_INPUT)) {
- ext->memref.size = imp->memref.outputSize;
- }
- if (imp->memref.sVirtualLen > 0) {
- map.bufs[n_buf].va = (uintptr_t)ext->memref.parent->buffer;
- map.bufs[n_buf].sva = imp->memref.sVirtualAddr;
- map.bufs[n_buf].len = imp->memref.sVirtualLen;
- n_buf++;
- }
- break;
- }
-
- case TEEC_MEMREF_PARTIAL_OUTPUT:
- case TEEC_MEMREF_PARTIAL_INOUT:
- case TEEC_MEMREF_PARTIAL_INPUT: {
- LOG_D(" cycle %d, TEEC_MEMREF_PARTIAL*", i);
- if ((copyValues) &&
- (_TEEC_GET_PARAM_TYPE(operation->paramTypes, i) != TEEC_MEMREF_PARTIAL_INPUT)) {
- ext->memref.size = imp->memref.outputSize;
- }
- if (imp->memref.sVirtualLen > 0) {
- map.bufs[n_buf].va = (uintptr_t)ext->memref.parent->buffer + ext->memref.offset;
- map.bufs[n_buf].sva = imp->memref.sVirtualAddr;
- map.bufs[n_buf].len = imp->memref.sVirtualLen;
- n_buf++;
- }
- break;
- }
- default:
- LOG_E("cycle %d, bad parameter", i);
- break;
- }
- }
-
- if (n_buf > MC_MAP_MAX) {
- LOG_E("too many buffers: %s", strerror(errno));
- return TEEC_ERROR_EXCESS_DATA;
- }
-
- for (i = n_buf; i < MC_MAP_MAX; i++) {
- map.bufs[i].va = 0;
- }
-
- if (n_buf > 0) {
- // This function assumes that we cannot handle errors
- if (client.unmap(map) < 0) {
- LOG_E("client unmap failed: %s", strerror(errno));
- }
- }
-
- return tci->returnStatus;
-}
-
-//------------------------------------------------------------------------------
-//TEEC_InitializeContext: TEEC_SUCCESS, Another error code from Table 4-2.
-TEEC_Result TEEC_InitializeContext(
- const char* name,
- TEEC_Context* context) {
- (void) name;
- LOG_D("== %s() ==============", __func__);
-
- if (context == NULL) {
- LOG_E("context is NULL");
- return TEEC_ERROR_BAD_PARAMETERS;
- }
-
- // For test purpose
- switch (context->imp.reserved) {
- case CommonClient::DRIVER:
- client.setOpenMode(CommonClient::DRIVER);
- break;
- case CommonClient::PROXY:
- client.setOpenMode(CommonClient::PROXY);
- break;
- }
-
- if (client.open()) {
- switch (errno) {
- case ENOENT:
- return TEEC_ERROR_COMMUNICATION;
- case EINVAL:
- return TEEC_ERROR_BAD_PARAMETERS;
- default:
- return TEEC_ERROR_GENERIC;
- }
- }
-
- return TEEC_SUCCESS;
-}
-
-//------------------------------------------------------------------------------
-//TEEC_FinalizeContext: void
-
-// The implementation of this function MUST NOT be able to fail: after this function returns the Client
-// Application must be able to consider that the Context has been closed.
-
-void TEEC_FinalizeContext(
- TEEC_Context* context) {
- LOG_D("== %s() ==============", __func__);
-
- // The parameter context MUST point to an initialized TEE Context.
- if (context == NULL) {
- LOG_E("context is NULL");
- return;
- }
-
- // The implementation of this function MUST NOT be able to fail: after this function returns the Client
- // Application must be able to consider that the Context has been closed.
- if (client.close()) {
- LOG_E("mcCloseDevice failed: %s", strerror(errno));
- /* continue even in case of error */;
- }
-}
-
-static void _TEEC_DeleteTci(TEEC_Session_IMP* session_imp) {
- if (session_imp->tci) {
- ::munmap(session_imp->tci, page_size);
- session_imp->tci = NULL;
- }
-}
-
-static void _TEEC_CloseSession(TEEC_Session_IMP* session_imp) {
- if (client.closeSession(session_imp->sessionId)) {
- LOG_E("%s failed: %s", __func__, strerror(errno));
- }
- session_imp->active = false;
-}
-
-//------------------------------------------------------------------------------
-static TEEC_Result _TEEC_CallTA(
- TEEC_Session_IMP* session,
- TEEC_Operation* operation,
- uint32_t* returnOrigin) {
- TEEC_Result teecRes;
- TEEC_Result teecError = TEEC_SUCCESS;
- int ret = 0;
-
- LOG_D(" %s()", __func__);
-
- // Phase 1: start the operation and wait for the result
- _TEEC_TCI* tci = static_cast<_TEEC_TCI*>(session->tci);
- teecRes = _TEEC_SetupOperation(session, tci, operation, returnOrigin);
- if (teecRes != TEEC_SUCCESS ) {
- LOG_E("_TEEC_SetupOperation failed (%08x)", teecRes);
- return teecRes;
- }
-
- // Signal the Trusted App
- ret = client.notify(session->sessionId);
- if (ret) {
- LOG_E("Notify failed: %s", strerror(errno));
- teecError = TEEC_ERROR_COMMUNICATION;
- } else {
- // -------------------------------------------------------------
- // Wait for the Trusted App response
- struct mc_ioctl_wait wait;
- wait.sid = session->sessionId;
- wait.timeout = -1;
- ret = client.waitNotification(wait);
- if (ret) {
- teecError = TEEC_ERROR_COMMUNICATION;
- if (errno == ECOMM) {
- struct mc_ioctl_geterr err;
- err.sid = session->sessionId;
-
- ret = client.getError(err);
- switch (err.value) {
- case TA_EXIT_CODE_FINISHED:
- // We may get here if the TA_OpenSessionEntryPoint returns an error and TA goes fast through DestroyEntryPoint and exits the TA.
- teecError = TEEC_SUCCESS;
- break;
- case ERR_SESSION_KILLED:
- teecError = TEEC_ERROR_TARGET_KILLED;
- break;
- case ERR_INVALID_SID:
- case ERR_SID_NOT_ACTIVE:
- LOG_E("mcWaitNotification failed: %s", strerror(errno));
- LOG_E("mcGetSessionErrorCode returned %d", err.value);
- break;
- default:
- LOG_E("Target is DEAD");
- *returnOrigin = TEEC_ORIGIN_TEE;
- teecError = TEEC_ERROR_TARGET_DEAD;
- break;
- }
- }
- }
- }
- // Phase 2: Return values and cleanup
- // unmap memory and copy values if no error
- teecRes = _TEEC_UnwindOperation(session, tci, operation,
- (teecError == TEEC_SUCCESS), returnOrigin);
- if (teecRes != TEEC_SUCCESS ) {
- LOG_E("_TEEC_UnwindOperation (%08x)", teecRes);
- /* continue even in case of error */;
- }
-
- // Cleanup
- if (teecError != TEEC_SUCCESS) {
- if (teecError == TEEC_ERROR_COMMUNICATION) {
- *returnOrigin = TEEC_ORIGIN_COMMS;
- }
- // Previous interactions failed, either TA is dead or communication error
- _TEEC_CloseSession(session);
- _TEEC_DeleteTci(session);
- }
- return teecError;
-}
-
-//------------------------------------------------------------------------------
-//TEEC_OpenSession: if the returnOrigin is different from TEEC_ORIGIN_TRUSTED_APP, an error code from Table 4-2
-// If the returnOrigin is equal to TEEC_ORIGIN_TRUSTED_APP, a return code defined by the
-//protocol between the Client Application and the Trusted Application.
-TEEC_Result TEEC_OpenSession (
- TEEC_Context* context,
- TEEC_Session* session,
- const TEEC_UUID* destination,
- uint32_t connectionMethod,
- const void* connectionData,
- TEEC_Operation* operation,
- uint32_t* returnOrigin) {
- TEEC_Result teecRes;
- uint32_t returnOrigin_local = TEEC_ORIGIN_API;
- struct mc_uuid_t tauuid;
- int ret = 0;
-
- LOG_D("== %s() ==============", __func__);
- // -------------------------------------------------------------
- //The parameter context MUST point to an initialized TEE Context.
- if (context == NULL) {
- LOG_E("context is NULL");
- if (returnOrigin) {
- *returnOrigin = TEEC_ORIGIN_API;
- }
- return TEEC_ERROR_BAD_PARAMETERS;
- }
-
- if (session == NULL) {
- LOG_E("session is NULL");
- if (returnOrigin) {
- *returnOrigin = TEEC_ORIGIN_API;
- }
- return TEEC_ERROR_BAD_PARAMETERS;
- }
-
- if ((connectionMethod != TEEC_LOGIN_PUBLIC) &&
- (connectionMethod != TEEC_LOGIN_USER) &&
- (connectionMethod != TEEC_LOGIN_GROUP) &&
- (connectionMethod != TEEC_LOGIN_APPLICATION) &&
- (connectionMethod != TEEC_LOGIN_USER_APPLICATION) &&
- (connectionMethod != TEEC_LOGIN_GROUP_APPLICATION)) {
- LOG_E("connectionMethod not supported");
- if (returnOrigin) {
- *returnOrigin = TEEC_ORIGIN_API;
- }
- return TEEC_ERROR_NOT_IMPLEMENTED;
- }
-
- if ((TEEC_LOGIN_GROUP == connectionMethod) ||
- (TEEC_LOGIN_GROUP_APPLICATION == connectionMethod)) {
- if (NULL == connectionData) {
- LOG_E("connectionData is NULL");
- if (returnOrigin) {
- *returnOrigin = TEEC_ORIGIN_API;
- }
- return TEEC_ERROR_BAD_PARAMETERS;
- }
- }
-
- // -------------------------------------------------------------
- session->imp.active = false;
-
- _libUuidToArray(destination, tauuid.value);
-
- if (operation) {
- operation->imp.session = &session->imp;
- }
-
- //Allocate a 4kB page with mmap, zero it out, and set session->imp.tci to its address.
- session->imp.tci = NULL;
- void* bulkBuf = (void*)::mmap(0, page_size, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- if (bulkBuf == MAP_FAILED) {
- LOG_E("mmap failed on tci buffer allocation");
- if (returnOrigin) {
- *returnOrigin = TEEC_ORIGIN_API;
- }
- return TEEC_ERROR_OUT_OF_MEMORY;
- }
-
- session->imp.tci = bulkBuf;
- ::memset(session->imp.tci, 0, page_size);
-
- ::pthread_mutex_init(&session->imp.mutex_tci, NULL);
- ::pthread_mutex_lock(&session->imp.mutex_tci);
-
- //Fill the TCI buffer session.tci with the destination UUID.
- _TEEC_TCI* tci = static_cast<_TEEC_TCI*>(session->imp.tci);
- ::memcpy(&tci->destination, destination, sizeof(tci->destination));
- // -------------------------------------------------------------
- struct mc_ioctl_open_session sess;
- sess.sid = 0;
- sess.tci = (uintptr_t)tci;
- sess.tcilen = sizeof(_TEEC_TCI);
- sess.uuid = tauuid;
- sess.is_gp_uuid = 1;
- sess.identity.login_type = static_cast<mc_login_type>(connectionMethod);
- sess.identity.pid = 0;
- if (connectionData) {
- ::memcpy(&sess.identity.login_data, connectionData,
- sizeof(sess.identity.login_data));
- }
-
- ret = client.openSession(sess);
- if (ret) {
- LOG_E("%s failed: %s", __func__, strerror(errno));
- if (returnOrigin) {
- *returnOrigin = TEEC_ORIGIN_COMMS;
- }
- switch (errno) {
- case ENOENT:
- teecRes = TEEC_ERROR_ITEM_NOT_FOUND;
- break;
- case EACCES:
- teecRes = TEEC_ERROR_ACCESS_DENIED;
- break;
- case EINVAL:
- teecRes = TEEC_ERROR_NOT_IMPLEMENTED;
- break;
- case ENOSPC:
- teecRes = TEEC_ERROR_OUT_OF_MEMORY;
- break;
- case ECONNREFUSED:
- teecRes = TEEC_ERROR_SD_BLOCKED;
- break;
- case ECONNABORTED:
- teecRes = TEEC_ERROR_TA_LOCKED;
- break;
- case ECONNRESET:
- teecRes = TEEC_ERROR_TARGET_KILLED;
- break;
- case EBUSY:
- teecRes = TEEC_ERROR_BUSY;
- break;
- default:
- teecRes = TEEC_ERROR_GENERIC;
- }
- goto error;
- }
-
- session->imp.context = context->imp;
- session->imp.sessionId = sess.sid;
- session->imp.active = true;
- LOG_I(" created session ID %x", session->imp.sessionId);
-
- // Let TA go through entry points
- LOG_D(" let TA go through entry points");
- tci->operation.type = _TA_OPERATION_OPEN_SESSION;
- teecRes = _TEEC_CallTA(&session->imp, operation, &returnOrigin_local);
-
- // Check for error on communication level
- if (teecRes != TEEC_SUCCESS ) {
- LOG_E("_TEEC_CallTA failed(%08x)", teecRes);
- // Nothing to do here because _TEEC_CallTA closes broken sessions
- if (returnOrigin) {
- *returnOrigin = returnOrigin_local;
- }
- goto error;
- }
- LOG_D(" no errors in com layer");
-
- // Check for error from TA
- if (returnOrigin) {
- *returnOrigin = tci->returnOrigin;
- }
- teecRes = tci->returnStatus;
- if (teecRes != TEEC_SUCCESS ) {
- LOG_E("TA OpenSession EP failed(%08x)", teecRes);
- goto error;
- }
-
- LOG_D(" %s() = TEEC_SUCCESS ", __func__);
- ::pthread_mutex_unlock(&session->imp.mutex_tci);
-
- if (returnOrigin) {
- *returnOrigin = TEEC_ORIGIN_TRUSTED_APP;
- }
- return TEEC_SUCCESS;
-
- // -------------------------------------------------------------
-error:
- if (session->imp.active) {
- // After notifying us, TA went to Destry EP, so close session now
- _TEEC_CloseSession(&session->imp);
- }
-
- ::pthread_mutex_unlock(&session->imp.mutex_tci);
- ::pthread_mutex_destroy(&session->imp.mutex_tci);
- _TEEC_DeleteTci(&session->imp);
-
- LOG_D(" %s() = 0x%x", __func__, teecRes);
- return teecRes;
-}
-
-//------------------------------------------------------------------------------
-TEEC_Result TEEC_InvokeCommand(
- TEEC_Session* session,
- uint32_t commandID,
- TEEC_Operation* operation,
- uint32_t* returnOrigin) {
- TEEC_Result teecRes;
- uint32_t returnOrigin_local = TEEC_ORIGIN_API;
-
- LOG_D("== %s() ==============", __func__);
-
- // -------------------------------------------------------------
- if (session == NULL) {
- LOG_E("session is NULL");
- if (returnOrigin) {
- *returnOrigin = TEEC_ORIGIN_API;
- }
- return TEEC_ERROR_BAD_PARAMETERS;
- }
-
- if (!session->imp.active) {
- LOG_E("session is inactive");
- if (returnOrigin) {
- *returnOrigin = TEEC_ORIGIN_API;
- }
- return TEEC_ERROR_BAD_STATE;
- }
- // -------------------------------------------------------------
- if (operation) {
- operation->imp.session = &session->imp;
- }
-
- ::pthread_mutex_lock(&session->imp.mutex_tci);
-
- // Call TA
- _TEEC_TCI* tci = static_cast<_TEEC_TCI*>(session->imp.tci);
- tci->operation.commandId = commandID;
- tci->operation.type = _TA_OPERATION_INVOKE_COMMAND;
- teecRes = _TEEC_CallTA(&session->imp, operation, &returnOrigin_local);
- if (teecRes != TEEC_SUCCESS ) {
- LOG_E("_TEEC_CallTA failed(%08x)", teecRes);
- if (returnOrigin) {
- *returnOrigin = returnOrigin_local;
- }
- } else {
- if (returnOrigin) {
- *returnOrigin = tci->returnOrigin;
- }
- teecRes = tci->returnStatus;
- }
-
- ::pthread_mutex_unlock(&session->imp.mutex_tci);
- LOG_D(" %s() = 0x%x", __func__, teecRes);
- return teecRes;
-}
-
-//------------------------------------------------------------------------------
-void TEEC_CloseSession(TEEC_Session* session) {
- TEEC_Result teecRes = TEEC_SUCCESS;
- uint32_t returnOrigin;
-
- LOG_D("== %s() ==============", __func__);
-
- // -------------------------------------------------------------
- //The Implementation MUST do nothing if the session parameter is NULL.
- if (session == NULL) {
- LOG_E("session is NULL");
- return;
- }
-
- // -------------------------------------------------------------
- if (session->imp.active) {
- // Let TA go through CloseSession and Destroy entry points
- LOG_D(" let TA go through close entry points");
- ::pthread_mutex_lock(&session->imp.mutex_tci);
- _TEEC_TCI* tci = static_cast<_TEEC_TCI*>(session->imp.tci);
- tci->operation.type = _TA_OPERATION_CLOSE_SESSION;
- teecRes = _TEEC_CallTA(&session->imp, NULL, &returnOrigin);
- if (teecRes != TEEC_SUCCESS ) {
- /* continue even in case of error */;
- LOG_E("_TEEC_CallTA failed(%08x)", teecRes);
- }
-
- if (session->imp.active) {
- _TEEC_CloseSession(&session->imp);
- }
- ::pthread_mutex_unlock(&session->imp.mutex_tci);
- }
-
- ::pthread_mutex_destroy(&session->imp.mutex_tci);
- _TEEC_DeleteTci(&session->imp);
-
- LOG_D(" %s() = 0x%x", __func__, teecRes);
-}
-
-//------------------------------------------------------------------------------
-TEEC_Result TEEC_RegisterSharedMemory(
- TEEC_Context* context,
- TEEC_SharedMemory* sharedMem) {
- LOG_D("== %s() ==============", __func__);
-
- //The parameter context MUST point to an initialized TEE Context.
- if (context == NULL) {
- LOG_E("context is NULL");
- return TEEC_ERROR_BAD_PARAMETERS;
- }
- //The parameter sharedMem MUST point to the Shared Memory structure defining
- //the memory region to register.
- if (sharedMem == NULL) {
- LOG_E("sharedMem is NULL");
- return TEEC_ERROR_BAD_PARAMETERS;
- }
- //The buffer field MUST point to the memory region to be shared, and MUST not be NULL.
- if (sharedMem->buffer == NULL) {
- LOG_E("sharedMem->buffer is NULL");
- return TEEC_ERROR_BAD_PARAMETERS;
- }
- if ((static_cast<int>(sharedMem->flags) & ~TEEC_MEM_INOUT)) {
- LOG_E("sharedMem->flags is incorrect");
- return TEEC_ERROR_BAD_PARAMETERS;
- }
- if (sharedMem->flags == 0) {
- LOG_E("sharedMem->flags is incorrect");
- return TEEC_ERROR_BAD_PARAMETERS;
- }
-
- sharedMem->imp.implementation_allocated = false;
- return TEEC_SUCCESS;
-}
-
-//------------------------------------------------------------------------------
-TEEC_Result TEEC_AllocateSharedMemory(
- TEEC_Context* context,
- TEEC_SharedMemory* sharedMem) {
- //No connection to "context"?
- LOG_D("== %s() ==============", __func__);
-
- //The parameter context MUST point to an initialized TEE Context.
- if (context == NULL) {
- LOG_E("context is NULL");
- return TEEC_ERROR_BAD_PARAMETERS;
- }
- //The parameter sharedMem MUST point to the Shared Memory structure defining
- //the memory region to register.
- if (sharedMem == NULL) {
- LOG_E("sharedMem is NULL");
- return TEEC_ERROR_BAD_PARAMETERS;
- }
- if (static_cast<int>(sharedMem->flags) & ~TEEC_MEM_INOUT) {
- LOG_E("sharedMem->flags is incorrect");
- return TEEC_ERROR_BAD_PARAMETERS;
- }
- if (sharedMem->flags == 0) {
- LOG_E("sharedMem->flags is incorrect");
- return TEEC_ERROR_BAD_PARAMETERS;
- }
-
- sharedMem->buffer = malloc(sharedMem->size);
- if (sharedMem->buffer == NULL) {
- LOG_E("malloc failed");
- return TEEC_ERROR_OUT_OF_MEMORY;
- }
- sharedMem->imp.implementation_allocated = true;
-
- return TEEC_SUCCESS;
-}
-
-//------------------------------------------------------------------------------
-void TEEC_ReleaseSharedMemory (
- TEEC_SharedMemory* sharedMem) {
- //No connection to "context"?
- LOG_D("== %s() ==============", __func__);
-
- //The Implementation MUST do nothing if the sharedMem parameter is NULL
- if (sharedMem == NULL) {
- LOG_E("sharedMem is NULL");
- return;
- }
-
- //For a memory buffer allocated using TEEC_AllocateSharedMemory the Implementation
- //MUST free the underlying memory
- if (sharedMem->imp.implementation_allocated) {
- if (sharedMem->buffer) {
- free(sharedMem->buffer);
- sharedMem->buffer = NULL;
- sharedMem->size = 0;
- }
- }
-}
-
-//------------------------------------------------------------------------------
-void TEEC_RequestCancellation(
- TEEC_Operation* operation) {
- LOG_D("== %s() ==============", __func__);
-
- while (operation->started == 0);
-
- LOG_D("while(operation->started ==0) passed");
-
- if (operation->started > 1) {
- LOG_D("The operation has finished");
- return;
- }
-
- TEEC_Session_IMP* session = operation->imp.session;
- operation->started = 2;
-
- if (!session->active) {
- LOG_D("Corresponding session is not active");
- return;
- }
-
- if (client.gpRequestCancellation(session->sessionId)) {
- LOG_ERRNO("gpRequestCancellation");
- }
-}
-
-//------------------------------------------------------------------------------
+++ /dev/null
-# =============================================================================
-#
-# MobiCore Android build components
-#
-# =============================================================================
-
-LOCAL_PATH := $(call my-dir)
-
-# Registry Shared Library
-# =============================================================================
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libMcRegistry
-LOCAL_MODULE_TAGS := eng
-
-LOCAL_CFLAGS += -DLOG_TAG=\"McRegistry\"
-LOCAL_CFLAGS += -Wall -Wextra
-LOCAL_CFLAGS += -DLOG_ANDROID
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
-LOCAL_SHARED_LIBRARIES := libMcClient
-ifeq ($(APP_PROJECT_PATH),)
-LOCAL_SHARED_LIBRARIES += liblog
-else
-# Local build
-LOCAL_LDLIBS := -llog
-endif
-
-LOCAL_SRC_FILES := \
- src/Connection.cpp \
- src/Registry.cpp
-
-LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDES)
-
-include $(BUILD_SHARED_LIBRARY)
-
-# Daemon Application
-# =============================================================================
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := mcDriverDaemon
-LOCAL_MODULE_TAGS := eng
-LOCAL_CFLAGS += -DLOG_TAG=\"McDaemon\"
-LOCAL_CFLAGS += -DTBASE_API_LEVEL=5
-LOCAL_CFLAGS += -Wall -Wextra
-LOCAL_CFLAGS += -std=c++11
-LOCAL_CFLAGS += -DLOG_ANDROID
-ifdef TRUSTONIC_ANDROID_LEGACY_SUPPORT
-LOCAL_CFLAGS += -DWITHOUT_PROXY
-endif # TRUSTONIC_ANDROID_LEGACY_SUPPORT
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
-LOCAL_STATIC_LIBRARIES := libMcClient_static
-ifeq ($(APP_PROJECT_PATH),)
-LOCAL_SHARED_LIBRARIES += \
- liblog
-
-ifdef TRUSTONIC_ANDROID_LEGACY_SUPPORT
-include external/stlport/libstlport.mk
-
-LOCAL_C_INCLUDES += \
- external/stlport/stlport
-
-LOCAL_SHARED_LIBRARIES += \
- libstlport
-else # TRUSTONIC_ANDROID_LEGACY_SUPPORT
-LOCAL_STATIC_LIBRARIES += \
- libMcProxy
-
-LOCAL_SHARED_LIBRARIES += \
- libprotobuf-cpp-lite \
- libcutils
-
-endif # !TRUSTONIC_ANDROID_LEGACY_SUPPORT
-else # !NDK
-# Local build
-LOCAL_LDLIBS := -llog
-ifndef TRUSTONIC_ANDROID_LEGACY_SUPPORT
-LOCAL_CFLAGS += -static-libstdc++
-
-LOCAL_STATIC_LIBRARIES += \
- libMcProxy \
- libprotobuf-cpp-lite
-endif # !TRUSTONIC_ANDROID_LEGACY_SUPPORT
-endif # NDK
-
-LOCAL_SRC_FILES := \
- src/Connection.cpp \
- src/CThread.cpp \
- src/MobiCoreDriverDaemon.cpp \
- src/SecureWorld.cpp \
- src/FSD2.cpp \
- src/Server.cpp \
- src/PrivateRegistry.cpp
-
-include $(BUILD_EXECUTABLE)
-
-ifndef TRUSTONIC_ANDROID_LEGACY_SUPPORT
-
-# Static version of the daemon for recovery
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := mcDriverDaemon_static
-LOCAL_MODULE_TAGS := eng
-LOCAL_CFLAGS += -DLOG_TAG=\"McDaemon\"
-LOCAL_CFLAGS += -DTBASE_API_LEVEL=5
-LOCAL_CFLAGS += -Wall -Wextra
-LOCAL_CFLAGS += -std=c++11
-LOCAL_CFLAGS += -DLOG_ANDROID
-LOCAL_CFLAGS += -DWITHOUT_FSD
-LOCAL_CFLAGS += -DWITHOUT_PROXY
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
-LOCAL_STATIC_LIBRARIES := libMcClient_static
-ifeq ($(APP_PROJECT_PATH),)
-LOCAL_STATIC_LIBRARIES += \
- liblog libc libc++_static libcutils
-
-else # !NDK
-# Local build
-LOCAL_LDLIBS := -llog
-endif # NDK
-
-LOCAL_SRC_FILES := \
- src/Connection.cpp \
- src/CThread.cpp \
- src/MobiCoreDriverDaemon.cpp \
- src/SecureWorld.cpp \
- src/Server.cpp \
- src/PrivateRegistry.cpp
-
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-
-include $(BUILD_EXECUTABLE)
-
-endif # !TRUSTONIC_ANDROID_LEGACY_SUPPORT
-
-# adding the root folder to the search path appears to make absolute paths
-# work for import-module - lets see how long this works and what surprises
-# future developers get from this.
-$(call import-add-path,/)
-$(call import-module,$(COMP_PATH_MobiCoreClientLib_module))
-$(call import-module,$(COMP_PATH_AndroidProtoBuf))
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef MOBICORE_REGISTRY_H_
-#define MOBICORE_REGISTRY_H_
-
-#include "MobiCoreDriverApi.h"
-#include "mcContainer.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /** Stores an authentication token in registry.
- * @param so Authentication token secure object.
- * @param size Authentication token object size
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryStoreAuthToken(void *so, uint32_t size);
-
- /** Reads an authentication token from registry.
- * @param[out] so Authentication token secure object.
- * @param[out] size Authentication token secure object size
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryReadAuthToken(void *so, uint32_t *size);
-
- /** Deletes the authentication token secure object from the registry.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryDeleteAuthToken(void);
-
- /** Stores a root container secure object in the registry.
- * @param so Root container secure object.
- * @param size Root container secure object size
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryStoreRoot(void *so, uint32_t size);
-
- /** Reads a root container secure object from the registry.
- * @param[out] so Root container secure object.
- * @param[out] size Root container secure object size
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryReadRoot(void *so, uint32_t *size);
-
- /** Stores a service provider container secure object in the registry.
- * @param spid Service provider ID.
- * @param so Service provider container secure object.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryStoreSp(mcSpid_t spid, void *so, uint32_t size);
-
- /** Reads a service provider container secure object from the registry.
- * @param spid Service provider ID.
- * @param[out] so Service provider container secure object.
- * @param[out] size Service provider container secure object size
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryReadSp(mcSpid_t spid, void *so, uint32_t *size);
-
- /** Deletes a service provider recursively, including all trustlets and
- * data.
- * @param spid Service provider ID.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryCleanupSp(mcSpid_t spid);
-
- /** Stores a trustlet container secure object in the registry.
- * @param uuid Trustlet UUID.
- * @param spid SPID of the trustlet container.
- * @param so Trustlet container secure object.
- * @param size Trustlet container secure object size.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t size);
-
- /** Reads a trustlet container secure object from the registry.
- * @param uuid Trustlet UUID.
- * @param spid SPID of the trustlet container
- * @param[out] so Trustlet container secure object.
- * @param[out] size Trustlet container secure object size
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryReadTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t *size);
-
- /** Deletes a trustlet container secure object and all of its associated data.
- * @param uuid Trustlet UUID.
- * @param spid Service provider ID
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryCleanupTrustlet(const mcUuid_t *uuid, const mcSpid_t spid);
-
- /**
- * mcRegistryCleanupTA()
- *
- * Removes all associated data of a TA (when uninstalled)
- *
- * @param [in] uuid the UUID to clean up all files belonging too
- * @retrurn MC_DRV_OK is successful, othwise an error code from mcResult_t
- */
- mcResult_t mcRegistryCleanupTA(const mcUuid_t *uuid);
-
- /** Deletes the root container and all of its associated service provider
- * containers.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryCleanupRoot(void);
-
- /** Stores a Trustlet Application blob in the registry.
- * @param spid SPID of the trustlet container.
- * @param blob Trustlet Application blob.
- * @param size Trustlet Application blob size.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, void *blob, uint32_t size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // MOBICORE_REGISTRY_H_
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/**
- * Thread implementation (pthread abstraction).
- */
-
-#include <signal.h>
-
-#include <log.h>
-
-#include "CThread.h"
-
-//------------------------------------------------------------------------------
-static void* thread_startup(void *arg) {
- reinterpret_cast<CThread*>(arg)->run();
- return NULL;
-}
-
-//------------------------------------------------------------------------------
-void CThread::terminate() {
- m_terminate = true;
-}
-
-//------------------------------------------------------------------------------
-bool CThread::shouldTerminate() {
- return m_terminate;
-}
-
-//------------------------------------------------------------------------------
-void CThread::start(const char* name) {
- int ret;
- ret = pthread_create(&m_thread, NULL, thread_startup, this);
- if (0 != ret)
- LOG_E("pthread_create failed with error code %d", ret);
-
- ret = pthread_setname_np(m_thread, name);
- if (0 != ret)
- LOG_E("pthread_setname_np failed with error code %d %s", ret, name);
-}
-
-//------------------------------------------------------------------------------
-void CThread::join() {
- int ret;
- ret = pthread_join(m_thread, NULL);
- if (0 != ret)
- LOG_E("pthread_join failed with error code %d", ret);
-}
-
-//------------------------------------------------------------------------------
-int CThread::kill(int sig) {
- return pthread_kill(m_thread, sig);
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef CTHREAD_H_
-#define CTHREAD_H_
-
-#include <pthread.h>
-
-class CThread {
-public:
- // m_thread value does not matter, only initialised for code checkers
- CThread(): m_terminate(false), m_thread(pthread_self()) {}
- virtual ~CThread() {}
- virtual void run() = 0;
- void start(const char* name);
- void join();
- void terminate();
- int kill(int sig);
-protected:
- bool shouldTerminate();
-private:
- bool m_terminate;
- pthread_t m_thread;
-};
-
-#endif /*CTHREAD_H_*/
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/**
- * Connection data.
- */
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <assert.h>
-#include <cstring>
-#include <errno.h>
-#include <poll.h>
-#include <log.h>
-#include <sys/un.h>
-
-#include "Connection.h"
-
-//------------------------------------------------------------------------------
-Connection::Connection(void):
- m_socket(-1)
-{
-}
-
-//------------------------------------------------------------------------------
-Connection::Connection(int socketDescriptor):
- m_socket(socketDescriptor)
-{
- assert(-1 != socketDescriptor);
-}
-
-//------------------------------------------------------------------------------
-Connection::~Connection(void)
-{
- LOG_D("closing Connection... fd=%i", m_socket);
- if (m_socket != -1) {
- int ret = ::close(m_socket);
- if(ret)
- LOG_ERRNO("close");
- }
- LOG_D(" Socket connection closed.");
-}
-
-//------------------------------------------------------------------------------
-bool Connection::connect(const char *dest)
-{
- if (m_socket >= 0) {
- LOG_E("Already connected");
- return false;
- }
-
- struct sockaddr_un sockaddr; /**< Remote address */
- memset(&sockaddr, 0, sizeof(sockaddr));
- sockaddr.sun_family = AF_UNIX;
- if (sizeof(sockaddr.sun_path) - 1 < strlen(dest)) {
- LOG_E("Invalid destination socket %s", dest);
- return false;
- }
-
- LOG_D("Connecting to %s socket", dest);
- sockaddr.sun_family = AF_UNIX;
- memset(sockaddr.sun_path, 0, sizeof(sockaddr.sun_path));
- strncpy(sockaddr.sun_path, dest, strlen(dest));
-
- m_socket = ::socket(AF_UNIX, SOCK_STREAM, 0);
- if (m_socket < 0) {
- LOG_ERRNO("Can't open stream socket.");
- return false;
- }
-
- socklen_t len = static_cast<socklen_t>(strlen(sockaddr.sun_path) + sizeof(sockaddr.sun_family));
- // The Daemon socket is in the Abstract Domain(LINUX ONLY!)
- sockaddr.sun_path[0] = 0;
- if (::connect(m_socket, reinterpret_cast<struct sockaddr*>(&sockaddr), len) < 0) {
- LOG_ERRNO("connect()");
- return false;
- }
-
- return true;
-}
-
-//------------------------------------------------------------------------------
-ssize_t Connection::readData(void *buffer, uint32_t len, int32_t timeout)
-{
- ssize_t ret = 0;
- struct timeval tv;
- struct timeval *ptv = NULL;
- fd_set readfds;
-
- if (timeout >= 0) {
- // Calculate timeout value
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
- ptv = &tv;
- }
-
- FD_ZERO(&readfds);
- FD_SET(m_socket, &readfds);
- ret = select(m_socket + 1, &readfds, NULL, NULL, ptv);
-
- // check for read error
- if (ret == -1) {
- LOG_ERRNO("select");
- return -1;
- }
-
- // Handle case of no descriptor ready
- if (ret == 0) {
- LOG_W("Timeout during select() / No more notifications.");
- return -2;
- }
-
- // one or more descriptors are ready
-
- // finally check if fd has been selected -> must socketDescriptor
- if (!FD_ISSET(m_socket, &readfds)) {
- LOG_ERRNO("no fd is set, select");
- return ret;
- }
-
- ret = recv(m_socket, buffer, len, MSG_DONTWAIT);
- if (ret == 0)
- LOG_D(" readData(): peer orderly closed connection.");
-
- return ret;
-}
-
-ssize_t Connection::readMsg(const iovec *iov, uint32_t nr_seg, int32_t timeout)
-{
- ssize_t ret = -1;
- struct msghdr msg;
- struct timeval tv;
- struct timeval *ptv = NULL;
- fd_set readfds;
-
- memset(&msg, 0, sizeof(msg));
- msg.msg_name = NULL;
- msg.msg_namelen = 0;
- msg.msg_iov = const_cast<iovec *>(iov);
- msg.msg_iovlen = nr_seg;
- msg.msg_control = NULL;
- msg.msg_controllen = 0;
-
- if (timeout >= 0) {
- // Calculate timeout value
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
- ptv = &tv;
- }
-
- FD_ZERO(&readfds);
- FD_SET(m_socket, &readfds);
- ret = select(m_socket + 1, &readfds, NULL, NULL, ptv);
-
- // check for read error
- if (ret == -1) {
- LOG_ERRNO("select");
- return -1;
- }
-
- // Handle case of no descriptor ready
- if (ret == 0) {
- LOG_W("Timeout during select() / No more notifications.");
- return -2;
- }
-
- // one or more descriptors are ready
-
- // finally check if fd has been selected -> must socketDescriptor
- if (!FD_ISSET(m_socket, &readfds)) {
- LOG_ERRNO("no fd is set, select");
- return ret;
- }
-
- ret = recvmsg(m_socket, &msg, MSG_DONTWAIT);
- if (ret == 0)
- LOG_D("readData(): peer orderly closed connection.");
-
- return ret;
-}
-
-
-//------------------------------------------------------------------------------
-ssize_t Connection::writeData(const void *buffer, uint32_t len)
-{
- const char *cbuf = static_cast<const char*>(buffer);
- uint32_t left = len;
- while (left) {
- ssize_t wlen = ::send(m_socket, cbuf, left, 0);
- if (wlen < 0) {
- LOG_ERRNO("writeData");
- return -1;
- }
- if (wlen == 0) {
- LOG_E("Client closed the connection");
- return -1;
- }
- left -= wlen;
- cbuf += wlen;
- }
- return len;
-}
-
-ssize_t Connection::writeMsg(const iovec *iov, uint32_t nr_seg)
-{
- ssize_t ret = -1, len;
- struct msghdr msg;
-
- memset(&msg, 0, sizeof(msg));
- msg.msg_name = NULL;
- msg.msg_namelen = 0;
- msg.msg_iov = const_cast<iovec *>(iov);
- msg.msg_iovlen = nr_seg;
- msg.msg_control = NULL;
- msg.msg_controllen = 0;
-
- for( len = 0; nr_seg > 0; nr_seg--, iov++)
- len += iov->iov_len;
-
- ret = sendmsg(m_socket, &msg, 0);
- if (ret != len) {
- LOG_E("%s: could not send all data, ret=%zd, errno: %d (%s)",
- __FUNCTION__, ret, errno, strerror(errno));
- ret = -1;
- }
-
- return ret;
-}
-
-//------------------------------------------------------------------------------
-int Connection::waitData(int32_t timeout)
-{
- int ret;
- struct timeval tv;
- struct timeval *ptv = NULL;
- fd_set readfds;
-
- if (timeout >= 0) {
- // Calculate timeout value
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
- ptv = &tv;
- }
-
- FD_ZERO(&readfds);
- FD_SET(m_socket, &readfds);
- ret = select(m_socket + 1, &readfds, NULL, NULL, ptv);
-
- // check for read error
- if (ret == -1) {
- LOG_ERRNO("select");
- return ret;
- } else if (ret == 0) {
- LOG_E("select() timed out");
- return -1;
- }
-
- return 0;
-}
-
-//------------------------------------------------------------------------------
-bool Connection::isConnectionAlive(void)
-{
- int retval;
- struct pollfd ufds[1];
- ufds[0].fd = m_socket;
- ufds[0].events = POLLRDHUP;
-
- retval = poll(ufds, 1, 10);
- if (retval < 0 || retval > 0) {
- LOG_ERRNO("poll");
- return false;
- }
- return true;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef CONNECTION_H_
-#define CONNECTION_H_
-
-#include <sys/socket.h> // iovec
-
-class Connection
-{
-public:
- Connection(void);
- Connection(int socketDescriptor);
-
- ~Connection(void);
-
- /**
- * Connect to destination.
- *
- * @param Destination pointer.
- * @return true on success.
- */
- bool connect(const char *dest);
-
- /**
- * Read bytes from the connection.
- *
- * @param buffer Pointer to destination buffer.
- * @param len Number of bytes to read.
- * @param timeout Timeout in milliseconds
- * @return Number of bytes read.
- * @return -1 if select() failed (returned -1)
- * @return -2 if no data available, i.e. timeout
- */
- ssize_t readData(void *buffer, uint32_t len, int32_t timeout = -1);
- ssize_t readMsg(const iovec *iov, uint32_t nr_seg, int32_t timeout = -1);
- /**
- * Write bytes to the connection.
- *
- * @param buffer Pointer to source buffer.
- * @param len Number of bytes to read.
- * @return Number of bytes written.
- * @return -1 if written bytes not equal to len.
- */
- ssize_t writeData(const void *buffer, uint32_t len);
- ssize_t writeMsg(const iovec *iov, uint32_t nr_seg);
-
- /**
- * Wait for data to be available.
- *
- * @param timeout Timeout in milliseconds
- * @return 0 if data is available
- * @return error code if otherwise
- */
- int waitData(int32_t timeout);
-
- /*
- * Checks if the socket is still connected to the daemon
- *
- * @return true if connection is still alive.
- */
- bool isConnectionAlive(void);
-
- int socket() const
- {
- return m_socket;
- }
-
-private:
- int m_socket; /**< Local socket descriptor */
-};
-
-#endif /* CONNECTION_H_ */
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef CONNECTIONHANDLER_H_
-#define CONNECTIONHANDLER_H_
-
-#include "Connection.h"
-
-class ConnectionHandler
-{
-
-public:
- virtual ~ConnectionHandler() {};
-
- /**
- * Handle connection activities.
- * The connection handler shall process pending connection activities.
- *
- * @param [in] connection Reference to the connection which
- * has data to process.
- */
- virtual bool handleConnection(Connection &connection) = 0;
-
- /**
- * Connection has been closed.
- * The connection handler shall clean up all resources associated with
- * the given connection. After the method has been executed the connection
- * object will be deleted.
- *
- * @param [in] connection Reference to the connection which will be deleted.
- */
- virtual void dropConnection(Connection &connection) = 0;
-};
-
-#endif /* CONNECTIONHANDLER_H_ */
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * Filesystem v2 delegate.
- *
- * Handles incoming storage requests from TA through STH
- */
-
-#include <unistd.h>
-#include <string>
-#include <cstring>
-#include <errno.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <memory>
-#include <stdio.h>
-#include <assert.h>
-#include <pthread.h>
-#include <sys/stat.h>
-
-#undef LOG_TAG
-#define LOG_TAG "TeeFilesystem"
-#include <log.h>
-#include "tee_client_api.h" /* TEEC_Result */
-#include "MobiCoreDriverApi.h" /* MC session */
-#include "sth2ProxyApi.h"
-#include "sfs_error.h"
-#include "FSD2.h"
-
-#define MAX_SECTOR_SIZE 4096
-#define SECTOR_NUM 8
-#define SFS_L2_CACHE_SLOT_SPACE 12 // Hard coded size, cf. sfs_internal.h
-#define DEFAULT_WORKSPACE_SIZE (SECTOR_NUM * (MAX_SECTOR_SIZE + SFS_L2_CACHE_SLOT_SPACE))
-
-extern const std::string& getTbStoragePath();
-
-/*----------------------------------------------------------------------------
- * Utilities functions
- *----------------------------------------------------------------------------*/
-static TEEC_Result errno2serror() {
- switch (errno) {
- case EINVAL:
- return S_ERROR_BAD_PARAMETERS;
- case EMFILE:
- return S_ERROR_NO_MORE_HANDLES;
- case ENOENT:
- return S_ERROR_ITEM_NOT_FOUND;
- case EEXIST:
- return S_ERROR_ITEM_EXISTS;
- case ENOSPC:
- return S_ERROR_STORAGE_NO_SPACE;
- case ENOMEM:
- return S_ERROR_OUT_OF_MEMORY;
- case EBADF:
- case EACCES:
- default:
- return S_ERROR_STORAGE_UNREACHABLE;
- }
-}
-
-class Partition {
- std::string name_;
- FILE* fd_;
- off_t size_;
-public:
- Partition(std::string name): name_(name), fd_(NULL), size_(0) {}
- const char* name() const {
- return name_.c_str();
- }
- off_t size() {
- if (size_ == 0) {
- struct stat st;
- if (::stat(name(), &st)) {
- return -1;
- }
- size_ = st.st_size;
- }
- return size_;
- }
- TEEC_Result create() {
- LOG_I("%s: Create storage file \"%s\"", __func__, name());
- fd_ = ::fopen(name(), "w+b");
- if (!fd_) {
- LOG_E("%s: %s creating storage file \"%s\"", __func__,
- strerror(errno), name());
- return errno2serror();
- }
- return S_SUCCESS;
- }
- TEEC_Result destroy() {
- if (!fd_) {
- /* The partition is not open */
- return S_ERROR_BAD_STATE;
- }
-
- /* Try to erase the file */
- if (::unlink(name())) {
- /* File in use or OS didn't allow the operation */
- return errno2serror();
- }
-
- return S_SUCCESS;
- }
- TEEC_Result open() {
- /* Open the file */
- LOG_I("%s: Open storage file \"%s\"", __func__, name());
- fd_ = ::fopen(name(), "r+b");
- if (!fd_) {
- LOG_E("%s: %s opening storage file \"%s\"", __func__,
- strerror(errno), name());
- return errno2serror();
- }
- LOG_I("%s: storage file \"%s\" successfully open (size: %ld KB / %ld B))",
- __func__, name(), size() / 1024, size());
- return S_SUCCESS;
- }
- TEEC_Result close() {
- if (!fd_) {
- /* The partition is not open */
- return S_ERROR_BAD_STATE;
- }
-
- ::fclose(fd_);
- fd_ = NULL;
-
- return S_SUCCESS;
- }
- TEEC_Result read(uint8_t* buf, uint32_t length, uint32_t offset) {
- if (!fd_) {
- /* The partition is not open */
- return S_ERROR_BAD_STATE;
- }
-
- if (::fseek(fd_, offset, SEEK_SET)) {
- LOG_E("%s: fseek error: %s", __func__, strerror(errno));
- return errno2serror();
- }
-
- if (::fread(buf, length, 1, fd_) != 1) {
- if (feof(fd_)) {
- LOG_E("%s: fread error: End-Of-File detected", __func__);
- return S_ERROR_ITEM_NOT_FOUND;
- }
- LOG_E("%s: fread error: %s", __func__, strerror(errno));
- return errno2serror();
- }
-
- return S_SUCCESS;
- }
- TEEC_Result write(const uint8_t* buf, uint32_t length, uint32_t offset) {
- if (!fd_) {
- /* The partition is not open */
- return S_ERROR_BAD_STATE;
- }
-
- if (::fseek(fd_, offset, SEEK_SET)) {
- LOG_E("%s: fseek error: %s", __func__, strerror(errno));
- return errno2serror();
- }
-
- if (::fwrite(buf, length, 1, fd_) != 1) {
- LOG_E("%s: fwrite error: %s", __func__, strerror(errno));
- return errno2serror();
- }
- return S_SUCCESS;
- }
- TEEC_Result sync() {
- if (!fd_) {
- /* The partition is not open */
- return S_ERROR_BAD_STATE;
- }
-
- /*
- * First make sure that the data in the stdio buffers is flushed to the
- * file descriptor
- */
- if (::fflush(fd_)) {
- return errno2serror();
- }
-
- /* Then synchronize the file descriptor with the file-system */
- if (::fdatasync(fileno(fd_))) {
- return errno2serror();
- }
-
- return S_SUCCESS;
- }
- TEEC_Result resize(off_t new_size) {
- if (!fd_) {
- /* The partition is not open */
- return S_ERROR_BAD_STATE;
- }
-
- if (new_size == size()) {
- return S_SUCCESS;
- }
-
- if (new_size > size()) {
- /*
- * Enlarge the partition file. Make sure we actually write some
- * non-zero data into the new sectors. Otherwise, some file-system
- * might not really reserve the storage space but use a sparse
- * representation. In this case, a subsequent write instruction
- * could fail due to out-of-space, which we want to avoid.
- */
- if (::fseek(fd_, 0, SEEK_END)) {
- LOG_E("%s: fseek error: %s", __func__, strerror(errno));
- return errno2serror();
- }
-
- off_t count = new_size - size();
- while (count) {
- if (::fputc(0xA5, fd_) != 0xA5) {
- LOG_E("%s: fputc error: %s", __func__, strerror(errno));
- return errno2serror();
- }
- count--;
- }
- } else {
- /* Truncate the partition file */
- if (::ftruncate(fileno(fd_), new_size)) {
- return errno2serror();
- }
- }
- // Update size
- size_ = new_size;
- return S_SUCCESS;
- }
-};
-
-struct FileSystem::Impl {
- pthread_t thread;
-
- /*
- * Communication buffer, includes the workspace
- */
- struct {
- STH2_delegation_exchange_buffer_t exchange_buffer;
- uint8_t workspace[DEFAULT_WORKSPACE_SIZE];
- } dci;
-
- /*
- * Provided by the SWd
- */
- uint32_t sector_size;
-
- /*
- * The 16 possible partitions
- */
- Partition* partitions[16];
-
- // thread value does not matter, only initialised for code checkers
- Impl(): thread(pthread_self()) {
- ::memset(&dci, 0, sizeof(dci));
- sector_size = 0;
- for (int i = 0; i < 16; i++) {
- partitions[i] = NULL;
- }
- }
- void run();
- int executeCommand();
- const char* getCommandtypeString(uint32_t nInstructionID);
-};
-
-FileSystem::FileSystem(): pimpl_(new Impl) {}
-
-FileSystem::~FileSystem() {
- delete pimpl_;
-}
-
-void* FileSystem::run(void* arg) {
- FileSystem::Impl* pimpl = static_cast<FileSystem::Impl*>(arg);
- pimpl->run();
- return NULL;
-}
-
-int FileSystem::open() {
- const std::string storage_dir_name = getTbStoragePath();
-
- // Create Tbase storage directory if necessary, parent is assumed to exist
- if (::mkdir(storage_dir_name.c_str(), 0700) && (errno != EEXIST)) {
- LOG_ERRNO("creating storage folder");
- // Do not return any error and block deamon boot flow or stop FSD thread.
- // Just print a "warning/not critical error message".
- // Directory could also be created by platform at initialization time.
- // return -1;
- }
-
- // Create partitions with default names
- for (int i = 0; i < 16; i++) {
- char file_name[16];
- snprintf(file_name, sizeof(file_name), "/Store_%1X.tf", i);
- pimpl_->partitions[i] = new Partition(storage_dir_name + file_name);
- }
-
- /* Prepare DCI message buffer */
- pimpl_->dci.exchange_buffer.nWorkspaceLength = DEFAULT_WORKSPACE_SIZE;
-
- // Create listening thread
- int ret = pthread_create(&pimpl_->thread, NULL, run, pimpl_);
- if (ret) {
- LOG_E("pthread_create failed with error code %d", ret);
- return -1;
- }
-
- pthread_setname_np(pimpl_->thread, "McDaemon.FileSystem");
- return 0;
-}
-
-int FileSystem::close() {
- // Stop listening thread
- pthread_kill(pimpl_->thread, SIGUSR1);
- pthread_join(pimpl_->thread, NULL);
-
- /* Clear DCI message buffer */
- ::memset(&pimpl_->dci, 0, sizeof(pimpl_->dci));
- return 0;
-}
-
-/*
- * main
- */
-void FileSystem::Impl::run() {
- // Only accept USR1, to give up
- sigset_t sigmask;
- sigemptyset(&sigmask);
- sigaddset(&sigmask, SIGUSR1);
- pthread_sigmask(SIG_UNBLOCK, &sigmask, (sigset_t*)0);
-
- mcResult_t mc_ret = mcOpenDevice(MC_DEVICE_ID_DEFAULT);
- if (MC_DRV_OK != mc_ret) {
- LOG_E("%s: mcOpenDevice returned: 0x%08X\n", __func__, mc_ret);
- return;
- }
-
- const mcUuid_t uuid = SERVICE_DELEGATION_UUID;
- mcSessionHandle_t session_handle;
- session_handle.deviceId = MC_DEVICE_ID_DEFAULT;
- mc_ret = mcOpenSession(&session_handle, &uuid, reinterpret_cast<uint8_t*>(&dci),
- sizeof(dci));
- if (MC_DRV_OK != mc_ret) {
- LOG_E("%s: mcOpenSession returned: 0x%08X\n", __func__, mc_ret);
- mcCloseDevice(MC_DEVICE_ID_DEFAULT);
- return;
- }
-
- LOG_I("%s: Start listening for request from STH2", __func__);
- while (true) {
- /* Wait for notification from SWd */
- LOG_D("%s: Waiting for notification\n", __func__);
- mc_ret = mcWaitNotification(&session_handle, MC_INFINITE_TIMEOUT_INTERRUPTIBLE);
- if (mc_ret != MC_DRV_OK) {
- LOG_E("%s: mcWaitNotification failed, error=0x%08X\n", __func__, mc_ret);
- break;
- }
-
- /* Read sector size */
- if (sector_size == 0) {
- sector_size = dci.exchange_buffer.nSectorSize;
- LOG_D("%s: Sector Size: %d bytes", __func__, sector_size);
-
- /* Check sector size */
- if (!(sector_size == 512 || sector_size == 1024 ||
- sector_size == 2048 || sector_size == 4096)) {
- LOG_E("%s: Incorrect sector size: terminating...", __func__);
- break;
- }
- }
-
- LOG_D("%s: Received Command from STH2\n", __func__);
- if (executeCommand()) {
- break;
- }
-
- /* Set "listening" flag before notifying SPT2 */
- dci.exchange_buffer.nDaemonState = STH2_DAEMON_LISTENING;
- mc_ret = mcNotify(&session_handle);
- if (mc_ret != MC_DRV_OK) {
- LOG_E("%s: mcNotify() returned: 0x%08X\n", __func__, mc_ret);
- break;
- }
- }
-
- mc_ret = mcCloseSession(&session_handle);
- if (MC_DRV_OK != mc_ret) {
- LOG_E("%s: mcCloseSession returned: 0x%08X\n", __func__, mc_ret);
- }
-
- mc_ret = mcCloseDevice(MC_DEVICE_ID_DEFAULT);
- if (MC_DRV_OK != mc_ret) {
- LOG_E("%s: mcCloseDevice returned: 0x%08X\n", __func__, mc_ret);
- }
-
- LOG_W("%s: Exiting Filesystem thread", __func__);
-}
-
-/*----------------------------------------------------------------------------
- * Instructions
- *----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
- * Command dispatcher function
- *----------------------------------------------------------------------------*/
-/* Debug function to show the command name */
-const char* FileSystem::Impl::getCommandtypeString(uint32_t nInstructionID) {
- switch (nInstructionID) {
- case DELEGATION_INSTRUCTION_PARTITION_CREATE:
- return "PARTITION_CREATE";
- case DELEGATION_INSTRUCTION_PARTITION_OPEN:
- return "PARTITION_OPEN";
- case DELEGATION_INSTRUCTION_PARTITION_READ:
- return "PARTITION_READ";
- case DELEGATION_INSTRUCTION_PARTITION_WRITE:
- return "PARTITION_WRITE";
- case DELEGATION_INSTRUCTION_PARTITION_SET_SIZE:
- return "PARTITION_SET_SIZE";
- case DELEGATION_INSTRUCTION_PARTITION_SYNC:
- return "PARTITION_SYNC";
- case DELEGATION_INSTRUCTION_PARTITION_CLOSE:
- return "PARTITION_CLOSE";
- case DELEGATION_INSTRUCTION_PARTITION_DESTROY:
- return "PARTITION_DESTROY";
- case DELEGATION_INSTRUCTION_SHUTDOWN:
- return "SHUTDOWN";
- case DELEGATION_INSTRUCTION_NOTIFY:
- return "NOTIFY";
- default:
- return "UNKNOWN";
- }
-}
-
-int FileSystem::Impl::executeCommand() {
- TEEC_Result nError;
- uint32_t nInstructionsIndex;
- uint32_t nInstructionsBufferSize =
- dci.exchange_buffer.nInstructionsBufferSize;
-
-
- LOG_D("%s: nInstructionsBufferSize=%d", __func__, nInstructionsBufferSize);
-
- /* Reset the operation results */
- nError = TEEC_SUCCESS;
- dci.exchange_buffer.sAdministrativeData.nSyncExecuted = 0;
- ::memset(dci.exchange_buffer.sAdministrativeData.nPartitionErrorStates, 0,
- sizeof(dci.exchange_buffer.sAdministrativeData.nPartitionErrorStates));
- ::memset(dci.exchange_buffer.sAdministrativeData.nPartitionOpenSizes, 0,
- sizeof(dci.exchange_buffer.sAdministrativeData.nPartitionOpenSizes));
-
- /* Execute the instructions */
- nInstructionsIndex = 0;
- while (true) {
- DELEGATION_INSTRUCTION* pInstruction;
- uint32_t nInstructionID;
- pInstruction = (DELEGATION_INSTRUCTION*)(
- &dci.exchange_buffer.sInstructions[nInstructionsIndex/4]);
- if (nInstructionsIndex + 4 > nInstructionsBufferSize) {
- LOG_D("%s: Instruction buffer end, size = %i", __func__,
- nInstructionsBufferSize);
- return 0;
- }
-
- nInstructionID = pInstruction->sGeneric.nInstructionID;
- nInstructionsIndex += 4;
-
- LOG_D("%s: nInstructionID=0x%02X [%s], nInstructionsIndex=%d", __func__,
- nInstructionID, getCommandtypeString(nInstructionID), nInstructionsIndex);
-
- if ((nInstructionID & 0x0F) == 0) {
- /* Partition-independent instruction */
- switch (nInstructionID) {
- case DELEGATION_INSTRUCTION_SHUTDOWN: {
- return 1;
- }
- case DELEGATION_INSTRUCTION_NOTIFY: {
- /* Parse the instruction parameters */
- wchar_t pMessage[100];
- uint32_t nMessageType;
- uint32_t nMessageSize;
- ::memset(pMessage, 0, 100*sizeof(wchar_t));
-
- if (nInstructionsIndex + 8 > nInstructionsBufferSize) {
- return 0;
- }
-
- nMessageType = pInstruction->sNotify.nMessageType;
- nMessageSize = pInstruction->sNotify.nMessageSize;
- nInstructionsIndex += 8;
- if (nMessageSize > (99)*sizeof(wchar_t)) {
- /* How to handle the error correctly in this case ? */
- return 0;
- }
-
- if (nInstructionsIndex + nMessageSize > nInstructionsBufferSize) {
- return 0;
- }
-
- ::memcpy(pMessage, &pInstruction->sNotify.nMessage[0], nMessageSize);
- nInstructionsIndex += nMessageSize;
- /* Align the pInstructionsIndex on 4 bytes */
- nInstructionsIndex = (nInstructionsIndex + 3)&~3;
- switch (nMessageType) {
- case DELEGATION_NOTIFY_TYPE_ERROR:
- LOG_E("%s: %ls", __func__, pMessage);
- break;
- case DELEGATION_NOTIFY_TYPE_WARNING:
- LOG_W("%s: %ls", __func__, pMessage);
- break;
- case DELEGATION_NOTIFY_TYPE_DEBUG:
- LOG_D("%s: DEBUG: %ls", __func__, pMessage);
- break;
- default:
- LOG_D("%s: %ls", __func__, pMessage);
- }
- break;
- }
- default: {
- LOG_E("%s: Unknown instruction identifier: %02X", __func__, nInstructionID);
- nError = S_ERROR_BAD_PARAMETERS;
- break;
- }
- }
- } else {
- /* Partition-specific instruction */
- uint32_t nPartitionID = (nInstructionID & 0xF0) >> 4;
- Partition* partition = partitions[nPartitionID];
- if (dci.exchange_buffer.sAdministrativeData.nPartitionErrorStates[nPartitionID]
- == S_SUCCESS) {
- /* Execute the instruction only if there is currently no error on the partition */
- switch (nInstructionID & 0x0F) {
- case DELEGATION_INSTRUCTION_PARTITION_CREATE: {
- nError = partition->create();
- LOG_D("%s: INSTRUCTION: ID=0x%x pid=%d err=0x%08X", __func__,
- (nInstructionID & 0x0F), nPartitionID, nError);
- break;
- }
- case DELEGATION_INSTRUCTION_PARTITION_OPEN: {
- nError = partition->open();
- LOG_D("%s: INSTRUCTION: ID=0x%x pid=%d pSize=%ld err=0x%08X", __func__,
- (nInstructionID & 0x0F), nPartitionID, partition->size() / sector_size,
- nError);
- if (nError == S_SUCCESS) {
- dci.exchange_buffer.sAdministrativeData.nPartitionOpenSizes[nPartitionID] =
- static_cast<unsigned int>(partition->size() / sector_size);
- }
- break;
- }
- case DELEGATION_INSTRUCTION_PARTITION_READ: {
- /* Parse parameters */
- uint32_t nSectorID;
- uint32_t nWorkspaceOffset;
- if (nInstructionsIndex + 8 > nInstructionsBufferSize) {
- return 0;
- }
-
- nSectorID = pInstruction->sReadWrite.nSectorID;
- nWorkspaceOffset = pInstruction->sReadWrite.nWorkspaceOffset;
- nInstructionsIndex += 8;
- LOG_D("%s: >Partition %1X: read sector 0x%08X into workspace at offset 0x%08X",
- __func__, nPartitionID, nSectorID, nWorkspaceOffset);
- nError = partition->read(dci.exchange_buffer.sWorkspace + nWorkspaceOffset,
- sector_size, nSectorID * sector_size);
- LOG_D("%s: INSTRUCTION: ID=0x%x pid=%d sid=%d woff=%d err=0x%08X", __func__,
- (nInstructionID & 0x0F), nPartitionID, nSectorID, nWorkspaceOffset, nError);
- break;
- }
- case DELEGATION_INSTRUCTION_PARTITION_WRITE: {
- /* Parse parameters */
- uint32_t nSectorID;
- uint32_t nWorkspaceOffset;
- if (nInstructionsIndex + 8 > nInstructionsBufferSize) {
- return 0;
- }
-
- nSectorID = pInstruction->sReadWrite.nSectorID;
- nWorkspaceOffset = pInstruction->sReadWrite.nWorkspaceOffset;
- nInstructionsIndex += 8;
- LOG_D("%s: >Partition %1X: write sector 0x%X from workspace at offset 0x%X",
- __func__, nPartitionID, nSectorID, nWorkspaceOffset);
- nError = partition->write(dci.exchange_buffer.sWorkspace + nWorkspaceOffset,
- sector_size, nSectorID * sector_size);
- LOG_D("%s: INSTRUCTION: ID=0x%x pid=%d sid=%d woff=%d err=0x%08X", __func__,
- (nInstructionID & 0x0F), nPartitionID, nSectorID, nWorkspaceOffset, nError);
- break;
- }
- case DELEGATION_INSTRUCTION_PARTITION_SYNC: {
- nError = partition->sync();
- LOG_D("%s: INSTRUCTION: ID=0x%x pid=%d err=0x%08X", __func__,
- (nInstructionID & 0x0F), nPartitionID, nError);
- if (nError == S_SUCCESS) {
- dci.exchange_buffer.sAdministrativeData.nSyncExecuted++;
- }
- break;
- }
- case DELEGATION_INSTRUCTION_PARTITION_SET_SIZE: {
- // nNewSize is a number of sectors
- uint32_t nNewSize;
- if (nInstructionsIndex + 4 > nInstructionsBufferSize) {
- return 0;
- }
-
- nNewSize = pInstruction->sSetSize.nNewSize;
- nInstructionsIndex += 4;
- nError = partition->resize(nNewSize * sector_size);
- LOG_D("%s: INSTRUCTION: ID=0x%x pid=%d nNewSize=%d err=0x%08X", __func__,
- (nInstructionID & 0x0F), nPartitionID, nNewSize, nError);
- break;
- }
- case DELEGATION_INSTRUCTION_PARTITION_CLOSE: {
- nError = partition->close();
- LOG_D("%s: INSTRUCTION: ID=0x%x pid=%d err=0x%08X", __func__,
- (nInstructionID & 0x0F), nPartitionID, nError);
- break;
- }
- case DELEGATION_INSTRUCTION_PARTITION_DESTROY: {
- nError = partition->destroy();
- LOG_D("%s: INSTRUCTION: ID=0x%x pid=%d err=0x%08X", __func__,
- (nInstructionID & 0x0F), nPartitionID, nError);
- break;
- }
- default: {
- LOG_E("%s: Unknown instruction identifier: %02X", __func__, nInstructionID);
- nError = S_ERROR_BAD_PARAMETERS;
- break;
- }
- }
- dci.exchange_buffer.sAdministrativeData.nPartitionErrorStates[nPartitionID] =
- nError;
- } else {
- /* Skip the instruction if there is currently error on the partition */
- switch (nInstructionID & 0x0F) {
- case DELEGATION_INSTRUCTION_PARTITION_CREATE:
- case DELEGATION_INSTRUCTION_PARTITION_OPEN:
- case DELEGATION_INSTRUCTION_PARTITION_SYNC:
- case DELEGATION_INSTRUCTION_PARTITION_CLOSE:
- case DELEGATION_INSTRUCTION_PARTITION_DESTROY:
- break;
- case DELEGATION_INSTRUCTION_PARTITION_READ:
- case DELEGATION_INSTRUCTION_PARTITION_WRITE: {
- if (nInstructionsIndex + 8 > nInstructionsBufferSize) {
- return 0;
- }
- nInstructionsIndex += 8;
- break;
- }
- case DELEGATION_INSTRUCTION_PARTITION_SET_SIZE: {
- if (nInstructionsIndex + 4 > nInstructionsBufferSize) {
- return 0;
- }
- nInstructionsIndex += 4;
- break;
- }
- default: {
- LOG_E("%s: Unknown instruction identifier: %02X", __func__, nInstructionID);
- /* OMS: update partition error with BAD PARAM ? */
- break;
- }
- }
- }
- }
- }
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FSD2_H_
-#define FSD2_H_
-
-class FileSystem {
- struct Impl;
- Impl* const pimpl_;
- // Until we can use std::thread everywhere
- static void* run(void* arg);
-public:
- /**
- * Constructor.
- */
- FileSystem();
- /**
- * Destructor.
- */
- ~FileSystem();
- /**
- * Ensure resources are available and start main thread.
- */
- int open();
- /**
- * Stop main thread and free resources.
- */
- int close();
-};
-
-#endif /* FSD2_H_ */
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MOBICORE_REGISTRY_API_H_
-#define MOBICORE_REGISTRY_API_H_
-
-#include "mcUuid.h"
-#include "mcSpid.h"
-
-#define SOCK_PATH "#mcdaemon"
-
-typedef enum {
- // Auth token OPS
- MC_DRV_REG_READ_AUTH_TOKEN = 0,
- MC_DRV_REG_WRITE_AUTH_TOKEN,
- MC_DRV_REG_DELETE_AUTH_TOKEN,
- // Root container OPS
- MC_DRV_REG_READ_ROOT_CONT,
- MC_DRV_REG_WRITE_ROOT_CONT,
- MC_DRV_REG_DELETE_ROOT_CONT,
- // Service Provider Container OPS
- MC_DRV_REG_READ_SP_CONT,
- MC_DRV_REG_WRITE_SP_CONT,
- MC_DRV_REG_DELETE_SP_CONT,
- // Trustlet Container OPS
- MC_DRV_REG_READ_TL_CONT,
- MC_DRV_REG_WRITE_TL_CONT,
- MC_DRV_REG_DELETE_TL_CONT,
- // Shared Object Data write
- MC_DRV_REG_WRITE_SO_DATA,
- // TA Blob store
- MC_DRV_REG_STORE_TA_BLOB,
- // Delete all TA objects
- MC_DRV_REG_DELETE_TA_OBJS,
-
- MC_DRV_REG_END
-} mcDrvCmd_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- /* id - free run counter managed by driver, initialized by
- * initial_cmd_counter, incremented for each command.
- * If difference between current value and value from previous command
- * is greater than 1, it means daemon and driver are out of synch. */
- uint32_t id;
- uint32_t cmd;
- uint32_t data_size;
-} CommandHeader;
-
-typedef struct {
- /* id - must be same value as it was in the corresponding command,
- * but managed by daemon */
- uint32_t id;
- uint32_t result;
- uint32_t data_size;
-} ResponseHeader;
-
-typedef struct {
- uint32_t len;
- uint32_t tl_start_off;
- uint8_t value[];
-} regObject_t;
-
-typedef struct {
- mcUuid_t uuid;
- mcSpid_t spid;
- uint8_t blob[];
-} TlBlob;
-
-typedef struct {
- mcSpid_t spid;
- uint8_t blob[];
-} TaBlob;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // MOBICORE_REGISTRY_API_H_
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <string.h>
-#include <signal.h>
-#include <libgen.h>
-
-#include <log.h>
-
-#include "cutils/properties.h"
-#include "mcVersion.h"
-#include "PrivateRegistry.h"
-#include "MobiCoreDriverDaemon.h"
-#include "buildTag.h"
-
-#define DRIVER_TCI_LEN 4096
-
-static SecureWorld* g_secure_world;
-
-//------------------------------------------------------------------------------
-/**
- * Print daemon command line options
- */
-static
-int printUsage(char *path)
-{
- fprintf(stderr, "<t-base Driver Daemon %u.%u. \"%s\" %s %s\n",
- DAEMON_VERSION_MAJOR, DAEMON_VERSION_MINOR,
- MOBICORE_COMPONENT_BUILD_TAG, __DATE__, __TIME__);
- fprintf(stderr, "usage: %s [-hbr]\n", basename(path));
- fprintf(stderr, "Start <t-base Daemon\n\n");
- fprintf(stderr, "-h\t\tshow this help\n");
- fprintf(stderr, "-b\t\tfork to background\n");
- fprintf(stderr, "-r DRIVER\t<t-base driver to load at start-up\n");
- return 2;
-}
-
-//------------------------------------------------------------------------------
-/**
- * Signal handler for daemon termination
- * Using this handler instead of the standard libc one ensures the daemon
- * can cleanup everything -> read() on a FD will now return EINTR
- */
-const MobiCoreDriverDaemon::cmd_map_item_t
-MobiCoreDriverDaemon::reg_cmd_map[] = {
- {
- &MobiCoreDriverDaemon::reg_read_auth_token,
- 0
- },
- {
- &MobiCoreDriverDaemon::reg_store_auth_token,
- 0
- },
- {
- &MobiCoreDriverDaemon::reg_delete_auth_token,
- 0
- },
- {
- &MobiCoreDriverDaemon::reg_read_root_cont,
- 0
- },
- {
- &MobiCoreDriverDaemon::reg_store_root_cont,
- 0
- },
- {
- &MobiCoreDriverDaemon::reg_delete_root_cont,
- 0
- },
- {
- &MobiCoreDriverDaemon::reg_read_sp_cont,
- sizeof(mcSpid_t)
- },
- {
- &MobiCoreDriverDaemon::reg_store_sp_cont,
- sizeof(TaBlob)
- },
- {
- &MobiCoreDriverDaemon::reg_delete_sp_cont,
- sizeof(mcSpid_t)
- },
- {
- &MobiCoreDriverDaemon::reg_read_tl_cont,
- sizeof(TlBlob)
- },
- {
- &MobiCoreDriverDaemon::reg_store_tl_cont,
- sizeof(TlBlob)
- },
- {
- &MobiCoreDriverDaemon::reg_delete_tl_cont,
- sizeof(TlBlob)
- },
- {
- &MobiCoreDriverDaemon::reg_store_so_data,
- 0
- },
- {
- &MobiCoreDriverDaemon::reg_store_ta_blob,
- sizeof(TaBlob)
- },
- {
- &MobiCoreDriverDaemon::reg_delete_ta_objs,
- sizeof(mcUuid_t)
- },
-};
-
-static void terminateDaemon(int signum)
-{
- LOG_I("Signal %d received", signum);
- if ((signum != SIGUSR1) && g_secure_world) {
- g_secure_world->stopListening();
- }
-}
-
-MobiCoreDriverDaemon::MobiCoreDriverDaemon():
- m_reg_server(this, SOCK_PATH)
-{
-}
-
-//------------------------------------------------------------------------------
-int MobiCoreDriverDaemon::init(const std::vector<std::string>& drivers)
-{
- sigset_t sigs_to_block;
-
- if (!m_reg_server.valid())
- return EXIT_FAILURE;
-
- LOG_D("Initializing Device");
-
- /* Set main thread's signal mask to block SIGUSR1.
- * All other threads will inherit mask and have it blocked too */
- sigemptyset(&sigs_to_block);
- sigaddset(&sigs_to_block, SIGUSR1);
- pthread_sigmask(SIG_BLOCK, &sigs_to_block, NULL);
-
- // Open Secure World access
- if (m_secure_world.open() < 0) {
- return EXIT_FAILURE;
- }
-
- // Load SW device driver(s), if requested
- for (auto driver = drivers.begin(); driver != drivers.end(); driver++) {
- // We don't care will loadDriver failed or not...
- m_secure_world.loadDriver(driver->c_str());
- }
-
- // Look for tokens and send it to <t-base if any
- installEndorsementToken();
-
- LOG_D("\n********* successfully initialized Daemon *********");
- return EXIT_SUCCESS;
-}
-
-uint32_t MobiCoreDriverDaemon::reg_store_auth_token(
- const std::string& rx_data, std::string&)
-{
- mcResult_t mcRet = mcRegistryStoreAuthToken(&rx_data[0], rx_data.size());
- /* Load authentication token into <t-base */
- if (MC_DRV_OK == mcRet) {
- if (m_secure_world.loadToken(&rx_data[0], rx_data.size()) < 0) {
- LOG_E("Failed to pass Auth Token to <t-base.");
- }
- }
- return mcRet;
-}
-
-uint32_t MobiCoreDriverDaemon::reg_store_root_cont(
- const std::string& rx_data, std::string&)
-{
- mcResult_t mcRet = mcRegistryStoreRoot(&rx_data[0], rx_data.size());
- /* Load root container into <t-base */
- if (MC_DRV_OK == mcRet) {
- if (m_secure_world.loadToken(&rx_data[0], rx_data.size()) < 0) {
- LOG_E("Failed to pass Root Container to <t-base.");
- }
- }
- return mcRet;
-}
-
-uint32_t MobiCoreDriverDaemon::reg_store_sp_cont(
- const std::string& rx_data, std::string&)
-{
- auto blob = reinterpret_cast<const TaBlob*>(&rx_data[0]);
- size_t blobSize = rx_data.size() - sizeof(*blob);
- return mcRegistryStoreSp(blob->spid, blob->blob, blobSize);
-}
-
-uint32_t MobiCoreDriverDaemon::reg_store_tl_cont(
- const std::string& rx_data, std::string&)
-{
- auto blob = reinterpret_cast<const TlBlob*>(&rx_data[0]);
- size_t blobSize = rx_data.size() - sizeof(*blob);
- return mcRegistryStoreTrustletCon(&blob->uuid, blob->spid, blob->blob, blobSize);
-}
-
-uint32_t MobiCoreDriverDaemon::reg_store_so_data(
- const std::string& rx_data, std::string&)
-{
- return mcRegistryStoreData(&rx_data[0], rx_data.size());
-}
-
-uint32_t MobiCoreDriverDaemon::reg_store_ta_blob(
- const std::string& rx_data, std::string&)
-{
- auto blob = reinterpret_cast<const TaBlob*>(&rx_data[0]);
- if (rx_data.size() < sizeof(*blob)) {
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- size_t blobSize = rx_data.size() - sizeof(*blob);
- if (m_secure_world.LoadCheck(blob->spid, blob->blob,
- static_cast<uint32_t>(blobSize)) < 0) {
- return MC_DRV_ERR_TRUSTLET_NOT_FOUND;
- }
- return mcRegistryStoreTABlob(blob->spid, blob->blob, blobSize);
-}
-
-uint32_t MobiCoreDriverDaemon::reg_read_auth_token(
- const std::string&, std::string& tx_data)
-{
- // Make buffer big enough
- tx_data.resize(sizeof(mcSoAuthTokenCont_t));
- return mcRegistryReadAuthToken(reinterpret_cast<mcSoAuthTokenCont_t*>(&tx_data[0]));
-}
-
-uint32_t MobiCoreDriverDaemon::reg_read_root_cont(
- const std::string&, std::string& tx_data)
-{
- // Make buffer big enough
- tx_data.resize(MAX_DATA_SIZE);
- uint32_t size = MAX_DATA_SIZE;
- uint32_t ret = mcRegistryReadRoot(&tx_data[0], &size);
- if (ret == MC_DRV_OK) {
- tx_data.resize(size);
- }
- return ret;
-}
-
-uint32_t MobiCoreDriverDaemon::reg_read_sp_cont(
- const std::string& rx_data, std::string& tx_data)
-{
- const mcSpid_t &spid = *reinterpret_cast<const mcSpid_t *>(&rx_data[0]);
- // Make buffer big enough
- tx_data.resize(MAX_DATA_SIZE);
- uint32_t size = MAX_DATA_SIZE;
- uint32_t ret = mcRegistryReadSp(spid, &tx_data[0], &size);
- if (ret == MC_DRV_OK) {
- tx_data.resize(size);
- }
- return ret;
-}
-
-uint32_t MobiCoreDriverDaemon::reg_read_tl_cont(
- const std::string& rx_data, std::string& tx_data)
-{
- auto blob = reinterpret_cast<const TlBlob*>(&rx_data[0]);
- // Make buffer big enough
- tx_data.resize(MAX_DATA_SIZE);
- uint32_t size = MAX_DATA_SIZE;
- uint32_t ret = mcRegistryReadTrustletCon(&blob->uuid, blob->spid, &tx_data[0], &size);
- if (ret == MC_DRV_OK) {
- tx_data.resize(size);
- }
- return ret;
-}
-
-uint32_t MobiCoreDriverDaemon::reg_delete_auth_token(
- const std::string&, std::string&)
-{
- return mcRegistryDeleteAuthToken();
-}
-
-uint32_t MobiCoreDriverDaemon::reg_delete_root_cont(
- const std::string&, std::string&)
-{
- mcResult_t mcRet = mcRegistryCleanupRoot();
-
- // Look for tokens and send it to <t-base if any
- if (MC_DRV_OK == mcRet)
- installEndorsementToken();
-
- return mcRet;
-}
-
-uint32_t MobiCoreDriverDaemon::reg_delete_sp_cont(
- const std::string& rx_data, std::string&)
-{
- const mcSpid_t &spid = *reinterpret_cast<const mcSpid_t *>(&rx_data[0]);
- return mcRegistryCleanupSp(spid);
-}
-
-uint32_t MobiCoreDriverDaemon::reg_delete_tl_cont(
- const std::string& rx_data, std::string&)
-{
- auto blob = reinterpret_cast<const TlBlob*>(&rx_data[0]);
- return mcRegistryCleanupTrustlet(&blob->uuid, blob->spid);
-}
-
-uint32_t MobiCoreDriverDaemon::reg_delete_ta_objs(
- const std::string& rx_data, std::string&)
-{
- const mcUuid_t *uuid = reinterpret_cast<const mcUuid_t *>(&rx_data[0]);
- return mcRegistryCleanupGPTAStorage(uuid);
-}
-
-bool MobiCoreDriverDaemon::handleConnection(Connection &conn)
-{
- LOG_D("handleConnection()==== %p", &conn);
-
- CommandHeader cmd;
- switch (conn.readData(&cmd, sizeof(cmd))) {
- case sizeof(cmd):
- break;
- case 0:
- LOG_D(" handleConnection(): Connection closed.");
- return false;
- case -1:
- LOG_E("Socket error.");
- return false;
- case -2:
- LOG_E("Timeout.");
- return false;
- default:
- LOG_E("Insufficient data arrived.");
- return false;
- }
-
- ResponseHeader result = { 0, MC_DRV_OK, 0 };
- std::string rx_data;
- std::string tx_data;
-
- if (MC_DRV_REG_END > cmd.cmd) {
- if (cmd.data_size) {
- if (cmd.data_size >= reg_cmd_map[cmd.cmd].min_rx_size) {
- rx_data.resize(cmd.data_size);
- size_t total = 0;
- while (total < rx_data.size()) {
- ssize_t sz = conn.readData(&rx_data[total], cmd.data_size - total);
- if (sz <= 0) {
- LOG_E("Payload reading failed for command %d expected=%zu received=%zd", cmd.cmd, cmd.data_size - total, sz);
- result.result = MC_DRV_ERR_UNKNOWN;
- break;
- }
- total += sz;
- }
- } else {
- LOG_E("Invalid payload size for command %d", cmd.cmd);
- }
- }
-
- if (result.result == MC_DRV_OK) {
- result.result = (this->*(reg_cmd_map[cmd.cmd].handler))(rx_data, tx_data);
- }
- } else {
- LOG_E("Unknown command %d", cmd.cmd);
- result.result = MC_DRV_ERR_INVALID_OPERATION;
- }
-
- struct iovec iov[2];
- iov[0].iov_len = sizeof(result);
- iov[0].iov_base = const_cast<ResponseHeader *>(&result);
- int count = 1;
- ssize_t write_sz = sizeof(result);
-
- if ((result.result == MC_DRV_OK) && !tx_data.empty()) {
- iov[1].iov_len = tx_data.size();
- iov[1].iov_base = &tx_data[0];
- count++;
- write_sz += tx_data.size();
- }
-
- LOG_D("handleConnection()<-------");
- return conn.writeMsg(iov, count) == write_sz;
-}
-
-int MobiCoreDriverDaemon::run()
-{
- LOG_D("run()====");
-
- // Start File Storage Daemon and registry server
-#ifndef WITHOUT_FSD
- m_filesystem.open();
-#endif
- m_reg_server.start();
-
- /* Exy SP: To let the other daemon which calls TA know
- if secureOS daemon is loaded or not */
- LOG_I("McDaemon.Server was loaded");
- property_set("secure_os.init", "done");
-
-#ifndef WITHOUT_PROXY
- m_proxy_server.open();
-#endif
-
- g_secure_world = &m_secure_world;
- // This call blocks
- int ret = m_secure_world.listen();
-
-#ifndef WITHOUT_PROXY
- m_proxy_server.close();
-#endif
- m_reg_server.terminate();
- m_reg_server.kill(SIGUSR1);
- m_reg_server.stop();
- m_reg_server.join();
-
-#ifndef WITHOUT_FSD
- m_filesystem.close();
-#endif
- LOG_I("run()<-------");
-
- return ret;
-}
-
-//------------------------------------------------------------------------------
-/**
- * Main entry of the <t-base Driver Daemon.
- */
-int main(int argc, char *args[])
-{
- int ret;
-
- // Read the Command line options
- extern char *optarg;
- extern int optopt;
- int c, errFlag = 0;
-
- std::vector<std::string> drivers;
- std::vector<std::string> registry_paths;
-
- // By default don't fork
- bool is_daemon = false;
-
- while ((c = getopt(argc, args, "r:bhp:")) != -1) {
- switch (c) {
- case 'h': /* Help */
- errFlag++;
- break;
- case 'b': /* Fork to background */
- is_daemon = true;
- break;
- case 'p': /* Search paths for registry */
- registry_paths.push_back(optarg);
- LOG_D("registry search path %s added", optarg);
- break;
- case 'r': /* Load <t-base driver at start-up */
- drivers.push_back(optarg);
- LOG_D("driver %s enqueued for loading", optarg);
- break;
- case ':': /* -r operand */
- fprintf(stderr, "Option -%c requires an operand\n", optopt);
- errFlag++;
- break;
- case '?':
- fprintf(stderr, "Unrecognized option: -%c\n", optopt);
- errFlag++;
- }
- }
-
- if (errFlag)
- return printUsage(args[0]);
-
- // Default registry paths if none specified (for Android)
- if (registry_paths.empty()) {
- registry_paths.push_back("/data/app/mcRegistry");
- registry_paths.push_back("/system/app/mcRegistry");
- }
- setSearchPaths(registry_paths);
- LOG_D("Registry search paths:");
- for (auto path = registry_paths.begin(); path != registry_paths.end(); path++) {
- LOG_D(" %s", path->c_str());
- }
-
- // Open the device before becoming a daemon
- MobiCoreDriverDaemon mobiCoreDriverDaemon;
- if (mobiCoreDriverDaemon.init(drivers)) {
- return EXIT_FAILURE;
- }
-
- // We should fork the daemon to background
- if (is_daemon) {
- /* ignore "terminal has been closed" signal */
- signal(SIGHUP, SIG_IGN);
-
- if (daemon(0, 0) < 0) {
- fprintf(stderr, "Fork failed, exiting...\n");
- return 1;
- }
- LOG_D("Daemon's fork was done");
-
- /* ignore tty signals */
- signal(SIGTSTP, SIG_IGN);
- signal(SIGTTOU, SIG_IGN);
- signal(SIGTTIN, SIG_IGN);
- }
-
- // Process signal action
- struct sigaction action;
-
- // Set up the structure to specify the new action.
- action.sa_handler = terminateDaemon;
- sigemptyset(&action.sa_mask);
-
- action.sa_flags = 0;
- sigaction(SIGINT, &action, NULL);
- sigaction(SIGTERM, &action, NULL);
- sigaction(SIGUSR1, &action, NULL);
-
- signal(SIGPIPE, SIG_IGN);
-
- LOG_I("Daemon starting up...");
- LOG_I("Interface version is %u.%u", DAEMON_VERSION_MAJOR,
- DAEMON_VERSION_MINOR);
-
- LOG_I("%s", MOBICORE_COMPONENT_BUILD_TAG);
- LOG_I("Build timestamp is %s %s", __DATE__, __TIME__);
-
- ret = mobiCoreDriverDaemon.run();
-
- LOG_D("Daemon exit with code %d...", ret);
- return ret;
-}
-
-void MobiCoreDriverDaemon::installEndorsementToken(void)
-{
- /* Look for tokens in the registry and pass them to <t-base for endorsement
- * purposes.
- */
- LOG_D("Looking for suitable tokens");
-
- mcSoAuthTokenCont_t authtoken;
- mcSoAuthTokenCont_t authtokenbackup;
- mcSoRootCont_t rootcont;
- uint32_t sosize;
- const void *p = NULL;
-
- // Search order: 1. authtoken 2. authtoken backup 3. root container
- sosize = 0;
- mcResult_t ret = mcRegistryReadAuthToken(&authtoken);
- if (ret != MC_DRV_OK) {
- LOG_D("Failed to read AuthToken (ret=%u). Trying AuthToken backup", ret);
-
- ret = mcRegistryReadAuthTokenBackup(&authtokenbackup);
- if (ret != MC_DRV_OK) {
- LOG_D("Failed to read AuthToken backup (ret=%u). Trying Root Cont", ret);
-
- sosize = sizeof(rootcont);
- ret = mcRegistryReadRoot(&rootcont, &sosize);
- if (ret != MC_DRV_OK) {
- LOG_D("Failed to read Root Cont, (ret=%u).", ret);
- LOG_W("Device endorsements not supported!");
- sosize = 0;
- } else {
- LOG_D("Found Root Cont.");
- p = &rootcont;
- }
-
- } else {
- LOG_D("Found AuthToken backup.");
- p = &authtokenbackup;
- sosize = sizeof(authtokenbackup);
- }
-
- } else {
- LOG_D("Found AuthToken.");
- p = &authtoken;
- sosize = sizeof(authtoken);
- }
-
- if (sosize) {
- LOG_D("Found token of size: %u", sosize);
- if (m_secure_world.loadToken(p, sosize) < 0) {
- LOG_E("Failed to pass token to <t-base. "
- "Device endorsements disabled");
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef MOBICOREDRIVER_H_
-#define MOBICOREDRIVER_H_
-
-#include <string>
-#include <vector>
-
-#include "ConnectionHandler.h"
-#include "Server.h"
-#ifndef WITHOUT_FSD
-#include "FSD2.h"
-#endif
-#include "SecureWorld.h"
-#ifndef WITHOUT_PROXY
-#include "proxy_server.h"
-#endif
-
-class MobiCoreDriverDaemon: public ConnectionHandler
-{
- struct cmd_map_item_t {
- uint32_t (MobiCoreDriverDaemon:: *handler)(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t min_rx_size;
- };
-
- /**
- * installEndorsementToken
- * Look for tokens in the registry and pass them to <t-base for endorsement purposes
- * Search order: 1. authtoken 2. authtoken backup 3. root container
- */
- void installEndorsementToken(void);
-
- bool handleConnection(Connection &connection);
- void dropConnection(Connection&) {}
-
- /* Registry commands, arrived through socket */
- uint32_t reg_store_auth_token(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_store_root_cont(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_store_sp_cont(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_store_tl_cont(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_store_so_data(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_store_ta_blob(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_read_auth_token(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_read_root_cont(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_read_sp_cont(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_read_tl_cont(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_delete_auth_token(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_delete_root_cont(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_delete_sp_cont(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_delete_tl_cont(
- const std::string& rx_data,
- std::string& tx_data);
- uint32_t reg_delete_ta_objs(
- const std::string& rx_data,
- std::string& tx_data);
-
- static const cmd_map_item_t reg_cmd_map[];
- static const uint MAX_DATA_SIZE = 512;
-
- SecureWorld m_secure_world;
-#ifndef WITHOUT_PROXY
- ProxyServer m_proxy_server;
-#endif
-#ifndef WITHOUT_FSD
- FileSystem m_filesystem;
-#endif
- Server m_reg_server;
-public:
- MobiCoreDriverDaemon();
- int init(const std::vector<std::string>& drivers);
- int run (void);
-};
-
-#endif /* MOBICOREDRIVER_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** Mobicore Driver Registry.
- *
- * Implements the MobiCore driver registry which maintains trustlets.
- *
- * @file
- * @ingroup MCD_MCDIMPL_DAEMON_REG
- */
-#include <stdlib.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <assert.h>
-#include <string.h>
-#include <string>
-#include <cstring>
-#include <cstddef>
-#include <sys/mman.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <libgen.h>
-
-#include "mcLoadFormat.h"
-#include "mcSpid.h"
-#include "mcVersionHelper.h"
-
-#include "PrivateRegistry.h"
-
-#include <tee_client_api.h>
-#include "uuid_attestation.h"
-
-#include <log.h>
-
-/** Maximum size of a shared object container in bytes. */
-#define MAX_SO_CONT_SIZE (512)
-
-#define MC_REGISTRY_ALL 0
-#define MC_REGISTRY_WRITABLE 1
-
-#define AUTH_TOKEN_FILE_NAME "00000000.authtokcont"
-#define AUTH_TOKEN_FILE_NAME_BACKUP_SUFFIX ".backup"
-#define ENV_MC_AUTH_TOKEN_PATH "MC_AUTH_TOKEN_PATH"
-#define ROOT_FILE_NAME "00000000.rootcont"
-#define SP_CONT_FILE_EXT ".spcont"
-#define TL_CONT_FILE_EXT ".tlcont"
-#define DATA_CONT_FILE_EXT ".datacont"
-#define TL_BIN_FILE_EXT ".tlbin"
-#define GP_TA_BIN_FILE_EXT ".tabin"
-#define GP_TA_SPID_FILE_EXT ".spid"
-
-static std::vector<std::string> search_paths;
-static std::string tb_storage_path;
-
-//------------------------------------------------------------------------------
-static std::string byteArrayToString(const void *bytes, size_t elems)
-{
- auto cbytes = static_cast<const char *>(bytes);
- char hx[elems * 2 + 1];
-
- for (size_t i = 0; i < elems; i++) {
- sprintf(&hx[i * 2], "%02x", cbytes[i]);
- }
- return std::string(hx);
-}
-
-//------------------------------------------------------------------------------
-static std::string uint32ToString(uint32_t value)
-{
- char hx[8 + 1];
- snprintf(hx, sizeof(hx), "%08X", value);
- std::string str(hx);
- return std::string(str.rbegin(), str.rend());
-}
-
-//------------------------------------------------------------------------------
-static bool dirExists(const char *path)
-{
- struct stat ss;
-
- return (path != NULL) && (stat(path, &ss) == 0) && S_ISDIR(ss.st_mode);
-}
-
-//------------------------------------------------------------------------------
-const std::string& getTbStoragePath()
-{
- return tb_storage_path;
-}
-
-//------------------------------------------------------------------------------
-static std::string getAuthTokenFilePath()
-{
- const char *path;
- std::string authTokenPath;
-
- // First, attempt to use regular auth token path environment variable.
- path = getenv(ENV_MC_AUTH_TOKEN_PATH);
- if (dirExists(path)) {
- LOG_D("getAuthTokenFilePath(): Using MC_AUTH_TOKEN_PATH %s", path);
- authTokenPath = path;
- } else {
- authTokenPath = search_paths[0];
- LOG_D("getAuthTokenFilePath(): Using path %s", authTokenPath.c_str());
- }
-
- return authTokenPath + "/" + AUTH_TOKEN_FILE_NAME;
-}
-
-//------------------------------------------------------------------------------
-static std::string getAuthTokenFilePathBackup()
-{
- return getAuthTokenFilePath() + AUTH_TOKEN_FILE_NAME_BACKUP_SUFFIX;
-}
-
-//------------------------------------------------------------------------------
-static std::string getRootContFilePath()
-{
- return search_paths[0] + "/" + ROOT_FILE_NAME;
-}
-
-//------------------------------------------------------------------------------
-static std::string getSpDataPath(mcSpid_t spid)
-{
- return search_paths[0] + "/" + uint32ToString(spid);
-}
-
-//------------------------------------------------------------------------------
-static std::string getSpContFilePath(mcSpid_t spid)
-{
- return search_paths[0] + "/" + uint32ToString(spid) + SP_CONT_FILE_EXT;
-}
-
-//------------------------------------------------------------------------------
-static std::string getTlContFilePath(const mcUuid_t *uuid, const mcSpid_t spid)
-{
- return search_paths[0] + "/" + byteArrayToString(uuid, sizeof(*uuid))
- + "." + uint32ToString(spid) + TL_CONT_FILE_EXT;
-}
-
-//------------------------------------------------------------------------------
-static std::string getTlDataPath(const mcUuid_t *uuid)
-{
- return search_paths[0] + "/" + byteArrayToString(uuid, sizeof(*uuid));
-}
-
-//------------------------------------------------------------------------------
-static std::string getTlDataFilePath(const mcUuid_t *uuid, mcPid_t pid)
-{
- return getTlDataPath(uuid) + "/" + uint32ToString(pid.data) + DATA_CONT_FILE_EXT;
-}
-
-//------------------------------------------------------------------------------
-static std::string getTlBinFilePath(const mcUuid_t *uuid, int registry)
-{
- std::string path_rw_registry = search_paths[0] + "/" + byteArrayToString(uuid, sizeof(*uuid)) + TL_BIN_FILE_EXT;
-
- if ((registry == MC_REGISTRY_ALL) && (search_paths.size() > 1)) {
- std::string path_ro_registry = search_paths[1] + "/" + byteArrayToString(uuid, sizeof(*uuid)) + TL_BIN_FILE_EXT;
- struct stat tmp;
- if (stat(path_ro_registry.c_str(), &tmp) == 0) {
- return path_ro_registry;
- }
- }
- return path_rw_registry;
-}
-
-//------------------------------------------------------------------------------
-static std::string getTABinFilePath(const mcUuid_t *uuid, int registry)
-{
- std::string path_rw_registry = search_paths[0] + "/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_BIN_FILE_EXT;
-
- if ((registry == MC_REGISTRY_ALL) && (search_paths.size() > 1)) {
- std::string path_ro_registry = search_paths[1] + "/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_BIN_FILE_EXT;
- struct stat tmp;
- if (stat(path_ro_registry.c_str(), &tmp) == 0) {
- return path_ro_registry;
- }
- }
- return path_rw_registry;
-}
-
-//------------------------------------------------------------------------------
-static std::string getTASpidFilePath(const mcUuid_t *uuid, int registry)
-{
- std::string path_rw_registry = search_paths[0] + "/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_SPID_FILE_EXT;
-
- if ((registry == MC_REGISTRY_ALL) && (search_paths.size() > 1)) {
- std::string path_ro_registry = search_paths[1] + "/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_SPID_FILE_EXT;
- struct stat tmp;
- if (stat(path_ro_registry.c_str(), &tmp) == 0) {
- return path_ro_registry;
- }
- }
- return path_rw_registry;
-}
-
-//------------------------------------------------------------------------------
-void setSearchPaths(const std::vector<std::string>& paths)
-{
- search_paths = paths;
- tb_storage_path = search_paths[0] + "/TbStorage";
-}
-
-static inline bool isAllZeros(const unsigned char *so, uint32_t size)
-{
- for (uint32_t i = 0; i < size; i++) {
- if (so[i]) {
- return false;
- }
- }
-
- return true;
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryStoreAuthToken(const void *so, size_t size)
-{
- int res = 0;
- if (so == NULL || size > 3 * MAX_SO_CONT_SIZE) {
- LOG_E("mcRegistry store So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- const std::string &authTokenFilePath = getAuthTokenFilePath();
- LOG_D("store AuthToken: %s", authTokenFilePath.c_str());
-
- /*
- * This special handling is needed because some of our OEM partners do not
- * supply the AuthToken to Kinibi Sphere. Instead, they retain the
- * AuthToken in a dedicated (reliable) storage area on the device. And in
- * that case, Kinibi Sphere is populated with a all-zero-padded AuthToken.
- * (Obviously the zero-padded AuthToken won't work, so we use that zero-
- * padding as an indicator to trigger the special behaviour.)
- *
- * When Kinibi Sphere supplies the device with the zero-padded AuthToken,
- * the device must look retrieve the AuthToken from its dedicated storage,
- * and use it in place of the zero-padded AuthToken supplied by Kinibi
- * Sphere. Since the AuthToken Backup will already have been retrieved from
- * the dedicated storage area by the time this method is called, using the
- * AuthToken Backup as our source is an acceptable proxy for retrieving it
- * from the dedicated storage area directly.
- *
- * This behaviour is triggered following Root.PA detecting a Factory Reset.
- */
- void *backup = NULL;
- if (isAllZeros((const unsigned char*)so, size)) {
- const std::string &authTokenFilePathBackup = getAuthTokenFilePathBackup();
-
- LOG_D("AuthToken is all zeros");
- FILE *backupfs = fopen(authTokenFilePathBackup.c_str(), "rb");
- if (backupfs) {
- backup = malloc(size);
- if (backup) {
- size_t readsize = fread(backup, 1, size, backupfs);
- if (readsize == size) {
- LOG_D("AuthToken reset backup");
- so = backup;
- } else {
- LOG_E("AuthToken read size = %zu (%zu)", readsize, size);
- }
- }
- fclose(backupfs);
- } else {
- LOG_W("can't open AuthToken %s", authTokenFilePathBackup.c_str());
- }
- }
-
- mcResult_t ret = MC_DRV_OK;
- FILE *fs = fopen(authTokenFilePath.c_str(), "wb");
- if (fs == NULL) {
- ret = MC_DRV_ERR_INVALID_DEVICE_FILE;
- } else {
- res = fseek(fs, 0, SEEK_SET);
- if (res != 0) {
- ret = MC_DRV_ERR_INVALID_PARAMETER;
- } else {
- fwrite(so, 1, size, fs);
- if (ferror(fs)) {
- ret = MC_DRV_ERR_OUT_OF_RESOURCES;
- }
- }
- fclose(fs);
- }
- if (ret != MC_DRV_OK) {
- LOG_ERRNO("mcRegistry store So.Soc failed");
- }
- free(backup);
-
- return ret;
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryReadAuthToken(mcSoAuthTokenCont_t *so)
-{
- int res = 0;
- if (NULL == so) {
- LOG_E("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- const std::string &authTokenFilePath = getAuthTokenFilePath();
- LOG_D("read AuthToken: %s", authTokenFilePath.c_str());
-
- FILE *fs = fopen(authTokenFilePath.c_str(), "rb");
- if (fs==NULL) {
- LOG_W("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- res = fseek(fs, 0, SEEK_END);
- if (res!=0) {
- LOG_E("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- long filesize = ftell(fs);
- // We ensure that mcSoAuthTokenCont_t matches with filesize, as ferror (during fread operation) can't
- // handle the case where mcSoAuthTokenCont_t < filesize
- if (sizeof(mcSoAuthTokenCont_t) != filesize) {
- fclose(fs);
- LOG_W("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_OUT_OF_RESOURCES);
- return MC_DRV_ERR_OUT_OF_RESOURCES;
- }
- res = fseek(fs, 0, SEEK_SET);
- if (res!=0) {
- LOG_E("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- size_t read_res = fread(so, 1, sizeof(mcSoAuthTokenCont_t), fs);
- if (ferror(fs)) {
- fclose(fs);
- LOG_E("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- if (read_res<sizeof(mcSoAuthTokenCont_t)) {
- //File is shorter than expected
- if (feof(fs)) {
- LOG_E("%s(): EOF reached: res is %zu, size of mcSoAuthTokenCont_t is %zu", __func__, read_res, sizeof(mcSoAuthTokenCont_t));
- }
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fclose(fs);
-
- return MC_DRV_OK;
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryReadAuthTokenBackup(mcSoAuthTokenCont_t *so)
-{
- int res = 0;
- if (NULL == so) {
- LOG_E("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- const std::string &authTokenFilePath = getAuthTokenFilePathBackup();
- LOG_D("read AuthToken: %s", authTokenFilePath.c_str());
-
- FILE *fs = fopen(authTokenFilePath.c_str(), "rb");
- if (fs==NULL) {
- LOG_W("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- res = fseek(fs, 0, SEEK_END);
- if (res!=0) {
- LOG_E("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- long filesize = ftell(fs);
- // We ensure that mcSoAuthTokenCont_t matches with filesize, as ferror (during fread operation) can't
- // handle the case where mcSoAuthTokenCont_t < filesize
- if (sizeof(mcSoAuthTokenCont_t) != filesize) {
- fclose(fs);
- LOG_W("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_OUT_OF_RESOURCES);
- return MC_DRV_ERR_OUT_OF_RESOURCES;
- }
- res = fseek(fs, 0, SEEK_SET);
- if (res!=0) {
- LOG_E("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- size_t read_res = fread(so, 1, sizeof(mcSoAuthTokenCont_t), fs);
- if (ferror(fs)) {
- fclose(fs);
- LOG_E("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- if (read_res<sizeof(mcSoAuthTokenCont_t)) {
- //File is shorter than expected
- if (feof(fs)) {
- LOG_E("%s(): EOF reached: res is %zu, size of mcSoAuthTokenCont_t is %zu", __func__,
- read_res, sizeof(mcSoAuthTokenCont_t));
- }
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fclose(fs);
-
- return MC_DRV_OK;
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryDeleteAuthToken(void)
-{
- if (rename(getAuthTokenFilePath().c_str(), getAuthTokenFilePathBackup().c_str())) {
- LOG_ERRNO("Rename Auth token file!");
- return MC_DRV_ERR_UNKNOWN;
- } else
- return MC_DRV_OK;
-}
-
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryStoreRoot(const void *so, size_t size)
-{
- int res = 0;
- if (so == NULL || size > 3 * MAX_SO_CONT_SIZE) {
- LOG_E("mcRegistry store So.Root failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
-
- const std::string &rootContFilePath = getRootContFilePath();
- LOG_D("store Root: %s", rootContFilePath.c_str());
-
- FILE *fs = fopen(rootContFilePath.c_str(), "wb");
- if (fs==NULL) {
- LOG_E("mcRegistry store So.Root failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- res = fseek(fs, 0, SEEK_SET);
- if (res!=0) {
- LOG_E("mcRegistry store So.Root failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fwrite(so, 1, size, fs);
- if (ferror(fs)) {
- LOG_E("mcRegistry store So.Root failed: %d", MC_DRV_ERR_OUT_OF_RESOURCES);
- fclose(fs);
- return MC_DRV_ERR_OUT_OF_RESOURCES;
- }
- fflush(fs);
- fclose(fs);
-
- return MC_DRV_OK;
-}
-
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryReadRoot(void *so, uint32_t *size)
-{
- const std::string &rootContFilePath = getRootContFilePath();
- size_t readBytes;
-
- if (so == NULL) {
- LOG_E("mcRegistry read So.Root failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- LOG_D(" Opening %s", rootContFilePath.c_str());
-
- FILE *fs = fopen(rootContFilePath.c_str(), "rb");
- if (fs==NULL) {
- LOG_W("mcRegistry read So.Root failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- readBytes = fread(so, 1, *size, fs);
- if (ferror(fs)) {
- fclose(fs);
- LOG_E("mcRegistry read So.Root failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fclose(fs);
-
- if (readBytes > 0) {
- *size = static_cast<uint32_t>(readBytes);
- return MC_DRV_OK;
- } else {
- LOG_E("mcRegistry read So.Root failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
-}
-
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryStoreSp(mcSpid_t spid, const void *so, size_t size)
-{
- int res = 0;
- if ((spid == 0) || (so == NULL) || size > 3 * MAX_SO_CONT_SIZE) {
- LOG_E("mcRegistry store So.Sp(SpId) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
-
- const std::string &spContFilePath = getSpContFilePath(spid);
- LOG_D("store SP: %s", spContFilePath.c_str());
-
- FILE *fs = fopen(spContFilePath.c_str(), "wb");
- if (fs==NULL) {
- LOG_E("mcRegistry store So.Sp(SpId) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- res = fseek(fs, 0, SEEK_SET);
- if (res!=0) {
- LOG_E("mcRegistry store So.Sp(SpId) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fwrite(so, 1, size, fs);
- if (ferror(fs)) {
- LOG_E("mcRegistry store So.Sp(SpId) failed: %d", MC_DRV_ERR_OUT_OF_RESOURCES);
- fclose(fs);
- return MC_DRV_ERR_OUT_OF_RESOURCES;
- }
- fflush(fs);
- fclose(fs);
-
- return MC_DRV_OK;
-}
-
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryReadSp(mcSpid_t spid, void *so, uint32_t *size)
-{
- const std::string &spContFilePath = getSpContFilePath(spid);
- size_t readBytes;
- if ((spid == 0) || (so == NULL)) {
- LOG_E("mcRegistry read So.Sp(SpId=0x%x) failed", spid);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- LOG_D(" Reading %s", spContFilePath.c_str());
-
- FILE *fs = fopen(spContFilePath.c_str(), "rb");
- if (fs==NULL) {
- LOG_E("mcRegistry read So.Sp(SpId) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- readBytes = fread(so, 1, *size, fs);
- if (ferror(fs)) {
- fclose(fs);
- LOG_E("mcRegistry read So.Sp(SpId) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fclose(fs);
-
- if (readBytes > 0) {
- *size = static_cast<uint32_t>(readBytes);
- return MC_DRV_OK;
- } else {
- LOG_E("mcRegistry read So.Sp(SpId) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
-}
-
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, const void *so, size_t size)
-{
- int res = 0;
- if ((uuid == NULL) || (so == NULL) || size > 3 * MAX_SO_CONT_SIZE) {
- LOG_E("mcRegistry store So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
-
- const std::string &tlContFilePath = getTlContFilePath(uuid, spid);
- LOG_D("store TLc: %s", tlContFilePath.c_str());
-
- FILE *fs = fopen(tlContFilePath.c_str(), "wb");
- if (fs==NULL) {
- LOG_E("mcRegistry store So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- res = fseek(fs, 0, SEEK_SET);
- if (res!=0) {
- LOG_E("mcRegistry store So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fwrite(so, 1, size, fs);
- if (ferror(fs)) {
- LOG_E("mcRegistry store So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_OUT_OF_RESOURCES);
- fclose(fs);
- return MC_DRV_ERR_OUT_OF_RESOURCES;
- }
- fflush(fs);
- fclose(fs);
-
- return MC_DRV_OK;
-}
-
-static uint32_t getAsUint32BE(
- const void *pValueUnaligned
-)
-{
- auto p = static_cast<const uint8_t *>(pValueUnaligned);
- uint32_t val = p[3] | (p[2] << 8) | (p[1] << 16) | (p[0] << 24);
- return val;
-}
-
-mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, const void *blob, size_t size)
-{
- int res = 0;
- LOG_D("mcRegistryStoreTABlob started");
-
- // Check blob size
- if (size < sizeof(mclfHeaderV24_t)) {
- LOG_E("RegistryStoreTABlob failed - TA blob length is less then header size");
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
-
- auto header24 = reinterpret_cast<const mclfHeaderV24_t *>(blob);
- auto header20 = reinterpret_cast<const mclfHeaderV2_t *>(blob);
-
- // Check header version
- if (header20->intro.version < MC_MAKE_VERSION(2, 4)) {
- LOG_E("RegistryStoreTABlob failed - TA blob header version is less than 2.4");
- return MC_DRV_ERR_TA_HEADER_ERROR;
- }
-
- //Check GP version
- if (header24->gp_level != 1) {
- LOG_E("RegistryStoreTABlob failed - TA blob header gp_level is not equal to 1");
- return MC_DRV_ERR_TA_HEADER_ERROR;
- }
-
- mcUuid_t uuid;
- switch (header20->serviceType) {
- case SERVICE_TYPE_SYSTEM_TRUSTLET: {
- // Check spid
- if (spid != MC_SPID_SYSTEM) {
- LOG_E("RegistryStoreTABlob failed - SPID is not equal to %d for System TA", spid);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- memcpy(&uuid, &header20->uuid, sizeof(mcUuid_t));
- break;
- }
- case SERVICE_TYPE_SP_TRUSTLET: {
- // Check spid
- if (spid >= MC_SPID_SYSTEM) {
- LOG_E("RegistryStoreTABlob failed - SPID is equal to %u ", spid);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
-
- auto pUa = reinterpret_cast<const uuid_attestation*>(&static_cast<const uint8_t*>(blob)[header24->attestationOffset]);
- // Check attestation size
- if ((header24->attestationOffset > size) && (header24->attestationOffset + getAsUint32BE(&pUa->size) > size)) {
- LOG_E("RegistryStoreTABlob failed - Attestation size is not correct");
- return MC_DRV_ERR_TA_HEADER_ERROR;
- }
-
- // Check attestation size
- if (getAsUint32BE(&pUa->size) < sizeof(uuid_attestation)) {
- LOG_E("RegistryStoreTABlob failed - Attestation size is equal to %d and is less then %zu", getAsUint32BE(&pUa->size), sizeof(uuid_attestation));
- return MC_DRV_ERR_TA_ATTESTATION_ERROR;
- }
-
- // Check magic word
- if (memcmp(pUa->magic, MAGIC, AT_MAGIC_SIZE)) {
- LOG_E("RegistryStoreTABlob failed - Attestation magic word is not correct");
- return MC_DRV_ERR_TA_ATTESTATION_ERROR;
- }
-
- // Check version
- if (getAsUint32BE(&pUa->version) != AT_VERSION) {
- LOG_E("RegistryStoreTABlob failed - Attestation version is equal to %08X. It has to be equal to %08X", getAsUint32BE(&pUa->version), AT_VERSION);
- return MC_DRV_ERR_TA_ATTESTATION_ERROR;
- }
-
- memcpy(&uuid, &pUa->uuid, sizeof(mcUuid_t));
- break;
- }
- default: {
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- }
- const std::string taBinFilePath = getTABinFilePath(&uuid, MC_REGISTRY_WRITABLE);
-
- LOG_D("Store TA blob at: %s", taBinFilePath.c_str());
-
- FILE *fs = fopen(taBinFilePath.c_str(), "wb");
- if (fs==NULL) {
- LOG_E("RegistryStoreTABlob failed - TA blob file open error: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- res = fseek(fs, 0, SEEK_SET);
- if (res!=0) {
- LOG_E("RegistryStoreTABlob failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fwrite(blob, 1, size, fs);
- if (ferror(fs)) {
- LOG_E("RegistryStoreTABlob failed: %d", MC_DRV_ERR_OUT_OF_RESOURCES);
- fclose(fs);
- return MC_DRV_ERR_OUT_OF_RESOURCES;
- }
- fflush(fs);
- fclose(fs);
-
- if (header20->serviceType == SERVICE_TYPE_SP_TRUSTLET) {
- const std::string taspidFilePath = getTASpidFilePath(&uuid, MC_REGISTRY_WRITABLE);
-
- LOG_D("Store spid file at: %s", taspidFilePath.c_str());
-
- FILE *fs = fopen(taspidFilePath.c_str(), "wb");
- if (fs==NULL) {
- LOG_E("RegistryStoreTABlob failed - TA blob file open error: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- res = fseek(fs, 0, SEEK_SET);
- if (res!=0) {
- LOG_E("RegistryStoreTABlob failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fwrite(&spid, 1, sizeof(mcSpid_t), fs);
- if (ferror(fs)) {
- LOG_E("RegistryStoreTABlob failed: %d", MC_DRV_ERR_OUT_OF_RESOURCES);
- fclose(fs);
- return MC_DRV_ERR_OUT_OF_RESOURCES;
- }
- fflush(fs);
- fclose(fs);
- }
- return MC_DRV_OK;
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryReadTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t *size)
-{
- int res = 0;
- if ((uuid == NULL) || (so == NULL)) {
- LOG_E("mcRegistry read So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- size_t readBytes;
- const std::string &tlContFilePath = getTlContFilePath(uuid, spid);
- LOG_D("read TLc: %s", tlContFilePath.c_str());
-
- FILE *fs = fopen(tlContFilePath.c_str(), "rb");
- if (fs==NULL) {
- LOG_E("mcRegistry read So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- res = fseek(fs, 0, SEEK_SET);
- if (res!=0) {
- LOG_E("mcRegistry read So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- readBytes = fread(so, 1, *size, fs);
- if (ferror(fs)) {
- fclose(fs);
- LOG_E("mcRegistry read So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fclose(fs);
-
- if (readBytes > 0) {
- *size = static_cast<uint32_t>(readBytes);
- return MC_DRV_OK;
- } else {
- LOG_E("mcRegistry read So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
-}
-
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryStoreData(const void *so, size_t size)
-{
- const mcSoDataCont_t *dataCont = reinterpret_cast<const mcSoDataCont_t*>(so);
- int res = 0;
-
- if (dataCont == NULL || size != sizeof(mcSoDataCont_t)) {
- LOG_E("mcRegistry store So.Data failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- std::string pathname, filename;
-
- switch (dataCont->cont.type) {
- case CONT_TYPE_SPDATA:
- LOG_E("SPDATA not supported");
- return MC_DRV_ERR_INVALID_PARAMETER;
- break;
- case CONT_TYPE_TLDATA:
- pathname = getTlDataPath(&dataCont->cont.uuid);
- filename = getTlDataFilePath(&dataCont->cont.uuid, dataCont->cont.pid);
- break;
- default:
- LOG_E("mcRegistry store So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- if (mkdir(pathname.c_str(), 0777) < 0)
- {
- LOG_E("mcRegistry store So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
-
- LOG_D("store DT: %s", filename.c_str());
-
- FILE *fs = fopen(filename.c_str(), "wb");
- if (fs==NULL) {
- LOG_E("mcRegistry store So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- res = fseek(fs, 0, SEEK_SET);
- if (res!=0) {
- LOG_E("mcRegistry store So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fwrite(dataCont, 1, MC_SO_SIZE(dataCont->soHeader.plainLen, dataCont->soHeader.encryptedLen), fs);
- if (ferror(fs)) {
- LOG_E("mcRegistry store So.Data(cid/pid) failed: %d", MC_DRV_ERR_OUT_OF_RESOURCES);
- fclose(fs);
- return MC_DRV_ERR_OUT_OF_RESOURCES;
- }
- fflush(fs);
- fclose(fs);
-
- return MC_DRV_OK;
-}
-
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryReadData(uint32_t context, const mcCid_t *cid, mcPid_t,
- mcSoDataCont_t *so, uint32_t maxLen)
-{
- int res = 0;
-
- if ((NULL == cid) || (NULL == so)) {
- LOG_E("mcRegistry read So.Data failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- std::string filename;
- switch (context) {
- case 0:
- LOG_E("SPDATA not supported");
- return MC_DRV_ERR_INVALID_PARAMETER;
- break;
- case 1:
- filename = getTlDataFilePath(&so->cont.uuid, so->cont.pid);
- break;
- default:
- LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- LOG_D("read DT: %s", filename.c_str());
-
- FILE *fs = fopen(filename.c_str(), "rb");
- if (fs==NULL) {
- LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
- return MC_DRV_ERR_INVALID_DEVICE_FILE;
- }
- res = fseek(fs, 0, SEEK_END);
- if (res!=0) {
- LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- long filesize = ftell(fs);
- if (static_cast<long>(maxLen) < filesize) {
- fclose(fs);
- LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_OUT_OF_RESOURCES);
- return MC_DRV_ERR_OUT_OF_RESOURCES;
- }
- res = fseek(fs, 0, SEEK_SET);
- if (res!=0) {
- LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- char *p = reinterpret_cast<char*>(so);
- size_t read_res = fread(p, 1, sizeof(mcSoHeader_t), fs);
- if (ferror(fs)) {
- fclose(fs);
- LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- if (read_res<sizeof(mcSoHeader_t)) {
- //File is shorter than expected
- if (feof(fs)) {
- LOG_E("%s(): EOF reached: res is %zu, size of mcSoHeader_t is %zu", __func__, read_res, sizeof(mcSoHeader_t));
- }
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- p += sizeof(mcSoHeader_t);
- read_res = fread(p, 1, MC_SO_SIZE(so->soHeader.plainLen,
- so->soHeader.encryptedLen)
- - sizeof(mcSoHeader_t), fs);
- if (ferror(fs)) {
- fclose(fs);
- LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- if (read_res<(MC_SO_SIZE(so->soHeader.plainLen, so->soHeader.encryptedLen) - sizeof(mcSoHeader_t))) {
- //File is shorter than expected
- if (feof(fs)) {
- LOG_E("%s(): EOF reached: res is %zu, size of secure object is %zu", __func__, read_res,
- MC_SO_SIZE(so->soHeader.plainLen, so->soHeader.encryptedLen) - sizeof(mcSoHeader_t));
- }
- fclose(fs);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- fclose(fs);
-
- return MC_DRV_OK;
-}
-
-
-//------------------------------------------------------------------------------
-static uint32_t getFileContent(
- const char *pPath,
- uint8_t **ppContent)
-{
- FILE *pStream;
- long filesize;
- uint8_t *content = NULL;
- size_t res = 0;
-
- /* Open the file */
- pStream = fopen(pPath, "rb");
- if (pStream == NULL) {
- LOG_E("Error: Cannot open file: %s.", pPath);
- return 0;
- }
-
- if (fseek(pStream, 0L, SEEK_END) != 0) {
- LOG_E("Error: Cannot read file: %s.", pPath);
- goto error;
- }
-
- filesize = ftell(pStream);
- if (filesize < 0) {
- LOG_E("Error: Cannot get the file size: %s.", pPath);
- goto error;
- }
-
- if (filesize == 0) {
- LOG_E("Error: Empty file: %s.", pPath);
- goto error;
- }
-
- /* Set the file pointer at the beginning of the file */
- if (fseek(pStream, 0L, SEEK_SET) != 0) {
- LOG_E("Error: Cannot read file: %s.", pPath);
- goto error;
- }
-
- /* Allocate a buffer for the content */
- content = new uint8_t[filesize];
- if (content == NULL) {
- LOG_E("Error: Cannot read file: Out of memory.");
- goto error;
- }
-
- /* Read data from the file into the buffer */
- res = fread(content, filesize, 1, pStream);
- if (ferror(pStream)) {
- LOG_E("Error: Cannot read file: %s.", pPath);
- goto error;
- }
- if (res < 1) {
- //File is shorter than expected
- if (feof(pStream)) {
- LOG_E("Error: EOF reached: %s.", pPath);
- }
- goto error;
- }
-
- /* Close the file */
- fclose(pStream);
- *ppContent = content;
-
- /* Return number of bytes read */
- return static_cast<uint32_t>(filesize);
-
-error:
- if (content != NULL) {
- delete[] content;
- }
- fclose(pStream);
- return 0;
-}
-
-//------------------------------------------------------------------------------
-static bool mcCheckUuid(const mcUuid_t *uuid, const char *filename)
-{
- uint8_t *pTAData = NULL;
- uint32_t nTASize;
- bool res;
-
- nTASize = getFileContent(filename, &pTAData);
- if (nTASize == 0) {
- LOG_E("err: Trusted Application not found.");
- return false;
- }
-
- // Check blob size
- if (nTASize < sizeof(mclfHeaderV24_t)) {
- delete[] pTAData;
- LOG_E("getFileContent failed - TA length is less than header size");
- return false;
- }
-
- mclfHeaderV2_t *header20 = reinterpret_cast<mclfHeaderV2_t *>(pTAData);
-
- // Check header version
- if (header20->intro.version < MC_MAKE_VERSION(2, 4)) {
- delete[] pTAData;
- LOG_E("mcCheckUuid() - TA blob header version is less than 2.4");
- return false;
- }
-
- // Check uuid
- if (memcmp(uuid, &header20->uuid, sizeof(mcUuid_t)) == 0) {
- res = true;
- } else {
- res = false;
- }
-
- delete[] pTAData;
-
- return res;
-}
-
-//this function deletes all the files owned by a GP TA and stored in the tbase secure storage dir.
-//then it deletes GP TA folder.
-static int CleanupGPTAStorage(const char *uuid)
-{
- DIR *dp;
- struct dirent *de;
- int e;
- std::string TAPath = getTbStoragePath() + "/" + uuid;
- if (NULL != (dp = opendir(TAPath.c_str()))) {
- while (NULL != (de = readdir(dp))) {
- if (de->d_name[0] != '.') {
- std::string dname = TAPath + "/" + std::string(de->d_name);
- LOG_D("delete DT: %s", dname.c_str());
- if (0 != (e = remove(dname.c_str()))) {
- LOG_E("remove UUID-files %s failed! error: %d", dname.c_str(), e);
- }
- }
- }
- if (dp) {
- closedir(dp);
- }
- LOG_D("delete dir: %s", TAPath.c_str());
- if (0 != (e = rmdir(TAPath.c_str()))) {
- LOG_E("remove UUID-dir failed! errno: %d", e);
- return e;
- }
- }
- return MC_DRV_OK;
-}
-
-
-mcResult_t mcRegistryCleanupGPTAStorage(const mcUuid_t *uuid)
-{
- return CleanupGPTAStorage(byteArrayToString(uuid, sizeof(*uuid)).c_str());
-}
-
-static void deleteSPTA(const mcUuid_t *uuid, const mcSpid_t spid)
-{
- DIR *dp;
- struct dirent *de;
- int e;
-
- // Delete TABIN and SPID files - we loop searching required spid file
- if (NULL != (dp = opendir(search_paths[0].c_str()))) {
- while (NULL != (de = readdir(dp))) {
- std::string spidFile;
- std::string tabinFile;
- std::string tabinUuid;
- size_t pch_dot, pch_slash;
- spidFile = search_paths[0] + "/" + std::string(de->d_name);
- pch_dot = spidFile.find_last_of('.');
- if (pch_dot == std::string::npos) continue;
- pch_slash = spidFile.find_last_of('/');
- if ((pch_slash != std::string::npos) && (pch_slash > pch_dot)) continue;
- if (spidFile.substr(pch_dot).compare(GP_TA_SPID_FILE_EXT) != 0) continue;
-
- mcSpid_t curSpid = 0;
-
- int fd = open(spidFile.c_str(), O_RDONLY);
- if (fd != -1) {
- if (read(fd, &curSpid, sizeof(mcSpid_t))!=sizeof(mcSpid_t)) {
- curSpid = 0;
- }
- close(fd);
- }
- if (spid == curSpid) {
- tabinFile = spidFile.substr(0, pch_dot) + GP_TA_BIN_FILE_EXT;
- if (mcCheckUuid(uuid, tabinFile.c_str())) {
- tabinUuid = spidFile.substr(0, pch_dot);
- tabinUuid = tabinUuid.substr(tabinUuid.find_last_of('/')+1);
- LOG_D("Remove TA storage %s", tabinUuid.c_str());
- if (0 != (e = CleanupGPTAStorage(tabinUuid.c_str()))){
- LOG_E("Remove TA storage failed! errno: %d", e);
- /* Discard error */
- }
- LOG_D("Remove TA file %s", tabinFile.c_str());
- if (0 != (e = remove(tabinFile.c_str()))) {
- LOG_E("Remove TA file failed! errno: %d", e);
- /* Discard error */
- }
- LOG_D("Remove spid file %s", spidFile.c_str());
- if (0 != (e = remove(spidFile.c_str()))) {
- LOG_E("Remove spid file failed! errno: %d", e);
- /* Discard error */
- }
- break;
- }
- }
- }
- if (dp) {
- closedir(dp);
- }
- }
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryCleanupTrustlet(const mcUuid_t *uuid, const mcSpid_t spid)
-{
- DIR *dp;
- struct dirent *de;
- int e;
-
- if (NULL == uuid) {
- LOG_E("mcRegistry cleanupTrustlet(uuid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
-
- // Delete all TA related data
- std::string pathname = getTlDataPath(uuid);
- if (NULL != (dp = opendir(pathname.c_str()))) {
- while (NULL != (de = readdir(dp))) {
- if (de->d_name[0] != '.') {
- std::string dname = pathname + "/" + std::string(de->d_name);
- LOG_D("delete DT: %s", dname.c_str());
- if (0 != (e = remove(dname.c_str()))) {
- LOG_E("remove UUID-data %s failed! error: %d", dname.c_str(), e);
- }
- }
- }
- if (dp) {
- closedir(dp);
- }
- LOG_D("delete dir: %s", pathname.c_str());
- if (0 != (e = rmdir(pathname.c_str()))) {
- LOG_E("remove UUID-dir failed! errno: %d", e);
- return MC_DRV_ERR_UNKNOWN;
- }
- }
-
- std::string tlBinFilePath = getTlBinFilePath(uuid, MC_REGISTRY_WRITABLE);
- struct stat tmp;
- std::string tlContFilePath = getTlContFilePath(uuid, spid);;
-
- if (stat(tlBinFilePath.c_str(), &tmp) == 0) {
- /* Legacy TA */
- LOG_D("Remove TA file %s", tlBinFilePath.c_str());
- if (0 != (e = remove(tlBinFilePath.c_str()))) {
- LOG_E("Remove TA file failed! errno: %d", e);
- }
- } else {
- /* GP TA */
- deleteSPTA(uuid, spid);
- }
-
- LOG_D("Remove TA container %s", tlContFilePath.c_str());
- if (0 != (e = remove(tlContFilePath.c_str()))) {
- LOG_E("Remove TA container failed! errno: %d", e);
- return MC_DRV_ERR_UNKNOWN;
- }
-
- return MC_DRV_OK;
-}
-
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryCleanupSp(mcSpid_t spid)
-{
- DIR *dp;
- struct dirent *de;
- mcResult_t ret;
- mcSoSpCont_t data;
- uint32_t i, len;
- int e;
-
- if (0 == spid) {
- LOG_E("mcRegistry cleanupSP(SpId) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
- len = sizeof(mcSoSpCont_t);
- ret = mcRegistryReadSp(spid, &data, &len);
- if (MC_DRV_OK != ret || len != sizeof(mcSoSpCont_t)) {
- LOG_E("read SP->UUID aborted! Return code: %d", ret);
- return ret;
- }
- for (i = 0; (i < MC_CONT_CHILDREN_COUNT) && (ret == MC_DRV_OK); i++) {
- if (0 != strncmp(reinterpret_cast<const char*>(&data.cont.children[i]),
- reinterpret_cast<const char*>(&MC_UUID_FREE),
- sizeof(mcUuid_t))) {
- ret = mcRegistryCleanupTrustlet(&(data.cont.children[i]), spid);
- }
- }
- if (MC_DRV_OK != ret) {
- LOG_E("delete SP->UUID failed! Return code: %d", ret);
- return ret;
- }
-
- std::string pathname = getSpDataPath(spid);
-
- if (NULL != (dp = opendir(pathname.c_str()))) {
- while (NULL != (de = readdir(dp))) {
- if (de->d_name[0] != '.') {
- std::string dname = pathname + "/" + std::string(de->d_name);
- LOG_D("delete DT: %s", dname.c_str());
- if (0 != (e = remove(dname.c_str()))) {
- LOG_E("remove SPID-data %s failed! error: %d", dname.c_str(), e);
- }
- }
- }
- if (dp) {
- closedir(dp);
- }
- LOG_D("delete dir: %s", pathname.c_str());
- if (0 != (e = rmdir(pathname.c_str()))) {
- LOG_E("remove SPID-dir failed! error: %d", e);
- return MC_DRV_ERR_UNKNOWN;
- }
- }
- std::string spContFilePath = getSpContFilePath(spid);
- LOG_D("delete Sp: %s", spContFilePath.c_str());
- if (0 != (e = remove(spContFilePath.c_str()))) {
- LOG_E("remove SP failed! error: %d", e);
- return MC_DRV_ERR_UNKNOWN;
- }
- return MC_DRV_OK;
-}
-
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryCleanupRoot(void)
-{
- mcResult_t ret;
- mcSoRootCont_t data;
- uint32_t i, len;
- int e;
- len = sizeof(mcSoRootCont_t);
- ret = mcRegistryReadRoot(&data, &len);
- if (MC_DRV_OK != ret || len != sizeof(mcSoRootCont_t)) {
- LOG_E("read Root aborted! Return code: %d", ret);
- return ret;
- }
- for (i = 0; (i < MC_CONT_CHILDREN_COUNT) && (ret == MC_DRV_OK); i++) {
- mcSpid_t spid = data.cont.children[i];
- if (spid != MC_SPID_FREE) {
- ret = mcRegistryCleanupSp(spid);
- if (MC_DRV_OK != ret) {
- LOG_E("Cleanup SP failed! Return code: %d", ret);
- return ret;
- }
- }
- }
-
- std::string rootContFilePath = getRootContFilePath();
- LOG_D("Delete root: %s", rootContFilePath.c_str());
- if (0 != (e = remove(rootContFilePath.c_str()))) {
- LOG_E("Delete root failed! error: %d", e);
- return MC_DRV_ERR_UNKNOWN;
- }
- return MC_DRV_OK;
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryGetTrustletInfo(const mcUuid_t *uuid, bool isGpUuid, mcSpid_t *spid, std::string& path)
-{
- // Ensure that a UUID is provided.
- if (NULL == uuid) {
- LOG_E("No UUID given");
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
-
- if (isGpUuid) {
- path = getTABinFilePath(uuid, MC_REGISTRY_ALL);
- } else {
- path = getTlBinFilePath(uuid, MC_REGISTRY_ALL);
- }
-
- *spid = 0;
- if (isGpUuid) {
- std::string taspidFilePath = getTASpidFilePath(uuid, MC_REGISTRY_ALL);
- int fd = open(taspidFilePath.c_str(), O_RDONLY);
- if (fd >= 0) {
- bool failed = read(fd, spid, sizeof(*spid)) != sizeof(*spid);
- close(fd);
- if (failed) {
- LOG_E("Could not read SPID (%d)", errno);
- return MC_DRV_ERR_TRUSTLET_NOT_FOUND;
- }
- }
- }
-
- LOG_D("Returning %s", path.c_str());
- return MC_DRV_OK;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef MOBICORE_REGISTRY_H_
-#define MOBICORE_REGISTRY_H_
-
-#include <string>
-#include <vector>
-
-#include "MobiCoreDriverApi.h"
-#include "mcContainer.h"
-#include "MobiCoreDriverCmd.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-//-----------------------------------------------------------------
-
- void setSearchPaths(const std::vector<std::string>& paths);
-
- /** Stores an authentication token in registry.
- * @param so Authentication token secure object.
- * @param size Authentication token secure object size.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryStoreAuthToken(const void *so, size_t size);
-
- /** Reads an authentication token from registry.
- * @param[out] so Authentication token secure object.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryReadAuthToken(mcSoAuthTokenCont_t *so);
-
- /** Reads an authentication token backup from registry.
- * @param[out] so Authentication token secure object.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryReadAuthTokenBackup(mcSoAuthTokenCont_t *so);
-
- /** Deletes the authentication token secure object from the registry.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryDeleteAuthToken(void);
-
- /** Stores a root container secure object in the registry.
- * @param so Root container secure object.
- * @param size Root container secure object size.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryStoreRoot(const void *so, size_t size);
-
- /** Reads a root container secure object from the registry.
- * @param[out] so Root container secure object.
- * @param[out] size Root container secure object size
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryReadRoot(void *so, uint32_t *size);
-
- /** Stores a service provider container secure object in the registry.
- * @param spid Service provider ID.
- * @param so Service provider container secure object.
- * @param size Service provider container secure object size.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryStoreSp(mcSpid_t spid, const void *so, size_t size);
-
- /** Reads a service provider container secure object from the registry.
- * @param spid Service provider ID.
- * @param[out] so Service provider container secure object.
- * @param[out] size Service provider container secure object size
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryReadSp(mcSpid_t spid, void *so, uint32_t *size);
-
- /** Deletes a service provider recursively, including all trustlets and
- * data.
- * @param spid Service provider ID.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryCleanupSp(mcSpid_t spid);
-
- /** Stores a trustlet container secure object in the registry.
- * @param uuid Trustlet UUID.
- * @param so Trustlet container secure object.
- * @param size Trustlet container secure object size
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, const void *so, size_t size);
-
- /** Reads a trustlet container secure object from the registry.
- * @param uuid Trustlet UUID.
- * @param spid SPID of the trustlet container
- * @param[out] so Trustlet container secure object.
- * @param[out] size Trustlet container secure object size
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryReadTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t *size);
-
- /** Deletes a trustlet container secure object and all of its associated data.
- * @param uuid Trustlet UUID.
- * @param spid Service provider ID
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryCleanupTrustlet(const mcUuid_t *uuid, const mcSpid_t spid);
-
- /**
- * mcRegistryCleanupGPTAStorage()
- *
- * Removes all associated data of the target UUID. This function is called
- * by FSD when cleaning up after a TA has been uninstalled.
- *
- * @param [in] uuid the UUID of the target TA
- * @retval MC_DRV_OK if successful, otherwise and error code from mcResult_t
- */
- mcResult_t mcRegistryCleanupGPTAStorage(const mcUuid_t *uuid);
-
- /** Stores a data container secure object in the registry.
- * @param so Data container secure object.
- * @param size Data container secure object size
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryStoreData(const void *so, size_t size);
-
- /** Reads a data container secure object from the registry.
- * @param context (service provider = 0; trustlet = 1).
- * @param cid Service provider or UUID.
- * @param pid Personalization data identifier.
- * @param[out] so Data container secure object.
- * @param maxLen Maximum size (in bytes) of the destination buffer (so).
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryReadData(uint32_t context, const mcCid_t *cid, mcPid_t pid, mcSoDataCont_t *so, uint32_t maxLen);
-
- /** Deletes the root container and all of its associated service provider
- * containers.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryCleanupRoot(void);
-
- /** Returns a registry object for a given service.
- * @param uuid service UUID
- * @param isGpUuid UUID is for a GP trustlet
- * @param[out] spid SPID for secure object.
- * @param[out] path The trustlet file path.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryGetTrustletInfo(const mcUuid_t *uuid, bool isGpUuid, mcSpid_t *spid, std::string& path);
-
- /** Stores a Trustlet Application blob in the registry.
- * @param spid SPID of the trustlet container.
- * @param blob Trustlet Application blob.
- * @param size Trustlet Application blob size.
- * @return MC_DRV_OK if successful, otherwise error code.
- */
- mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, const void *blob, size_t size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // MOBICORE_REGISTRY_H_
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** Mobicore Driver Registry Interface
- *
- * Implements the MobiCore registry interface for the ROOT-PA
- *
- * @file
- * @ingroup MCD_MCDIMPL_DAEMON_REG
- */
-
-#include <stdint.h>
-#include <string.h>
-#include <sys/uio.h>
-#include <fcntl.h>
-#include "log.h"
-
-#include "mcSpid.h"
-#include "MobiCoreRegistry.h"
-#include "MobiCoreDriverCmd.h"
-#include "Connection.h"
-#include "buildTag.h"
-
-static const __attribute__((used)) char* buildtag = MOBICORE_COMPONENT_BUILD_TAG;
-
-#define DAEMON_TIMEOUT 30000
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
-
-struct cmd_t: public CommandHeader
-{
- cmd_t(const uint32_t c)
- {
- id = 0;
- cmd = c;
- data_size = 0;
- }
-};
-
-static
-mcResult_t check_iov(const struct iovec *iov, size_t iovcnt, size_t *pay_size)
-{
- size_t sz = 0;
- if(iov == NULL || iov[0].iov_len != sizeof(cmd_t))
- return MC_DRV_ERR_INVALID_PARAMETER;
-
- for(size_t i = 0; i < iovcnt; i++) {
- if(iov[i].iov_base == NULL || iov[i].iov_len == 0)
- return MC_DRV_ERR_INVALID_PARAMETER;
- sz += iov[i].iov_len;
- }
- *pay_size = sz - iov[0].iov_len;
- return MC_DRV_OK;
-}
-
-
-static mcResult_t send_cmd_recv_data(struct iovec *out_iov,
- size_t out_iovcnt, void *rbuff = NULL, uint32_t *rlen = NULL)
-{
- uint32_t nsegs;
- ResponseHeader rsp;
- size_t payload_sz;
- ssize_t length;
-
- if( (rbuff == NULL && rlen != NULL) ||
- (rbuff != NULL && rlen == NULL) ||
- out_iov == NULL || out_iovcnt == 0) {
- LOG_E("Invalid buffer length!");
- return MC_DRV_ERR_INVALID_PARAMETER;
- }
-
- memset(&rsp, 0, sizeof(rsp));
- rsp.result = check_iov(out_iov, out_iovcnt, &payload_sz);
- if(rsp.result != MC_DRV_OK)
- return rsp.result;
-
- struct iovec in_iov[2] = {
- { &rsp, sizeof(rsp) }
- };
-
- if(rbuff != NULL) {
- nsegs = 2;
- in_iov[1].iov_base = rbuff;
- in_iov[1].iov_len = *rlen;
- } else {
- nsegs = 1;
- }
-
- cmd_t &cmd = *static_cast<cmd_t *>(out_iov[0].iov_base);
- cmd.data_size = static_cast<uint32_t>(payload_sz);
- LOG_D("Sending command %d", cmd.cmd);
-
- Connection con;
-
- if (!con.connect(SOCK_PATH)) {
- LOG_E("Failed to connect to daemon!");
- return MC_DRV_ERR_DAEMON_SOCKET;
- }
-
- if (con.writeMsg(out_iov, static_cast<uint32_t>(out_iovcnt)) <= 0) {
- LOG_E("Failed to send data to daemon");
- return MC_DRV_ERR_DAEMON_SOCKET;
- }
-
- length = con.readMsg(in_iov, nsegs, DAEMON_TIMEOUT);
- if (length <= 0) {
- LOG_E("Failed to get answer from daemon!");
- return MC_DRV_ERR_DAEMON_SOCKET;
- }
- if (length < (ssize_t)sizeof(ResponseHeader)) {
- LOG_E("Invalid length received from daemon!");
- return MC_DRV_ERR_DAEMON_SOCKET;
- }
- length -= sizeof(ResponseHeader);
-
- LOG_D("result is %x", rsp.result);
-
- // Return also the read size
- if(rsp.result == MC_DRV_OK && rlen != NULL)
- *rlen = length;
-
- return rsp.result;
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryStoreAuthToken(void *so, uint32_t size)
-{
- cmd_t cmd(MC_DRV_REG_WRITE_AUTH_TOKEN);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)},
- {so, size}
- };
- LOG_D("execute MC_DRV_REG_WRITE_AUTH_TOKEN");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov));
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryReadAuthToken(void *so, uint32_t *size)
-{
- cmd_t cmd(MC_DRV_REG_READ_AUTH_TOKEN);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)}
- };
- //__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "%s", MOBICORE_COMPONENT_BUILD_TAG);
- LOG_D("execute MC_DRV_REG_READ_AUTH_TOKEN");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov), so, size);
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryDeleteAuthToken(void)
-{
- cmd_t cmd(MC_DRV_REG_DELETE_AUTH_TOKEN);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)}
- };
- LOG_D("execute MC_DRV_REG_DELETE_AUTH_TOKEN");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov));
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryStoreRoot(void *so, uint32_t size)
-{
- cmd_t cmd(MC_DRV_REG_WRITE_ROOT_CONT);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)},
- {so, size}
- };
- LOG_D("execute MC_DRV_REG_WRITE_ROOT_CONT");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov));
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryReadRoot(void *so, uint32_t *size)
-{
- cmd_t cmd(MC_DRV_REG_READ_ROOT_CONT);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)}
- };
- LOG_D("execute MC_DRV_REG_READ_ROOT_CONT");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov), so, size);
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryCleanupRoot(void)
-{
- cmd_t cmd(MC_DRV_REG_DELETE_ROOT_CONT);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)}
- };
- LOG_D("execute MC_DRV_REG_DELETE_ROOT_CONT");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov));
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryStoreSp(mcSpid_t spid, void *so, uint32_t size)
-{
- cmd_t cmd(MC_DRV_REG_WRITE_SP_CONT);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)},
- {&spid, sizeof(spid)},
- {so, size}
- };
- LOG_D("execute MC_DRV_REG_WRITE_SP_CONT");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov));
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryReadSp(mcSpid_t spid, void *so, uint32_t *size)
-{
- cmd_t cmd(MC_DRV_REG_READ_SP_CONT);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)},
- {&spid, sizeof(spid)}
- };
- LOG_D("execute MC_DRV_REG_READ_SP_CONT");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov), so, size);
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryCleanupSp(mcSpid_t spid)
-{
- cmd_t cmd(MC_DRV_REG_DELETE_SP_CONT);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)},
- {&spid, sizeof(spid)},
- };
- LOG_D("execute MC_DRV_REG_DELETE_SP_CONT");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov));
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid,
- mcSpid_t spid, void *so, uint32_t size)
-{
- cmd_t cmd(MC_DRV_REG_WRITE_TL_CONT);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)},
- {const_cast<mcUuid_t *>(uuid), sizeof(*uuid)},
- {&spid, sizeof(spid)},
- {so, size}
- };
- LOG_D("execute MC_DRV_REG_WRITE_TL_CONT");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov));
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, void *blob, uint32_t size)
-{
- cmd_t cmd(MC_DRV_REG_STORE_TA_BLOB);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)},
- {&spid, sizeof(spid)},
- {blob, size}
- };
- LOG_D("execute MC_DRV_REG_STORE_TA_BLOB");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov));
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryReadTrustletCon(const mcUuid_t *uuid, mcSpid_t spid,
- void *so, uint32_t *size)
-{
- cmd_t cmd(MC_DRV_REG_READ_TL_CONT);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)},
- {const_cast<mcUuid_t *>(uuid), sizeof(*uuid)},
- {&spid, sizeof(spid)}
- };
- LOG_D("execute MC_DRV_REG_READ_TL_CONT");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov), so, size);
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryCleanupTrustlet(const mcUuid_t *uuid, const mcSpid_t spid)
-{
- cmd_t cmd(MC_DRV_REG_DELETE_TL_CONT);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)},
- {const_cast<mcUuid_t *>(uuid), sizeof(*uuid)},
- {const_cast<mcSpid_t *>(&spid), sizeof(spid)},
- };
- LOG_D("execute MC_DRV_REG_DELETE_TL_CONT");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov));
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryCleanupTA(const mcUuid_t *uuid)
-{
- cmd_t cmd(MC_DRV_REG_DELETE_TA_OBJS);
- struct iovec iov[] = {
- {&cmd, sizeof(cmd)},
- {const_cast<mcUuid_t *>(uuid), sizeof(*uuid)},
- };
- LOG_D("execute MC_DRV_REG_DELETE_TA_OBJS");
- return send_cmd_recv_data(iov, ARRAY_SIZE(iov));
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryStoreData(void *, uint32_t)
-{
- return MC_DRV_ERR_INVALID_PARAMETER;
-}
-
-//------------------------------------------------------------------------------
-mcResult_t mcRegistryReadData(uint32_t, const mcCid_t *, mcPid_t,
- mcSoDataCont_t *, uint32_t)
-{
- return MC_DRV_ERR_INVALID_PARAMETER;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// Standard
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <fstream>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-// <t-base
-#include "Mci/mcimcp.h"
-#include "mcVersionHelper.h"
-// Logging
-#include <log.h>
-// Driver
-#include "mc_user.h"
-#include "mc_admin.h"
-// Registry
-#include "PrivateRegistry.h"
-// Self
-#include "SecureWorld.h"
-
-MC_CHECK_VERSION(MCDRVMODULEAPI, 2, 1);
-#define MAX_SO_CONT_SIZE 512
-#define CRASHDUMP_PATH "/sys/kernel/debug/trustonic_tee/crashdump"
-
-#define MY_LOG_ERRNO(fmt, ...) \
- LOG_E("%s: %s " fmt, __func__, strerror(errno), ##__VA_ARGS__)
-
-struct SecureWorld::Impl {
- int device_fd;
- uint32_t command_id;
- bool keep_running;
- Impl(): device_fd(-1), command_id(0), keep_running(true) {}
-};
-
-SecureWorld::SecureWorld(): pimpl_(new Impl) {}
-
-SecureWorld::~SecureWorld() {
- delete pimpl_;
-}
-
-static void* getRootContainer(const struct mc_admin_request*,
- struct mc_admin_response* response,
- bool*) {
- void* data = ::malloc(MAX_SO_CONT_SIZE);
- uint32_t length = MAX_SO_CONT_SIZE;
-
- switch (mcRegistryReadRoot(data, &length)) {
- case MC_DRV_OK:
- response->length = length;
- response->error_no = 0;
- break;
- case MC_DRV_ERR_INVALID_PARAMETER:
- response->error_no = EINVAL;
- break;
- case MC_DRV_ERR_INVALID_DEVICE_FILE:
- response->error_no = ENOENT;
- break;
- default:
- // Some kind of default
- response->error_no = EPERM;
- }
-
- if (response->error_no) {
- ::free(data);
- return NULL;
- }
-
- LOG_D("Read root container, size: %u", response->length);
- return data;
-}
-
-static void* getSpContainer(const struct mc_admin_request* request,
- struct mc_admin_response* response,
- bool*) {
- void* data = ::malloc(MAX_SO_CONT_SIZE);
- uint32_t length = MAX_SO_CONT_SIZE;
-
- switch (mcRegistryReadSp(request->spid, data, &length)) {
- case MC_DRV_OK:
- response->length = length;
- response->error_no = 0;
- break;
- case MC_DRV_ERR_INVALID_PARAMETER:
- response->error_no = EINVAL;
- break;
- case MC_DRV_ERR_INVALID_DEVICE_FILE:
- response->error_no = ENOENT;
- break;
- default:
- // Some kind of default
- response->error_no = EPERM;
- }
-
- if (response->error_no) {
- ::free(data);
- return NULL;
- }
-
- LOG_D("Read SP container for %u, size: %u", request->spid, response->length);
- return data;
-}
-
-static void* getTrustletContainer(const struct mc_admin_request* request,
- struct mc_admin_response* response,
- bool*) {
- void* data = ::malloc(MAX_SO_CONT_SIZE);
- uint32_t length = MAX_SO_CONT_SIZE;
-
- const mcUuid_t* uuid = reinterpret_cast<const mcUuid_t*>(&request->uuid);
- switch (mcRegistryReadTrustletCon(uuid, request->spid, data, &length)) {
- case MC_DRV_OK:
- response->length = length;
- response->error_no = 0;
- break;
- case MC_DRV_ERR_INVALID_PARAMETER:
- response->error_no = EINVAL;
- break;
- case MC_DRV_ERR_INVALID_DEVICE_FILE:
- response->error_no = ENOENT;
- break;
- case MC_DRV_ERR_OUT_OF_RESOURCES:
- response->error_no = ENOMEM;
- break;
- default:
- // Some kind of default
- response->error_no = EPERM;
- }
-
- if (response->error_no) {
- ::free(data);
- return NULL;
- }
-
- LOG_D("Read trustlet container for %u, size: %u", response->spid, response->length);
- return data;
-}
-
-static void* mapTrustlet(const char* path, uint32_t* length,
- uint32_t* service_type) {
- int fd = ::open(path, O_RDONLY);
- if (fd < 0) {
- LOG_W("Cannot open trustlet %s (%d)", path, errno);
- return NULL;
- }
-
- void* data = NULL;
- *service_type = SERVICE_TYPE_ILLEGAL;
- do {
- struct stat stat;
- if (::fstat(fd, &stat) < 0) {
- MY_LOG_ERRNO("getting size for trustlet %s", path);
- break;
- }
-
- data = ::mmap(NULL, stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
- if (data == MAP_FAILED) {
- data = NULL;
- MY_LOG_ERRNO("mapping file to memory");
- break;
- }
-
- /* Give service type to driver so it knows how to allocate and copy */
- mclfHeaderV2_t* header = static_cast<mclfHeaderV2_t*>(data);
- *service_type = header->serviceType;
- *length = static_cast<uint32_t>(stat.st_size);
- } while (false);
-
- ::close(fd);
-
- return data;
-}
-
-static void* getTrustlet(const struct mc_admin_request* request,
- struct mc_admin_response* response,
- bool* is_mmapped) {
- *is_mmapped = true;
- const mcUuid_t* uuid = reinterpret_cast<const mcUuid_t*>(&request->uuid);
- std::string path;
-
- mcResult_t res = mcRegistryGetTrustletInfo(uuid, request->is_gp, &response->spid, path);
- switch (res) {
- case MC_DRV_OK:
- response->error_no = 0;
- break;
- case MC_DRV_ERR_INVALID_PARAMETER:
- response->error_no = EINVAL;
- break;
- case MC_DRV_ERR_TRUSTLET_NOT_FOUND:
- response->error_no = ENOENT;
- break;
- default:
- // Some kind of default
- response->error_no = EPERM;
- }
-
- if (response->error_no) {
- return NULL;
- }
-
- void* data = mapTrustlet(path.c_str(), &response->length,
- &response->service_type);
- if (!data) {
- response->error_no = errno;
- } else {
- LOG_D("Read spid %u and mmap'd trustlet from %s, total size: %u", response->spid, path.c_str(), response->length);
- }
- return data;
-}
-
-static void* logCrashDump(const struct mc_admin_request*,
- struct mc_admin_response* response,
- bool*) {
- std::ifstream crashdump(CRASHDUMP_PATH);
- if (!crashdump.is_open()) {
- MY_LOG_ERRNO("opening crash dump");
- response->error_no = errno;
- return NULL;
- }
-
- LOG_E("<t-base halted. Status dump:");
- std::string line;
- while (std::getline(crashdump, line)) {
- LOG_I("%s", line.c_str());
- }
-
- return NULL;
-}
-
-int SecureWorld::open() {
- pimpl_->device_fd = ::open("/dev/" MC_ADMIN_DEVNODE, O_RDWR);
- if (pimpl_->device_fd < 0) {
- MY_LOG_ERRNO("opening admin device");
- return -1;
- }
-
- LOG_D("Check version of <t-base driver");
- struct mc_admin_driver_info info;
- if (ioctl(pimpl_->device_fd, MC_ADMIN_IO_GET_INFO, &info) != 0) {
- LOG_ERRNO("ioctl MC_ADMIN_IO_GET_INFO");
- ::close(pimpl_->device_fd);
- return -1;
- }
-
- char *errmsg;
- if (!checkVersionOkMCDRVMODULEAPI(info.drv_version, &errmsg)) {
- LOG_E("%s", errmsg);
- ::close(pimpl_->device_fd);
- return -1;
- }
-
- LOG_D("%s", errmsg);
- pimpl_->command_id = info.initial_cmd_id;
-
- // We wait 10 times 100ms for the device file to appear
- int counter = 10;
- do {
- struct stat st;
-
- int ret = ::stat("/dev/" MC_USER_DEVNODE, &st);
- if (!ret) {
- break;
- }
-
- if (errno != ENOENT) {
- MY_LOG_ERRNO("stat'ing user device");
- return -1;
- }
-
- /* Device driver didn't appear yet: give some time */
- usleep(100000);
- } while (counter--);
-
- if (counter == 0) {
- LOG_E("timed out while waiting for user device to appear");
- return -1;
- }
-
- LOG_D("TEE is ready");
- return 0;
-}
-
-void SecureWorld::close() {
- ::close(pimpl_->device_fd);
-}
-
-int SecureWorld::loadDriver(const char* path) {
- struct mc_admin_load_info info;
- uint32_t service_type;
-
- void* data = mapTrustlet(path, &info.length, &service_type);
- if (!data) {
- return -1;
- }
-
- LOG_D("Load secure driver %s of size %d", path, info.length);
- info.address = reinterpret_cast<uintptr_t>(data);
- info.spid = 0;
-
- int ret = ioctl(pimpl_->device_fd, MC_ADMIN_IO_LOAD_DRIVER, &info);
- if (ret != 0) {
- LOG_ERRNO("ioctl MC_ADMIN_IO_LOAD_DRIVER");
- }
-
- // Free memory occupied by Trustlet data
- ::munmap(data, info.length);
- return ret == 0;
-}
-
-int SecureWorld::loadToken(const void *data, uint32_t length) {
- struct mc_admin_load_info token;
-
- LOG_D("Load authentication token %p of size %u", data, length);
- token.address = reinterpret_cast<uintptr_t>(data);
- token.length = length;
-
- int rc = ioctl(pimpl_->device_fd, MC_ADMIN_IO_LOAD_TOKEN, &token);
- if (rc != 0) {
- LOG_ERRNO("ioctl MC_ADMIN_IO_LOAD_TOKEN");
- return -1;
- }
-
- return 0;
-}
-
-int SecureWorld::LoadCheck(mcSpid_t spid, const void *data, uint32_t length) {
- struct mc_admin_load_info info;
-
- LOG_D("Load secure object %p, length %u, spid %x", data, length, spid);
- info.spid = spid;
- info.address = reinterpret_cast<uintptr_t>(data);
- info.length = length;
-
- int rc = ioctl(pimpl_->device_fd, MC_ADMIN_IO_LOAD_CHECK, &info);
- if (rc != 0) {
- LOG_ERRNO("ioctl MC_ADMIN_IO_LOAD_CHECK");
- return -1;
- }
-
- return 0;
-}
-
-int SecureWorld::listen()
-{
- int rc = 0;
-
- while (pimpl_->keep_running) {
- struct mc_admin_request request;
-
- rc = ioctl(pimpl_->device_fd, MC_ADMIN_IO_GET_DRIVER_REQUEST, &request);
- if (rc) {
- if (errno == EINTR) {
- LOG_D("Giving up on signal");
- } else {
- LOG_ERRNO("Getting request from driver");
- }
- break;
- }
-
- LOG_D("Request %d received (ID %u)", request.command, request.request_id);
- if (pimpl_->command_id != request.request_id) {
- LOG_E("Request ID counters are not synchronised (expected %u, got %u)", pimpl_->command_id, request.request_id);
- break;
- }
-
- struct mc_admin_response response;
- memset(&response, 0, sizeof(response));
- response.request_id = pimpl_->command_id++;
- void* response_data = NULL;
- bool is_mmapped = false; // Response data needs freeing
- switch (request.command) {
- case MC_DRV_GET_ROOT_CONTAINER:
- response_data = getRootContainer(&request, &response, &is_mmapped);
- break;
- case MC_DRV_GET_SP_CONTAINER:
- response_data = getSpContainer(&request, &response, &is_mmapped);
- break;
- case MC_DRV_GET_TRUSTLET_CONTAINER:
- response_data = getTrustletContainer(&request, &response, &is_mmapped);
- break;
- case MC_DRV_GET_TRUSTLET:
- response_data = getTrustlet(&request, &response, &is_mmapped);
- break;
- case MC_DRV_SIGNAL_CRASH:
- logCrashDump(&request, &response, &is_mmapped);
- break;
- default:
- LOG_E("Unknown command");
- response.error_no = EBADRQC;
- }
-
- ssize_t ret = ::write(pimpl_->device_fd, &response, sizeof(response));
- if (ret != sizeof(response)) {
- LOG_ERRNO("Sending response to driver");
- ret = -1;
- } else if (response.length > 0) {
- ssize_t expected_length = response.length;
- ret = ::write(pimpl_->device_fd, response_data, response.length);
- if (ret != expected_length) {
- LOG_ERRNO("Sending response data to driver");
- ret = -1;
- }
- }
-
- if (response_data && is_mmapped) {
- ::munmap(response_data, response.length);
- } else {
- ::free(response_data);
- }
- }
-
- return rc;
-}
-
-void SecureWorld::stopListening() {
- pimpl_->keep_running = false;
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MOBICORE_SECURE_WORLD_H_
-#define MOBICORE_SECURE_WORLD_H_
-
-#include <memory>
-
-#include <mcSpid.h>
-
-class SecureWorld {
- struct Impl;
- Impl* const pimpl_;
-public:
- SecureWorld();
- ~SecureWorld();
- int open();
- void close();
- int loadDriver(
- const char* path);
- int loadToken(
- const void* data,
- uint32_t length);
- int LoadCheck(
- mcSpid_t spid,
- const void *data,
- uint32_t length);
- // Does not exit until stopListening() is called
- int listen();
- void stopListening();
-};
-
-#endif // MOBICORE_SECURE_WORLD_H_
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/**
- * Connection server.
- *
- * Handles incoming socket connections from registry library clients.
- */
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <log.h>
-
-#include "Server.h"
-
-const char * const Server::m_server_name = "McDaemon.Server";
-
-class LockGuard {
- pthread_mutex_t* mutex_;
-public:
- LockGuard(pthread_mutex_t* mutex): mutex_(mutex) {
- pthread_mutex_lock(mutex_);
- }
- ~LockGuard() {
- pthread_mutex_unlock(mutex_);
- }
-};
-
-//------------------------------------------------------------------------------
-Server::Server(ConnectionHandler *handler, const char *localAddr,
- const int listen_queue_sz) :
- m_serverSock(-1),
- m_connectionHandler(handler)
-{
- // Fill in address structure and bind to socket
- struct sockaddr_un serverAddr;
- int sock;
-
- pthread_mutex_init(&m_close_lock, NULL);
- if(localAddr == NULL || strlen(localAddr) == 0 || listen_queue_sz <= 0)
- return;
-
- LOG_D("Server: start listening on socket %s", localAddr);
-
- // Open a socket (a UNIX domain stream socket)
- sock = socket(AF_UNIX, SOCK_STREAM, 0);
- if (sock < 0) {
- LOG_ERRNO("Can't open stream socket, because socket");
- return;
- }
-
- serverAddr.sun_family = AF_UNIX;
- strncpy(serverAddr.sun_path, localAddr, sizeof(serverAddr.sun_path) - 1);
-
- socklen_t len = static_cast<socklen_t>(strlen(serverAddr.sun_path) +
- sizeof(serverAddr.sun_family));
- // Make the socket in the Abstract Domain(no path but everyone can connect)
- serverAddr.sun_path[0] = 0;
-
- if (bind(sock, reinterpret_cast<struct sockaddr*>(&serverAddr), len) == 0) {
- if (listen(sock, listen_queue_sz) == 0) {
- m_serverSock = sock;
- return;
- }
- else
- LOG_ERRNO("listen");
- } else
- LOG_ERRNO("Binding to server socket failed, because bind");
-
- close(sock);
-}
-
-//------------------------------------------------------------------------------
-void Server::run()
-{
- sigset_t sigmask;
- sigemptyset(&sigmask);
- sigaddset(&sigmask, SIGUSR1);
- pthread_sigmask(SIG_UNBLOCK, &sigmask, NULL);
-
- LOG_D("Server::run()====");
-
- while ( valid() && !shouldTerminate() ) {
- fd_set fdReadSockets;
-
- // Clear FD for select()
- FD_ZERO(&fdReadSockets);
-
- LockGuard lock(&m_close_lock);
-
- // Select server socket descriptor
- FD_SET(m_serverSock, &fdReadSockets);
- int maxSocketDescriptor = m_serverSock;
-
- // Select socket descriptor of all connections
- for (auto it = m_peerConnections.begin(); it != m_peerConnections.end(); it++) {
- auto& conn = *it;
- int peerSocket = conn->socket();
- FD_SET(peerSocket, &fdReadSockets);
- if (peerSocket > maxSocketDescriptor)
- maxSocketDescriptor = peerSocket;
- }
-
- // Wait for activities, select() returns the number of sockets
- // which require processing
- LOG_D(" Server: waiting on sockets");
- int numSockets = select(maxSocketDescriptor + 1,
- &fdReadSockets, NULL, NULL, NULL);
- // Check if select failed
- if (numSockets < 0) {
- int err = errno;
- if (err == EINTR) {
- LOG_D("Giving up on signal");
- } else {
- LOG_ERRNO("select failed");
- }
- continue;
- }
-
- // actually, this should not happen.
- if (0 == numSockets) {
- LOG_W(" Server: select() returned 0, spurious event?.");
- continue;
- }
-
- LOG_D(" Server: events on %d socket(s).", numSockets);
-
- // Check if a new client connected to the server socket
- if (FD_ISSET(m_serverSock, &fdReadSockets)) {
- LOG_D(" Server: new connection attempt.");
- numSockets--;
-
- int clientSock = ::accept(m_serverSock, NULL, NULL);
- if (clientSock > 0) {
- Connection *connection = new Connection(clientSock);
- m_peerConnections.push_back(connection);
- LOG_D(" Server: new socket connection established and start listening.");
- } else
- LOG_ERRNO("accept");
-
- // we can ignore any errors from accepting a new connection.
- // If this fail, the client has to deal with it, we are done
- // and nothing has changed.
- }
-
- // Handle traffic on existing client connections
- auto it = m_peerConnections.begin();
- while ((it != m_peerConnections.end()) && (numSockets > 0)) {
- Connection *connection = *it;
-
- if (!FD_ISSET(connection->socket(), &fdReadSockets)) {
- ++it;
- continue;
- }
-
- numSockets--;
-
- // the connection will be terminated if command processing
- // fails
- if (!m_connectionHandler->handleConnection(*connection)) {
- LOG_D(" Server: dropping connection.");
-
- //Inform the driver
- m_connectionHandler->dropConnection(*connection);
-
- // Remove connection from list
- it = m_peerConnections.erase(it);
- delete connection;
- } else
- it++;
- }
- }
-
- stop();
-
- LOG_D("Exiting Server");
-}
-
-//------------------------------------------------------------------------------
-Server::~Server()
-{
- LOG_D("Destroying Server object");
- stop();
-}
-
-void Server::stop()
-{
- LockGuard lock(&m_close_lock);
-
- // Destroy all client connections
- while(!m_peerConnections.empty()) {
- Connection *c = m_peerConnections.front();
- m_peerConnections.pop_front();
- delete c;
- }
-
- // Shut down the server socket
- if(m_serverSock != -1) {
- close(m_serverSock);
- m_serverSock = -1;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef SERVER_H_
-#define SERVER_H_
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <string>
-#include <cstdio>
-#include <pthread.h>
-
-#include <list>
-
-#include "CThread.h"
-#include "ConnectionHandler.h"
-
-/** Number of incoming connections that can be queued.
- * Additional clients will generate the error ECONNREFUSED. */
-#define LISTEN_QUEUE_LEN 8
-
-typedef std::list<Connection *> connectionList_t;
-typedef connectionList_t::iterator connectionIterator_t;
-
-class Server: public CThread
-{
-public:
- /**
- * Server contructor.
- *
- * @param connectionHanler Connection handler to pass incoming connections to.
- * @param localAdrerss Pointer to a zero terminated
- * string containing the file to listen to.
- */
- Server(ConnectionHandler *connectionHandler,
- const char *localAddr, const int listen_queue_sz = LISTEN_QUEUE_LEN);
-
- /**
- * Server destructor.
- * All available connections will be terminated. Resources will be freed.
- */
- virtual ~Server();
-
- /**
- * Start server and listen for incoming connections.
- * Implements the central socket server loop.
- * Incoming connections will be stored.
- */
- virtual void run();
-
- void start()
- {
- CThread::start(Server::m_server_name);
- }
-
- void stop();
-
- bool valid() const
- {
- return m_serverSock != -1;
- }
-protected:
-
- int m_serverSock;
- /**< Connection handler registered to the server */
- ConnectionHandler * const m_connectionHandler;
-
-private:
- pthread_mutex_t m_close_lock;
- connectionList_t m_peerConnections; /**< Connections to devices */
- static const char * const m_server_name;
-};
-
-#endif /* SERVER_H_ */
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef MOBICORE_COMPONENT_BUILD_TAG
-#define MOBICORE_COMPONENT_BUILD_TAG \
- "t-base-EXYNOS64-Android-310B-V006-20160331_140301_7136"
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file drSecureFS_Api.h
- * @brief Contains TCI definitions shared with FSD2 daemon and SPT2 TA
- *
- */
-
-#ifndef __DRSFSAPI_H__
-#define __DRSFSAPI_H__
-
-#include "service_delegation_protocol.h"
-
-
-/*
- * Driver ID. This is managed by Trustonic
- */
-#define DRV_STH2_ID 0x0104
-
-/**
- * Driver UUID. Update accordingly after reserving UUID
- */
-#define DRV_SFS_UUID { { 0x07, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20 } }
-
-/*
- * TCI definitions, relayed by SPT2 TA from FSD2 daemon
- */
-#define EXCHANGE_BUFFER_INSTRUCTIONS_NB 1000
-
-/**
- * This type indicates the state of the daemon
- */
-typedef enum {
- STH2_DAEMON_LISTENING = 0,
- STH2_DAEMON_PROCESSING = 1,
-} STH2_daemon_state;
-
-/**
- * TCI message data.
- */
-typedef struct {
- /* indicates that the secure driver has sent instructions to the normal world daemon.
- * This variable is updated in the following ways:
- * - Initially set to LISTENING by the daemon before it connects to the secure driver.
- * - The secure driver switches the state from LISTENING to PROCESSING when it wants the daemon to process instructions.
- * - The daemon switches the state from PROCESSING to LISTENING when it has finished processing the instructions.
- */
- STH2_daemon_state nDaemonState;
- /* sector size
- * set initially by the secure world.
- * In TF: `g_nSectorSize`.
- */
- uint32_t nSectorSize;
-
- /* workspace length
- * set initially by the daemon.
- * In TF: calculated from the exchange buffer size.
- */
- uint32_t nWorkspaceLength;
- /* administrative data
- * written by the normal world.
- * In TF: `g_pExchangeBuffer->sAdministrativeData`.
- */
- DELEGATION_ADMINISTRATIVE_DATA sAdministrativeData;
- /* number of instructions to be executed by the daemon.
- * Set by the secure world for each command.
- * In TF: the output `size` of `params[1]`
- */
- uint32_t nInstructionsBufferSize;
- /* instruction list
- * set by the secure world.
- * In TF: `g_pExchangeBuffer->sInstructions`.
- */
- uint32_t sInstructions[EXCHANGE_BUFFER_INSTRUCTIONS_NB];
- /* sectors content, set by either side depending on the instruction.
- * The workspace size is hard-coded based on the maximum sector size (4096).
- * In TF: `g_pExchangeBuffer->sWorkspace'
- */
- uint8_t sWorkspace[];
-} STH2_delegation_exchange_buffer_t;
-
-
-#endif // __DRSFSAPI_H__
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef DAEMON_VERSION_H_
-#define DAEMON_VERSION_H_
-
-#define DAEMON_VERSION_MAJOR 0
-#define DAEMON_VERSION_MINOR 4
-
-#endif /** DAEMON_VERSION_H_ */
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MC_ADMIN_IOCTL_H__
-#define __MC_ADMIN_IOCTL_H__
-
-#include <linux/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MC_ADMIN_DEVNODE "mobicore"
-
-/* Driver/daemon commands */
-enum {
- /* Command 0 is reserved */
- MC_DRV_GET_ROOT_CONTAINER = 1,
- MC_DRV_GET_SP_CONTAINER = 2,
- MC_DRV_GET_TRUSTLET_CONTAINER = 3,
- MC_DRV_GET_TRUSTLET = 4,
- MC_DRV_SIGNAL_CRASH = 5,
-};
-
-/* MobiCore IOCTL magic number */
-#define MC_IOC_MAGIC 'M'
-
-struct mc_admin_request {
- __u32 request_id; /* Unique request identifier */
- __u32 command; /* Command to daemon */
- struct mc_uuid_t uuid; /* UUID of trustlet, if relevant */
- __u32 is_gp; /* Whether trustlet is GP */
- __u32 spid; /* SPID of trustlet, if relevant */
-};
-
-struct mc_admin_response {
- __u32 request_id; /* Unique request identifier */
- __u32 error_no; /* Errno from daemon */
- __u32 spid; /* SPID of trustlet, if relevant */
- __u32 service_type; /* Type of trustlet being returned */
- __u32 length; /* Length of data to get */
- /* Any data follows */
-};
-
-struct mc_admin_driver_info {
- /* Version, and something else..*/
- __u32 drv_version;
- __u32 initial_cmd_id;
-};
-
-struct mc_admin_load_info {
- __u32 spid; /* SPID of trustlet, if relevant */
- __u64 address; /* Address of the data */
- __u32 length; /* Length of data to get */
-};
-
-#define MC_ADMIN_IO_GET_DRIVER_REQUEST \
- _IOR(MC_IOC_MAGIC, 0, struct mc_admin_request)
-#define MC_ADMIN_IO_GET_INFO \
- _IOR(MC_IOC_MAGIC, 1, struct mc_admin_driver_info)
-#define MC_ADMIN_IO_LOAD_DRIVER \
- _IOW(MC_IOC_MAGIC, 2, struct mc_admin_load_info)
-#define MC_ADMIN_IO_LOAD_TOKEN \
- _IOW(MC_IOC_MAGIC, 3, struct mc_admin_load_info)
-#define MC_ADMIN_IO_LOAD_CHECK \
- _IOW(MC_IOC_MAGIC, 4, struct mc_admin_load_info)
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __MC_ADMIN_IOCTL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _MC_USER_H_
-#define _MC_USER_H_
-
-#define MCDRVMODULEAPI_VERSION_MAJOR 2
-#define MCDRVMODULEAPI_VERSION_MINOR 10
-
-#include <linux/types.h>
-
-#define MC_USER_DEVNODE "mobicore-user"
-
-/** Maximum length of MobiCore product ID string. */
-#define MC_PRODUCT_ID_LEN 64
-
-/** Number of buffers that can be mapped at once */
-#define MC_MAP_MAX 4
-
-/** Max length for buffers */
-#define BUFFER_LENGTH_MAX 0x100000
-
-/** Flags for buffers to map (aligned on GP) */
-#define MC_IO_MAP_INPUT 0x1
-#define MC_IO_MAP_OUTPUT 0x2
-#define MC_IO_MAP_INPUT_OUTPUT (MC_IO_MAP_INPUT | MC_IO_MAP_OUTPUT)
-
-/*
- * Universally Unique Identifier (UUID) according to ISO/IEC 11578.
- */
-struct mc_uuid_t {
- __u8 value[16]; /* Value of the UUID. */
-};
-
-/*
- * GP TA login types.
- */
-enum mc_login_type {
- LOGIN_PUBLIC = 0,
- LOGIN_USER,
- LOGIN_GROUP,
- LOGIN_APPLICATION = 4,
- LOGIN_USER_APPLICATION,
- LOGIN_GROUP_APPLICATION,
-};
-
-/*
- * GP TA identity structure.
- */
-struct mc_identity {
- enum mc_login_type login_type;
- union {
- __u8 login_data[16];
- gid_t gid; /* Requested group id */
- struct {
- uid_t euid;
- uid_t ruid;
- } uid;
- };
- pid_t pid; /* Client, when using proxy */
-};
-
-/*
- * Data exchange structure of the MC_IO_OPEN_SESSION ioctl command.
- */
-struct mc_ioctl_open_session {
- struct mc_uuid_t uuid; /* trustlet uuid */
- __u32 is_gp_uuid; /* uuid is for GP TA */
- __u32 sid; /* session id (out) */
- __u64 tci; /* tci buffer pointer */
- __u32 tcilen; /* tci length */
- struct mc_identity identity; /* GP TA identity */
-};
-
-/*
- * Data exchange structure of the MC_IO_OPEN_TRUSTLET ioctl command.
- */
-struct mc_ioctl_open_trustlet {
- __u32 sid; /* session id (out) */
- __u32 spid; /* trustlet spid */
- __u64 buffer; /* trustlet binary pointer */
- __u32 tlen; /* binary length */
- __u64 tci; /* tci buffer pointer */
- __u32 tcilen; /* tci length */
-};
-
-/*
- * Data exchange structure of the MC_IO_WAIT ioctl command.
- */
-struct mc_ioctl_wait {
- __u32 sid; /* session id (in) */
- __s32 timeout; /* notification timeout */
- __u32 partial; /* for proxy server to retry silently */
-};
-
-/*
- * Data exchange structure of the MC_IO_ALLOC ioctl command.
- */
-struct mc_ioctl_alloc {
- __u32 len; /* buffer length */
- __u32 handle; /* user handle for the buffer (out) */
-};
-
-/*
- * Buffer mapping incoming and outgoing information.
- */
-struct mc_ioctl_buffer {
- __u64 va; /* user space address of buffer */
- __u32 len; /* buffer length */
- __u64 sva; /* SWd virt address of buffer (out) */
- __u32 flags; /* buffer flags */
-};
-
-/*
- * Data exchange structure of the MC_IO_MAP and MC_IO_UNMAP ioctl commands.
- */
-struct mc_ioctl_map {
- __u32 sid; /* session id */
- struct mc_ioctl_buffer bufs[MC_MAP_MAX]; /* buffers info */
-};
-
-/*
- * Data exchange structure of the MC_IO_ERR ioctl command.
- */
-struct mc_ioctl_geterr {
- __u32 sid; /* session id */
- __s32 value; /* error value (out) */
-};
-
-/*
- * Global MobiCore Version Information.
- */
-struct mc_version_info {
- char product_id[MC_PRODUCT_ID_LEN]; /** Product ID string */
- __u32 version_mci; /** Mobicore Control Interface */
- __u32 version_so; /** Secure Objects */
- __u32 version_mclf; /** MobiCore Load Format */
- __u32 version_container; /** MobiCore Container Format */
- __u32 version_mc_config; /** MobiCore Config. Block Format */
- __u32 version_tl_api; /** MobiCore Trustlet API */
- __u32 version_dr_api; /** MobiCore Driver API */
- __u32 version_nwd; /** This Driver */
-};
-
-/*
- * defines for the ioctl mobicore driver module function call from user space.
- */
-/* MobiCore IOCTL magic number */
-#define MC_IOC_MAGIC 'M'
-
-/*
- * Implement corresponding functions from user api
- */
-#define MC_IO_OPEN_SESSION \
- _IOWR(MC_IOC_MAGIC, 0, struct mc_ioctl_open_session)
-#define MC_IO_OPEN_TRUSTLET \
- _IOWR(MC_IOC_MAGIC, 1, struct mc_ioctl_open_trustlet)
-#define MC_IO_CLOSE_SESSION _IO(MC_IOC_MAGIC, 2)
-#define MC_IO_NOTIFY _IO(MC_IOC_MAGIC, 3)
-#define MC_IO_WAIT _IOW(MC_IOC_MAGIC, 4, struct mc_ioctl_wait)
-#define MC_IO_MAP _IOWR(MC_IOC_MAGIC, 5, struct mc_ioctl_map)
-#define MC_IO_UNMAP _IOW(MC_IOC_MAGIC, 6, struct mc_ioctl_map)
-#define MC_IO_ERR _IOWR(MC_IOC_MAGIC, 7, struct mc_ioctl_geterr)
-#define MC_IO_HAS_SESSIONS _IO(MC_IOC_MAGIC, 8)
-#define MC_IO_VERSION _IOR(MC_IOC_MAGIC, 9, struct mc_version_info)
-
-#endif /* _MC_USER_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file service_delegation_protocol.h
- * @brief Delegation protocol definitions
- *
- */
-
-#ifndef __SERVICE_DELEGATION_PROTOCOL_H__
-#define __SERVICE_DELEGATION_PROTOCOL_H__
-
-
-
-/* Instruction codes */
-#define DELEGATION_INSTRUCTION_SHUTDOWN 0xF0
-#define DELEGATION_INSTRUCTION_NOTIFY 0xE0
-
-/* Partition-specific instruction codes (high-nibble encodes the partition identifier) */
-#define DELEGATION_INSTRUCTION_PARTITION_CREATE 0x01
-#define DELEGATION_INSTRUCTION_PARTITION_OPEN 0x02
-#define DELEGATION_INSTRUCTION_PARTITION_READ 0x03
-#define DELEGATION_INSTRUCTION_PARTITION_WRITE 0x04
-#define DELEGATION_INSTRUCTION_PARTITION_SET_SIZE 0x05
-#define DELEGATION_INSTRUCTION_PARTITION_SYNC 0x06
-#define DELEGATION_INSTRUCTION_PARTITION_CLOSE 0x07
-#define DELEGATION_INSTRUCTION_PARTITION_DESTROY 0x08
-
-#define DELEGATION_NOTIFY_TYPE_ERROR 0x000000E1
-#define DELEGATION_NOTIFY_TYPE_WARNING 0x000000E2
-#define DELEGATION_NOTIFY_TYPE_INFO 0x000000E3
-#define DELEGATION_NOTIFY_TYPE_DEBUG 0x000000E4
-
-typedef struct
-{
- uint32_t nInstructionID;
-} DELEGATION_GENERIC_INSTRUCTION;
-
-typedef struct
-{
- uint32_t nInstructionID;
- uint32_t nMessageType;
- uint32_t nMessageSize;
- char nMessage[4];
-} DELEGATION_NOTIFY_INSTRUCTION;
-
-typedef struct
-{
- uint32_t nInstructionID;
- uint32_t nSectorID;
- uint32_t nWorkspaceOffset;
-} DELEGATION_RW_INSTRUCTION;
-
-typedef struct
-{
- uint32_t nInstructionID;
- uint32_t nNewSize;
-} DELEGATION_SET_SIZE_INSTRUCTION;
-
-typedef union
-{
- DELEGATION_GENERIC_INSTRUCTION sGeneric;
- DELEGATION_NOTIFY_INSTRUCTION sNotify;
- DELEGATION_RW_INSTRUCTION sReadWrite;
- DELEGATION_SET_SIZE_INSTRUCTION sSetSize;
-} DELEGATION_INSTRUCTION;
-
-typedef struct
-{
- uint32_t nSyncExecuted;
- uint32_t nPartitionErrorStates[16];
- uint32_t nPartitionOpenSizes[16];
-} DELEGATION_ADMINISTRATIVE_DATA;
-
-#endif /* __SERVICE_DELEGATION_PROTOCOL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file sfs_error.h
- * @brief error codes used for levels 0-2
- *
- */
-
-#ifndef __SFS_ERROR_H__
-#define __SFS_ERROR_H__
-
-#include "sfs_type.h"
-
-#if defined (DRIVER)
-
-#include "tee_error.h"
-
-/* Existing TEE codes */
-#define S_SUCCESS TEE_SUCCESS
-#define S_ERROR_GENERIC TEE_ERROR_GENERIC
-#define S_ERROR_CANCEL TEE_ERROR_CANCEL
-#define S_ERROR_ACCESS_CONFLICT TEE_ERROR_ACCESS_CONFLICT
-#define S_ERROR_BAD_PARAMETERS TEE_ERROR_BAD_PARAMETERS
-#define S_ERROR_BAD_STATE TEE_ERROR_BAD_STATE
-#define S_ERROR_ITEM_NOT_FOUND TEE_ERROR_ITEM_NOT_FOUND
-#define S_ERROR_NOT_SUPPORTED TEE_ERROR_NOT_SUPPORTED
-#define S_ERROR_OUT_OF_MEMORY TEE_ERROR_OUT_OF_MEMORY
-#define S_ERROR_COMMUNICATION TEE_ERROR_COMMUNICATION
-#define S_ERROR_SHORT_BUFFER TEE_ERROR_SHORT_BUFFER
-#define S_ERROR_STORAGE_NO_SPACE TEE_ERROR_STORAGE_NO_SPACE
-
-/* Implementation-specific errors */
-#define S_ERROR_STORAGE_ITEM_EXISTS ((S_RESULT)TEE_TBASE_ERROR_STORAGE_ITEM_EXISTS)
-#define S_ERROR_STORAGE_CORRUPTED ((S_RESULT)TEE_TBASE_ERROR_STORAGE_CORRUPTED)
-#define S_ERROR_STORAGE_UNREACHABLE ((S_RESULT)TEE_TBASE_ERROR_STORAGE_UNREACHABLE)
-#define S_ERROR_NO_MORE_HANDLES ((S_RESULT)TEE_TBASE_ERROR_NO_MORE_HANDLES)
-#define S_ERROR_ITEM_EXISTS ((S_RESULT)TEE_TBASE_ERROR_ITEM_EXISTS)
-
-#else
-
-#include "tee_client_error.h"
-
-/* Existing TEEC codes */
-#define S_SUCCESS TEEC_SUCCESS
-#define S_ERROR_GENERIC TEEC_ERROR_GENERIC
-#define S_ERROR_CANCEL TEEC_ERROR_CANCEL
-#define S_ERROR_ACCESS_CONFLICT TEEC_ERROR_ACCESS_CONFLICT
-#define S_ERROR_BAD_PARAMETERS TEEC_ERROR_BAD_PARAMETERS
-#define S_ERROR_BAD_STATE TEEC_ERROR_BAD_STATE
-#define S_ERROR_ITEM_NOT_FOUND TEEC_ERROR_ITEM_NOT_FOUND
-#define S_ERROR_NOT_SUPPORTED TEEC_ERROR_NOT_SUPPORTED
-#define S_ERROR_OUT_OF_MEMORY TEEC_ERROR_OUT_OF_MEMORY
-#define S_ERROR_COMMUNICATION TEEC_ERROR_COMMUNICATION
-#define S_ERROR_SHORT_BUFFER TEEC_ERROR_SHORT_BUFFER
-#define S_ERROR_STORAGE_NO_SPACE TEEC_ERROR_STORAGE_NO_SPACE
-
-/* Implementation-specific errors */
-#define S_ERROR_STORAGE_ITEM_EXISTS ((S_RESULT)TEEC_TBASE_ERROR_STORAGE_ITEM_EXISTS)
-#define S_ERROR_STORAGE_CORRUPTED ((S_RESULT)TEEC_TBASE_ERROR_STORAGE_CORRUPTED)
-#define S_ERROR_STORAGE_UNREACHABLE ((S_RESULT)TEEC_TBASE_ERROR_STORAGE_UNREACHABLE)
-#define S_ERROR_NO_MORE_HANDLES ((S_RESULT)TEEC_TBASE_ERROR_NO_MORE_HANDLES)
-#define S_ERROR_ITEM_EXISTS ((S_RESULT)TEEC_TBASE_ERROR_ITEM_EXISTS)
-
-#endif /* #if defined (DRIVER) */
-
-
-#endif //__SFS_ERROR_H__
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __SFS_TYPES_H__
-#define __SFS_TYPES_H__
-
-#if defined (DRIVER)
-#include "tee_type.h"
-#endif
-
-/* These definitions are for common port */
-typedef uint32_t S_RESULT;
-typedef uint32_t S_HANDLE;
-typedef S_HANDLE SM_HANDLE;
-#define S_HANDLE_NULL ((S_HANDLE)0)
-#define SM_HANDLE_INVALID S_HANDLE_NULL
-
-/** Definition of an UUID (from RFC 4122 http://www.ietf.org/rfc/rfc4122.txt) */
-typedef struct S_UUID
-{
- uint32_t timeLow;
- uint16_t timeMid;
- uint16_t timeHiAndVersion;
- uint8_t clockSeqAndNode[8];
-} S_UUID;
-
-/* Static SFS configuration */
-typedef struct
-{
-
- uint32_t nFileSystemCacheSize; /* filesystem.cache.size */
- uint32_t nFileSystemSectorSize; /* filesystem.sector.size */
- uint32_t nFileSystemSizeMax; /* filesystem.size.max in KB */
-}
-SYSTEM_STATIC_CFG;
-
-
-extern SYSTEM_STATIC_CFG g_sSystemStaticCfg;
-
-/**
- * Return the difference {p1}-{p2} in bytes
- **/
-#define SPointerDiff(p1, p2) ((int32_t)(((uint32_t)p1) - ((uint32_t)p2)))
-
-/**
- * Add an offset of {n} bytes to the pointer {p}
- **/
-#define SPointerAdd(p, n) ((void*)(((uint8_t*)(p)) + (int32_t)(n)))
-
-
-#if defined (DRIVER)
- #include "DrApi/DrApi.h"
-
-/* These definitions are for TDriver port */
- #define _SLogTrace(...) drDbgPrintLnf(__VA_ARGS__)
- #define SLogTrace(...) drDbgPrintLnf(__VA_ARGS__)
- #define SLogError(...) drDbgPrintLnf(__VA_ARGS__)
- //#define SLogError(...) drApiPrintLnf(__VA_ARGS__)
- #define SLogWarning(...) drDbgPrintLnf(__VA_ARGS__)
- #define __INCLUDE_DEBUG
- _EXTERN_C _NORETURN void _doAssert(
- const char *expr,
- const char *file,
- const uint32_t line
- );
- #define SAssert(cond) \
- do{if (!(cond)){_doAssert(NULL,__FILE__, __LINE__);}} while(FALSE)
-
- _DRAPI_EXTERN_C _DRAPI_NORETURN void drApiExit(uint32_t exitCode);
- #define SPanic(exitCode) drApiExit(exitCode)
-
- #define SMemAllocEx(param,size) drApiMalloc(size,0)
- #define SMemAlloc(size) drApiMalloc(size,0)
- #define SMemFree(ptr) drApiFree(ptr)
- #define SMemMove(a,b,c) memmove(a,b,c)
- #define SMemCompare(a,b,c) memcmp(a,b,c)
- #define SMemFill(a,b,c) memset(a,b,c)
- #define SMemRealloc(a, b) drApiRealloc(a, b)
-
- #define setError(...) drDbgPrintLnf(__VA_ARGS__)
- #define exosTraceError(...) drDbgPrintLnf(__VA_ARGS__)
-
- #define Trace(...) drDbgPrintLnf(__VA_ARGS__)
-
- #define Error(...) drDbgPrintLnf(__VA_ARGS__)
-
-#elif defined (TEST_SUITE_NAME)
-/* These definitions are for Test Suite port */
-/* Olivier, this is your part to update */
- #include <stdlib.h>
- #include <stdio.h>
-// #include "ssdi.h"
-
- #ifndef LOG_TAG
- #define LOG_TAG "sfs"
- #endif
-
- #include <log.h>
-// #undef LOG_I
-// #define LOG_I(fmt, args...) DUMMY_FUNCTION()
-
- #ifdef NDEBUG
- #define LOG(fmt, args...) DUMMY_FUNCTION()
- #else
- #define LOG(...) \
- (void) fprintf(stdout, __VA_ARGS__); (void) fflush(stdout)
- #endif
-
- #define setError(...) LOG(__VA_ARGS__)
- #define Trace(...) LOG(__VA_ARGS__)
-
-#endif /* #if defined (DRIVER) */
-
-#endif //__SFS_TYPES_H__
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef STH2_PROXY_API_H_
-#define STH2_PROXY_API_H_
-
-
-#include "drSecureFS_Api.h"
-
-
-/**
- * Termination codes
- */
-#define EXIT_ERROR ((uint32_t)(-1))
-
-/**
- * TA UUID.
- */
-#define SERVICE_DELEGATION_UUID { { 0x07, 0x05, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20 } }
-
-#endif // STH2_PROXY_API_H_
--- /dev/null
+ Copyright Giesecke & Devrient GmbH 2009 - 2012
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
--- /dev/null
+MobiCore Daemon in Android
+---
+Command line
+--
+The MobiCore Daemon supports 4 command line options. It also displays them with the help option:
+
+# ./mcDriverDaemon -h
+usage: ./mcDriverDaemon [-mdsbh]
+Start MobiCore Daemon
+
+-h show this help
+-b fork to background
+-m IMAGE load mobicore from IMAGE to DDR
+-s disable daemon scheduler(default enabled)
+-r DRIVER load dyamic driver
+
+-b Forks the daemon to background
+
+# ./mcDriverDaemon -b
+
+Makes the daemon run in background and returns immediate control to the shell. No need to use shell forking with &
+
+-m Loads a mobicore image to DDR
+
+# ./mcDriverDaemon -m /data/app/mobicore.img
+
+Loads the mobicore.img to DDR and starts executing it.
+
+-s Disables NQ IRQ scheduler
+
+# ./mcDriverDaemon -s
+
+-r Loads dynamic driver at startup. The full path of the driver binary must be given, eg. /data/app/driver.drbin
+
+# ./mcDriverDaemon -r /data/app/driver.drbin
+
+Custom registry locations
+--
+Registry fallback
+
+In case of a Device wipe in Android the /data/app/mcRegistry folder will be deleted with all it's contents. To overcome
+this the daemon supports a fallback location(eg /system/app/mcRegistry): it first tries to load the trustlet
+from /data/app/mcRegistry/[uuid].tlbin and if it fails then it tries to read the trustlet from /system/app/mcRegistry/[uuid].tlb
+
+Both paths are completely configurable for the Daemon using 2 environment variables:MC_REGISTRY_PATH and MC_REGISTRY_FALLBACK_PATH
+
+For example if you want to use /data/app/mcRegistry as the default path and /system/app/mcRegistry as the fallback path:
+
+$ export MC_REGISTRY_PATH=/data/app/mcRegistry
+$ export MC_REGISTRY_FALLBACK_PATH=/system/app/mcRegistry
+$ /data/app/mcDriverDaemon
+
+Custom authtoken path
+--
+
+The authtoken file is created at provisioning and is by default located in /data/app/mcRegistry/00000.authtoken
+
+Because a device wipe could delete this file and make MobiCore unusable a new environment variable has been added to change the
+default behaviour: MC_AUTH_TOKEN_PATH
+
+$ export MC_AUTH_TOKEN_PATH=/efs
+$ /data/app/mcDriverDaemon
+
+This would change the location of the authtoken file to /efs
+++ /dev/null
-#
-# build TuiService
-#
-
-# ExySp: Choice TUI availability
-#_SUPPORT_TUI := true
-ifdef _SUPPORT_TUI
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# Module name (sets name of output binary / library)
-LOCAL_MODULE := libTui
-
-# Add your source files here (relative paths)
-LOCAL_SRC_FILES += \
- jni/tlcTui.cpp \
- jni/tlcTuiJni.cpp
-
-# Enable logging to logcat per default
-LOCAL_CFLAGS += -DLOG_ANDROID
-LOCAL_LDLIBS += -llog
-
-# Undefine NDEBUG to enable LOG_D in log
-LOCAL_CFLAGS += -UNDEBUG
-
-# Needed to use Trustonic logging macros
-LOCAL_SHARED_LIBRARIES := libMcClient
-LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
-
-include $(BUILD_SHARED_LIBRARY)
-
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JNI_SHARED_LIBRARIES := libTui
-
-LOCAL_PACKAGE_NAME := TuiService
-LOCAL_MODULE_TAGS := debug eng optional
-LOCAL_CERTIFICATE := platform
-LOCAL_DEX_PREOPT := false
-
-LOCAL_PROGUARD_FLAGS := -include $(LOCAL_PATH)/proguard-project.txt
-
-include $(BUILD_PACKAGE)
-
-# =============================================================================
-
-# adding the root folder to the search path appears to make absolute paths
-# work for import-module - lets see how long this works and what surprises
-# future developers get from this.
-$(call import-add-path,/)
-$(call import-module,$(COMP_PATH_MobiCoreClientLib_module))
-endif
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.trustonic.tuiservice"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="16"
- android:targetSdkVersion="23" />
-
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
- <uses-permission android:name="android.permission.WAKE_LOCK"/>
- <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
-
- <application
- android:allowBackup="true"
- android:icon="@drawable/sym_def_app_icon"
- android:label="@string/app_name"
- android:theme="@style/Theme.Transparent" >
-
- <receiver
- android:name="com.trustonic.tuiservice.TuiServiceAutoStart"
- android:enabled="true"
- android:exported="true">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED">
- </action>
- <category android:name="android.intent.category.DEFAULT">
- </category>
- </intent-filter>
- </receiver>
-
- <service
- android:name="com.trustonic.tuiservice.TuiService"
- android:enabled="true"
- android:exported="false" >
- </service>
-
- <!-- noHistory and excludeFromRecents property are used to remove
- this activity from the task manager menu -->
- <activity
- android:name="com.trustonic.tuiservice.TuiActivity"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:label="@string/app_name"
- android:screenOrientation="portrait"
- android:theme="@style/Theme.Transparent"
- android:noHistory="true"
- android:excludeFromRecents="true">
- </activity>
- </application>
-</manifest>
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+++ /dev/null
-out.dir=out
-java.compilerargs="-Xlint:unchecked"
-
-debug.key.store=google_certificate.keystore
-debug.key.alias=platform
-debug.key.store.password=android
-debug.key.alias.password=android
-
-key.store=google_certificate.keystore
-key.alias=platform
-key.store.password=android
-key.alias.password=android
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="TuiService" default="help">
-
- <!-- The local.properties file is created and updated by the 'android' tool.
- It contains the path to the SDK. It should *NOT* be checked into
- Version Control Systems. -->
- <property file="local.properties" />
-
- <!-- The ant.properties file can be created by you. It is only edited by the
- 'android' tool to add properties to it.
- This is the place to change some Ant specific build properties.
- Here are some properties you may want to change/update:
-
- source.dir
- The name of the source directory. Default is 'src'.
- out.dir
- The name of the output directory. Default is 'bin'.
-
- For other overridable properties, look at the beginning of the rules
- files in the SDK, at tools/ant/build.xml
-
- Properties related to the SDK location or the project target should
- be updated using the 'android' tool with the 'update' action.
-
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems.
-
- -->
- <property file="ant.properties" />
-
- <!-- if sdk.dir was not set from one of the property file, then
- get it from the ANDROID_HOME env var.
- This must be done before we load project.properties since
- the proguard config can use sdk.dir -->
- <property environment="env" />
- <condition property="sdk.dir" value="${env.ANDROID_HOME}">
- <isset property="env.ANDROID_HOME" />
- </condition>
-
- <!-- The project.properties file is created and updated by the 'android'
- tool, as well as ADT.
-
- This contains project specific properties such as project target, and library
- dependencies. Lower level build properties are stored in ant.properties
- (or in .classpath for Eclipse projects).
-
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems. -->
- <loadproperties srcFile="project.properties" />
-
- <!-- quick check on sdk.dir -->
- <fail
- message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
- unless="sdk.dir"
- />
-
- <!--
- Import per project custom build rules if present at the root of the project.
- This is the place to put custom intermediary targets such as:
- -pre-build
- -pre-compile
- -post-compile (This is typically used for code obfuscation.
- Compiled code location: ${out.classes.absolute.dir}
- If this is not done in place, override ${out.dex.input.absolute.dir})
- -post-package
- -post-build
- -pre-clean
- -->
- <import file="custom_rules.xml" optional="true" />
-
- <target name="test" depends="debug">
- </target>
-
- <!-- Import the actual build file.
-
- To customize existing targets, there are two options:
- - Customize only one target:
- - copy/paste the target into this file, *before* the
- <import> task.
- - customize it to your needs.
- - Customize the whole content of build.xml
- - copy/paste the content of the rules files (minus the top node)
- into this file, replacing the <import> task.
- - customize to your needs.
-
- ***********************
- ****** IMPORTANT ******
- ***********************
- In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
- in order to avoid having your file be overridden by tools such as "android update project"
- -->
-
-
- <!-- the version tag is set to custom in order to avoid regenerating this file. The file has been modifies to make the project name different from the folder name -->
- <!-- version-tag: custom -->
- <import file="${sdk.dir}/tools/ant/build.xml" />
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <jni.h>
-#include <pthread.h>
-#include <fcntl.h>
-#include <sys/syscall.h> /* For SYS_xxx definitions */
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-
-#include "tui_ioctl.h"
-
-#include "tlcTui.h"
-#include "tlcTuiJni.h"
-
-#define LOG_TAG "TlcTui"
-#include "log.h"
-
-/* ------------------------------------------------------------- */
-/* Globals */
-bool testGetEvent = false;
-/* ------------------------------------------------------------- */
-/* Static */
-static pthread_t threadId;
-static int32_t drvFd = -1;
-
-/* ------------------------------------------------------------- */
-/* Static functions */
-static void *mainThread(void *);
-
-/* Functions */
-/* ------------------------------------------------------------- */
-/**
- * TODO.
- */
-static void *mainThread(void *) {
-// int32_t fd;
-// struct stat st;
-// uint32_t size;
-// void *address;
- uint32_t cmdId;
-
- LOG_D("mainThread: TlcTui start!");
-
-/* Android APP has no right to load a .ko. It must be loaded prior to starting the app.
- // Load the k-TLC
- fd = open("/data/app/tlckTuiPlay.ko", O_RDONLY);
- if (fd < 0) {
- LOG_E("mainThread: Could not find k-tlc file!");
- exit(1);
- }
- else {
- fstat(fd, &st);
- size = st.st_size;
- address = mmap(0, size, PROT_READ, MAP_PRIVATE, fd, 0);
- if (syscall(__NR_init_module, address, size, NULL)) {
- int32_t errsv = errno;
- LOG_E("mainThread: Load k-tlc failed with errno %s!", strerror(errsv));
- exit(1);
- }
- close(fd);
- }
-*/
- drvFd = open("/dev/" TUI_DEV_NAME, O_NONBLOCK);
- if (drvFd < 0) {
- LOG_E("mainThread: open k-tlc device failed with errno %s.", strerror(errno));
- exit(1);
- }
-
- /* TlcTui main thread loop */
- for (;;) {
- /* Wait for a command from the k-TLC*/
- if (false == tlcWaitCmdFromDriver(&cmdId)) {
- break;
- }
- /* Something has been received, process it. */
- if (false == tlcProcessCmd(cmdId)) {
- break;
- }
- }
-
- // Close
- close(drvFd);
-
- // close_module() ?
- return NULL;
-}
-/* ------------------------------------------------------------- */
-bool tlcLaunch(void) {
-
- bool ret = false;
- /* Create the TlcTui Main thread */
- if (pthread_create(&threadId, NULL, &mainThread, NULL) != 0) {
- LOG_E("tlcLaunch: pthread_create failed!");
- ret = false;
- } else {
- ret = true;
- }
-
- return ret;
-}
-
-/* ------------------------------------------------------------- */
-bool tlcWaitCmdFromDriver(uint32_t *pCmdId) {
- uint32_t cmdId = 0;
- int ioctlRet = 0;
-
- /* Wait for ioctl to return from k-tlc with a command ID */
- /* Loop if ioctl has been interrupted. */
- do {
- ioctlRet = ioctl(drvFd, TUI_IO_WAITCMD, &cmdId);
- } while((EINTR == errno) && (-1 == ioctlRet));
-
- if (-1 == ioctlRet) {
- LOG_E("TUI_IO_WAITCMD ioctl failed with errno %s.", strerror(errno));
- return false;
- }
- *pCmdId = cmdId;
- return true;
-}
-
-/* ------------------------------------------------------------- */
-bool tlcNotifyEvent(uint32_t eventType) {
-
- if (-1 == ioctl(drvFd, TUI_IO_NOTIFY, eventType)) {
- LOG_E("TUI_IO_NOTIFY ioctl failed with errno %s.", strerror(errno));
- return false;
- }
-
- return true;
-}
-
-/* ------------------------------------------------------------- */
-bool tlcProcessCmd(uint32_t commandId) {
- uint32_t ret = TLC_TUI_ERROR;
- struct tlc_tui_response_t response;
-
- bool acknowledge = true;
-
- switch (commandId) {
- case TLC_TUI_CMD_NONE:
- LOG_I("tlcProcessCmd: TLC_TUI_CMD_NONE.");
- acknowledge = false;
- break;
-
- case TLC_TUI_CMD_START_ACTIVITY:
- LOG_D("tlcProcessCmd: TLC_TUI_CMD_START_ACTIVITY.");
- ret = tlcStartTuiSession();
- LOG_D("tlcStartTuiSession returned %d", ret);
- if (ret == TUI_JNI_OK) {
- ret = TLC_TUI_OK;
- } else {
- ret = TLC_TUI_ERROR;
- acknowledge = false;
- }
- break;
-
- case TLC_TUI_CMD_STOP_ACTIVITY:
- LOG_D("tlcProcessCmd: TLC_TUI_CMD_STOP_ACTIVITY.");
- ret = tlcFinishTuiSession();
- LOG_D("tlcFinishTuiSession returned %d", ret);
- if (ret == TUI_JNI_OK) {
- ret = TLC_TUI_OK;
- } else {
- ret = TLC_TUI_ERROR;
- }
- break;
-
- default:
- LOG_E("tlcProcessCmd: Unknown command %d", commandId);
- acknowledge = false;
- ret = TLC_TUI_ERR_UNKNOWN_CMD;
- break;
- }
-
- // Send command return code to the k-tlc
- response.id = commandId;
- response.return_code = ret;
- if (acknowledge) {
- if (-1 == ioctl(drvFd, TUI_IO_ACK, &response)) {
- LOG_E("TUI_IO_ACK ioctl failed with errno %s.", strerror(errno));
- return false;
- }
- }
-
- LOG_D("tlcProcessCmd: ret = %d", ret);
- return true;
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __TLCTUI_H__
-#define __TLCTUI_H__
-
-bool tlcLaunch(void);
-bool tlcOpen(void);
-bool tlcProcessCmd(uint32_t);
-bool tlcWaitCmdFromDriver(uint32_t *);
-bool tlcNotifyEvent(uint32_t eventType);
-void tlcClose(void);
-
-#endif /* __TLCTUI_H__ */
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include <string.h>
-#include <stdint.h>
-#include <jni.h>
-#include <android/log.h>
-
-#include "tui_ioctl.h"
-
-#include "tlcTui.h"
-#include "tlcTuiJni.h"
-
-#define LOG_TAG "TlcTuiJni"
-#include "log.h"
-
-/* See for more help about JNI:
- * http://java.sun.com/docs/books/jni/html/jniTOC.html
- * http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html
- * http://developer.android.com/training/articles/perf-jni.html
- */
-
-#ifdef __cplusplus
-#define EXTERN_C extern "C"
-#else
-#define EXTERN_C
-#endif
-
-JNIEnv *gEnv = NULL;
-JavaVM *gVm = NULL;
-jclass gTuiTlcWrapperClass = NULL;
-
-static uint32_t setByteArrayField(const char * field, const void *ptr,
- uint32_t length, jclass cls,
- jobject instance) {
- jfieldID fid = NULL; /* store the field ID */
- jbyteArray bytearray = NULL;
-
- LOG_D("setByteArrayField: {%s}, length=%u", field, length);
- /* Look for the static field in class */
- fid = gEnv->GetFieldID(cls, field, "[B");
- if (fid == NULL) {
- LOG_E("setByteArrayField: cannot find field [%s]", field);
- return TUI_JNI_ERROR; /* field not found */
- }
- bytearray = gEnv->NewByteArray(length); /* TODO : free */
- if (bytearray == NULL) {
- LOG_E("setByteArrayField: not enough memory");
- return TUI_JNI_ERROR; /* out of memory */
- }
- gEnv->SetByteArrayRegion(bytearray, (jint)0, (jint)length, (jbyte*)ptr);
- gEnv->SetObjectField(instance, fid, bytearray);
- gEnv->DeleteLocalRef(bytearray);
-
- return TUI_JNI_OK;
-}
-
-uint32_t tlcStartTuiSession(void) {
-
- uint32_t nResult = TUI_JNI_ERROR;
- jmethodID midStartTuiSession = NULL;
-
- if (gTuiTlcWrapperClass == NULL) {
- LOG_E("tlcStartTuiSession: Missing parameter gTuiTlcWrapperClass");
- nResult = TUI_JNI_ERROR;
- goto exit;
- }
-
- /* Attach the thread to the VM */
- if (gVm->AttachCurrentThread(&gEnv, 0) != JNI_OK) {
- LOG_E("tlcStartTuiSession: AttachCurrentThread failed");
- return 1;
- }
-
- if (gEnv != NULL) {
- /* ------------------------------------------------------------- */
- /* Get the method ID for startTuiSession */
- midStartTuiSession = gEnv->GetStaticMethodID(gTuiTlcWrapperClass,
- "startTuiSession",
- "()Z");
- if (midStartTuiSession == NULL) {
- LOG_E("tlcStartTuiSession: Method startTuiSession not found");
- nResult = TUI_JNI_ERROR;
- goto exit;
- }
- /* Call startTuiSession */
- jboolean success = gEnv->CallStaticBooleanMethod(gTuiTlcWrapperClass,
- midStartTuiSession);
- /* ------------------------------------------------------------- */
- if (!success) {
- LOG_E("tlcStartTuiSession: timeout in activity creation");
- nResult = TUI_JNI_ERROR;
- goto exit;
- }
- nResult = TUI_JNI_OK;
- } else {
- LOG_E("tlcStartTuiSession: gEnv is null!");
- nResult = TUI_JNI_ERROR;
- goto exit;
- }
-
- exit: if (gEnv != NULL) {
- if (gEnv->ExceptionCheck()) {
- LOG_E("tlcStartTuiSession: Java exception");
- gEnv->ExceptionClear();
- }
- } else {
- LOG_E("tlcStartTuiSession: exit gEnv is NULL");
- }
-
- if (gVm->DetachCurrentThread() != 0) {
- LOG_E("tlcStartTuiSession: DetachCurrentThread failed");
- }
- return nResult;
-}
-
-uint32_t tlcFinishTuiSession(void) {
-
- uint32_t nResult = TUI_JNI_ERROR;
- jmethodID midFinishTuiSession = NULL;
-
- if (gTuiTlcWrapperClass == NULL) {
- LOG_E("tlcFinishTuiSession: Missing parameter gTuiTlcWrapperClass");
- nResult = TUI_JNI_ERROR;
- goto exit;
- }
-
- /* Attach the thread to the VM */
- if (gVm->AttachCurrentThread(&gEnv, 0) != JNI_OK) {
- LOG_E("tlcFinishTuiSession: AttachCurrentThread failed");
- return 1;
- }
-
- if (gEnv != NULL) {
- /* ------------------------------------------------------------- */
- /* Get the method ID for finishTuiSession */
- midFinishTuiSession = gEnv->GetStaticMethodID(gTuiTlcWrapperClass,
- "finishTuiSession",
- "()V");
- if (midFinishTuiSession == NULL) {
- LOG_E("tlcFinishTuiSession: Method finishTuiSession not found");
- nResult = TUI_JNI_ERROR;
- goto exit;
- }
- /* Call finishTuiSession */
- gEnv->CallStaticVoidMethod(gTuiTlcWrapperClass, midFinishTuiSession);
- /* ------------------------------------------------------------- */
- nResult = TUI_JNI_OK;
- } else {
- LOG_E("tlcFinishTuiSession: gEnv is null!");
- nResult = TUI_JNI_ERROR;
- goto exit;
- }
-
- exit: if (gEnv != NULL) {
- if (gEnv->ExceptionCheck()) {
- LOG_E("tlcFinishTuiSession: Java exception");
- gEnv->ExceptionClear();
- }
- } else {
- LOG_E("tlcFinishTuiSession: exit gEnv is NULL");
- }
-
- if (gVm->DetachCurrentThread() != 0) {
- LOG_E("tlcFinishTuiSession: DetachCurrentThread failed");
- }
-
- return nResult;
-}
-
-
-EXTERN_C JNIEXPORT bool JNICALL
-Java_com_trustonic_tuiservice_TuiTlcWrapper_startTlcTui(JNIEnv *env,
- jobject obj) {
- (void) env;
- (void) obj;
- bool ret = false;
-
- LOG_D("calling tlcLaunch()");
- ret = tlcLaunch();
- if(!ret) {
- LOG_E("tlcLaunch: failed to start TlcTui!");
- }
-
- return ret;
-}
-
-EXTERN_C JNIEXPORT bool JNICALL
-Java_com_trustonic_tuiservice_TuiTlcWrapper_notifyEvent(JNIEnv *env,
- jobject obj, jint eventType) {
- (void) env;
- (void) obj;
- bool ret = false;
-
- LOG_D("calling tlcNotifyEvent()");
- ret = tlcNotifyEvent(eventType);
- if (!ret) {
- LOG_E("tlcNotifyEvent: failed to notify an event!");
- }
-
- return ret;
-}
-
-jint JNI_OnLoad(JavaVM *vm, void *reserved) {
- (void) reserved;
- JNIEnv *env = NULL;
- jclass TuiTlcWrapperClass = NULL;
-
- LOG_D("JNI_OnLoad");
-
- if (vm->GetEnv((void **)&env, JNI_VERSION_1_6) != JNI_OK) {
- LOG_E("JNI_OnLoad: GetEnv failed!");
- return -1;
- }
-
- TuiTlcWrapperClass = env->FindClass(
- "com/trustonic/tuiservice/TuiTlcWrapper");
- if (TuiTlcWrapperClass == NULL) {
- LOG_E("JNI_OnLoad: FindClass on class TuiTlcWrapperClass failed!");
- return -1;
- }
-
- LOG_D("JNI_OnLoad: TuiTlcWrapperClass = %p", TuiTlcWrapperClass);
-
- /* Cache the TlcTuiWrapper class in a global reference */
- /* Use the cached gTuiTlcWrapperClass.
- * As we called the AttachCurrentThread to get the java environnement from
- * a native thread, the FindClass will always fail. This is a ClassLoader issue.
- * This call (AttachCurrentThread) changes the call stack, so when the FindClass
- * try to start the class search in the class loader associated with this method,
- * FindClass find the ClassLoader associated with the a wrong class, so FindClass fails.*/
- gTuiTlcWrapperClass = (jclass)env->NewGlobalRef(TuiTlcWrapperClass);
-
- /* Cache the javaVM to get back a JNIEnv reference from native code*/
- gVm = vm;
- LOG_D("JNI_OnLoad: gVm = %p vm = %p", gVm, vm);
-
- return JNI_VERSION_1_6;
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __TLCTUIJNI_H__
-#define __TLCTUIJNI_H__
-
-#define TUI_JNI_OK 0
-#define TUI_JNI_ERROR 1
-#define TUI_JNI_ERROR_IN_JAVA 2
-
-uint32_t tlcStartTuiSession(void);
-uint32_t tlcFinishTuiSession(void);
-
-#endif /* __TLCTUIJNI_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TUI_IOCTL_H_
-#define TUI_IOCTL_H_
-
-
-
-/* Response header */
-struct tlc_tui_response_t {
- uint32_t id;
- uint32_t return_code;
-};
-
-/* Command IDs */
-#define TLC_TUI_CMD_NONE 0
-#define TLC_TUI_CMD_START_ACTIVITY 1
-#define TLC_TUI_CMD_STOP_ACTIVITY 2
-
-/* Return codes */
-#define TLC_TUI_OK 0
-#define TLC_TUI_ERROR 1
-#define TLC_TUI_ERR_UNKNOWN_CMD 2
-
-
-/*
- * defines for the ioctl TUI driver module function call from user space.
- */
-#define TUI_DEV_NAME "t-base-tui"
-
-#define TUI_IO_MAGIC 't'
-
-#define TUI_IO_NOTIFY _IOW(TUI_IO_MAGIC, 1, uint32_t)
-#define TUI_IO_WAITCMD _IOR(TUI_IO_MAGIC, 2, uint32_t)
-#define TUI_IO_ACK _IOW(TUI_IO_MAGIC, 3, struct tlc_tui_response_t)
-
-#ifdef INIT_COMPLETION
-#define reinit_completion(x) INIT_COMPLETION(*(x))
-#endif
-
-#endif /* TUI_IOCTL_H_ */
+++ /dev/null
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
+++ /dev/null
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-19
+++ /dev/null
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/tuiLayout"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- android:gravity="center_vertical|center_horizontal"
- android:keepScreenOn="true"
- tools:context=".TuiActivity">
-
-</LinearLayout>
+++ /dev/null
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <item
- android:id="@+id/action_settings"
- android:orderInCategory="100"
- android:showAsAction="never"
- android:title="@string/action_settings"/>
-
-</menu>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <!--
- Base application theme for API 11+. This theme completely replaces
- AppBaseTheme from res/values/styles.xml on API 11+ devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
- <!-- API 11 theme customizations can go here. -->
- </style>
-
- <style name="FullscreenTheme" parent="android:Theme.Holo">
- <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
- <item name="android:windowActionBarOverlay">true</item>
- <item name="android:windowBackground">@null</item>
- <item name="buttonBarStyle">?android:attr/buttonBarStyle</item>
- <item name="buttonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
- </style>
-
- <style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar">
- <item name="android:background">@color/black_overlay</item>
- </style>
-
-</resources>
\ No newline at end of file
+++ /dev/null
-<resources>
-
- <!--
- Base application theme for API 14+. This theme completely replaces
- AppBaseTheme from BOTH res/values/styles.xml and
- res/values-v11/styles.xml on API 14+ devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
- <!-- API 14 theme customizations can go here. -->
- </style>
-
-</resources>
\ No newline at end of file
+++ /dev/null
-<resources>
-
- <!--
- Declare custom theme attributes that allow changing which styles are
- used for button bars depending on the API level.
- ?android:attr/buttonBarStyle is new as of API 11 so this is
- necessary to support previous API levels.
- -->
- <declare-styleable name="ButtonBarContainerTheme">
- <attr name="buttonBarStyle" format="reference" />
- <attr name="buttonBarButtonStyle" format="reference" />
- </declare-styleable>
-
-</resources>
\ No newline at end of file
+++ /dev/null
-<resources>
-
- <color name="black_overlay">#66000000</color>
- <color name="status">#fafafa</color>
- <color name="button_off_bgd">#fafafa</color>
- <color name="button_off_txt">#5b5b5b</color>
- <color name="button_on_bgd">#5b5b5b</color>
- <color name="button_on_txt">#fafafa</color>
- <color name="white">#FFFFFF</color>
-
- <color
- name="trustonic_blue">#00A9E0</color>
- <color
- name="trustonic_light_blue">#81B2D7</color>
- <color
- name="trustonic_dark_blue">#0C6CB1</color>
- <color
- name="trustonic_very_dark_blue">#237AB1</color>
- <color
- name="trustonic_grey">#AAACAB</color>
- <color
- name="trustonic_very_light_grey">#EFEFEF</color>
- <color
- name="trustonic_light_grey">#CFCFCF</color>
- <color
- name="trustonic_dark_grey">#615F5F</color>
-
-</resources>
\ No newline at end of file
+++ /dev/null
-<resources>
-
- <!-- Default screen margins, per the Android Design guidelines. -->
- <dimen name="activity_horizontal_margin">16dp</dimen>
- <dimen name="activity_vertical_margin">16dp</dimen>
-
- <!-- ARNDALE board screen size. -->
- <dimen name="arndale_screen_width">600px</dimen>
- <dimen name="arndale_screen_height">1024px</dimen>
- <dimen name="arndale_screen_density">168px</dimen>
-
-</resources>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string name="app_name">tuiService</string>
- <string name="dummy_button">Dummy Button</string>
- <string name="dummy_content">DUMMY\nCONTENT</string>
- <string name="title_activity_tui_manager">TuiManager</string>
- <string name="action_settings">Settings</string>
- <string name="button">Start/Stop</string>
- <string name="tui_manager_start">Start</string>
- <string name="tui_manager_stop">Stop</string>
- <string name="tui_enabled">TUI service is running!</string>
- <string name="tui_disabled">TUI service is not running!</string>
- <string name="slogan">Secured by Trustonic!</string>
-
-</resources>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <!--
- Base application theme, dependent on API level. This theme is replaced
- by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Light">
- <!--
- Theme customizations available in newer API levels can go in
- res/values-vXX/styles.xml, while customizations related to
- backward-compatibility can go here.
- -->
- </style>
-
- <!-- Application theme. -->
- <style name="AppTheme" parent="AppBaseTheme">
- <!-- All customizations that are NOT specific to a particular API-level can go here. -->
- </style>
-
- <style name="FullscreenTheme" parent="android:Theme.NoTitleBar">
- <item name="android:windowContentOverlay">@null</item>
- <item name="android:windowBackground">@null</item>
- <item name="buttonBarStyle">@style/ButtonBar</item>
- <item name="buttonBarButtonStyle">@style/ButtonBarButton</item>
- </style>
-
- <style name="ButtonBar">
- <item name="android:paddingLeft">2dp</item>
- <item name="android:paddingTop">5dp</item>
- <item name="android:paddingRight">2dp</item>
- <item name="android:paddingBottom">0dp</item>
- <item name="android:background">@android:drawable/bottom_bar</item>
- </style>
-
- <style name="ButtonBarButton" />
-
- <style name="Theme.Transparent" parent="android:Theme">
- <item name="android:windowIsTranslucent">true</item>
- <item name="android:windowBackground">@android:color/transparent</item>
- <item name="android:windowContentOverlay">@null</item>
- <item name="android:windowNoTitle">true</item>
- <item name="android:windowIsFloating">true</item>
- <item name="android:backgroundDimEnabled">false</item>
- </style>
-</resources>
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.trustonic.tuiapi;
-
-public class TUI_Event {
- private TUI_EventType type;
-
- public TUI_Event() {
- super();
- this.type = new TUI_EventType(TUI_EventType.TUI_UNKNOW_EVENT);
- }
-
- public TUI_Event(int type) {
- super();
- this.type = new TUI_EventType(type);
- }
-
- public int getType(){
- return this.type.is();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.trustonic.tuiapi;
-
-public class TUI_EventData {
-
- public TUI_EventData() {
- // TODO Auto-generated constructor stub
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.trustonic.tuiapi;
-
-public class TUI_EventType {
-
- private int is;
- public static int TUI_UNKNOW_EVENT = 0;
- public static int TUI_CANCEL_EVENT = 1;
-
- public TUI_EventType(int type) {
- this.is = type;
- }
-
- public int is(){
- return this.is;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.trustonic.tuiservice;
-public interface BuildTag {
- public static final String BUILD_TAG = "t-base-EXYNOS64-Android-310B-V006-20160331_140301_7136";
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.trustonic.tuiservice;
-
-import com.trustonic.tuiapi.TUI_Event;
-import com.trustonic.tuiapi.TUI_EventType;
-import com.trustonic.util.tLog;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.app.Activity;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Matrix;
-import android.graphics.drawable.BitmapDrawable;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.WindowManager;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-
-public class TuiActivity extends Activity {
-
- private static final String TAG = TuiActivity.class.getSimpleName();
-
- private LinearLayout mainView;
- private PerformActionInBackground mTuiHandler;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- android.util.Log.i(TAG, BuildTag.BUILD_TAG);
- super.onCreate(savedInstanceState);
- tLog.d(TAG, "onCreate()");
- setContentView(R.layout.activity_tui);
-
- mTuiHandler = new PerformActionInBackground();
- TuiTlcWrapper.setHandler(mTuiHandler);
-
- try {
- mainView = (LinearLayout) findViewById(R.id.tuiLayout);
- mainView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
- } catch (Exception e) {
- e.printStackTrace();
- }
- TuiTlcWrapper.setIsActivityCreated(true);
- }
-
- @Override
- public void onWindowFocusChanged(boolean hasFocus) {
- super.onWindowFocusChanged(hasFocus);
- if(hasFocus) {
- tLog.d(TAG, "Focus gained");
- synchronized(TuiTlcWrapper.getStartSignal()){
- TuiTlcWrapper.setIsActityAlive(true);
- TuiTlcWrapper.getStartSignal().notify();
- }
- } else {
-// tLog.d(TAG, "Focus lost");
-// synchronized(TuiTlcWrapper.getFinishSignal()){
-// TuiTlcWrapper.getFinishSignal().notify();
-// }
- }
- }
-
- @Override
- protected void onDestroy() {
- tLog.d(TAG, "onDestroy()");
- super.onDestroy();
-
- TuiTlcWrapper.setIsActivityCreated(false);
- TuiTlcWrapper.setIsActityAlive(false);
- synchronized(TuiTlcWrapper.getFinishSignal()){
- TuiTlcWrapper.getFinishSignal().notify();
- }
- }
-
- @Override
- public void onBackPressed() {
- // Cancel the TUI session when the back key is pressed during a TUI
- // session
- final TUI_Event cancel = new TUI_Event(TUI_EventType.TUI_CANCEL_EVENT);
- if(!TuiTlcWrapper.notifyEvent(cancel.getType())) {
- tLog.e(TAG, "notifyEvent failed!");
- }
- }
-
- /*
- * Handler that receives messages from the TimerTask, to adapt the UI.
- */
- class PerformActionInBackground extends Handler {
-
- @Override
- public void handleMessage(Message msg) {
- switch(msg.what){
- case TuiTlcWrapper.CLOSE_SESSION:
- tLog.d(TAG, " handle message CLOSE_SESSION");
- // Call the finish method to close the activity
- finish();
- /* Remove the animation when the activity is finished */
- overridePendingTransition(0, 0);
- break;
-
- default:
- tLog.d(TAG, " handle unknown message");
- break;
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.trustonic.tuiservice;
-
-import com.trustonic.tuiapi.TUI_Event;
-import com.trustonic.tuiapi.TUI_EventType;
-import com.trustonic.util.tLog;
-
-import android.app.Service;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.telephony.TelephonyManager;
-
-public class TuiService extends Service{
- private static final String TAG = TuiService.class.getSimpleName();
-
- @Override
- public IBinder onBind(Intent intent) {
- // TODO Auto-generated method stub
- return null;
- }
-
- // Executed if the service is not running, before OnStartCommand
- @Override
- public void onCreate()
- {
- tLog.d(TAG, "onCreate!!");
- TuiTlcWrapper.init(this);
-
- IntentFilter filter = new IntentFilter();
- Intent screenIntent = new Intent(Intent.ACTION_SCREEN_OFF);
- Intent batteryIntent = new Intent(Intent.ACTION_BATTERY_LOW);
- filter.addAction(screenIntent.getAction());
- filter.addAction(batteryIntent.getAction());
- filter.addAction("android.intent.action.PHONE_STATE");
- registerReceiver(mReceiver, filter);
-
- }
-
- // Executed each time startservice is called
- @Override
- public int onStartCommand(Intent intent, int flags, int startId)
- {
- tLog.d(TAG, "onStartCommand!!");
- return Service.START_STICKY;
- }
-
- private BroadcastReceiver mReceiver= new BroadcastReceiver() {
-
- @Override
- public void onReceive(Context context, Intent intent) {
-
- Runnable notifyEvent = new Runnable() {
- public void run() {
- final TUI_Event cancel = new TUI_Event(TUI_EventType.TUI_CANCEL_EVENT);
- if(!TuiTlcWrapper.notifyEvent(cancel.getType())) {
- tLog.e(TAG, "notifyEvent failed!");
- }
- }
- };
-
- if (TuiTlcWrapper.isSessionOpened()) {
-
- if((intent.getAction() == Intent.ACTION_SCREEN_OFF)){
- tLog.d(TAG,"event screen off!");
- TuiTlcWrapper.acquireWakeLock();
- notifyEvent.run();
- }
- if(intent.getAction() == "android.intent.action.PHONE_STATE"){
- Bundle bundle = intent.getExtras();
- if(bundle != null){
- if(bundle.getString(TelephonyManager.EXTRA_STATE).
- equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)){
- tLog.d(TAG,"event incoming call!");
- notifyEvent.run();
- }
- }
- }
- if((intent.getAction() == Intent.ACTION_BATTERY_LOW)){
- tLog.d(TAG,"event battery low!");
- /* TODO: get the battery level and only send a cancel event
- * if this level is below a threshold that will be defined */
- notifyEvent.run();
- }
- }
- }
- };
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.trustonic.tuiservice;
-
-import com.trustonic.util.tLog;
-
-import android.app.ActivityManager;
-import android.app.ActivityManager.RunningServiceInfo;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import com.trustonic.tuiservice.TuiService;
-
-public class TuiServiceAutoStart extends BroadcastReceiver {
- private static final String TAG = TuiServiceAutoStart.class.getSimpleName();
-
- @Override
- public void onReceive(Context context, Intent intent) {
-
- if (this.isServiceRunning(context)) {
- tLog.d(TAG, "Start of service is not necessary, it is already running");
- return;
- }
-
- Intent service = new Intent(context, TuiService.class);
- context.startService(service);
- }
-
- private boolean isServiceRunning(Context context) {
-
- ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
- for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
- if ("com.trustonic.tuiservice.TuiService".equals(service.service.getClassName()))
- return true;
-
- return false;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013-2015 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.trustonic.tuiservice;
-
-import java.util.LinkedList;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import com.trustonic.tuiservice.TuiActivity.PerformActionInBackground;
-import com.trustonic.util.tLog;
-
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-//import android.os.Build;
-//import android.util.DisplayMetrics;
-import android.os.PowerManager;
-//import android.view.Surface;
-
-public class TuiTlcWrapper {
- private static final String TAG = TuiTlcWrapper.class.getSimpleName();
-
-// public static final int INIT_SESSION = 1;
- public static final int CLOSE_SESSION = 2;
-
- private static Context context = null;
- private static PerformActionInBackground handler = null;
- private static final Object sessionSignal = new Object();
- private static final Object startSignal = new Object();
- private static final Object finishSignal = new Object();
- private static boolean sessionOpened = false;
- private static AtomicBoolean isActityAlive = new AtomicBoolean();
- private static AtomicBoolean isActivityCreated = new AtomicBoolean();
-
- private static PowerManager pm;
- private static PowerManager.WakeLock wl;
-
-
- public static boolean isSessionOpened() {
- synchronized (sessionSignal) {
- return sessionOpened;
- }
- }
- public static void setSessionOpened(boolean sessionOpened) {
- synchronized (sessionSignal) {
- TuiTlcWrapper.sessionOpened = sessionOpened;
- }
- }
-
- public static Object getStartSignal() {
- return startSignal;
- }
- public static Object getFinishSignal() {
- return finishSignal;
- }
-
- public static PerformActionInBackground getHandler() {
- return handler;
- }
- public static void setHandler(PerformActionInBackground handler) {
- TuiTlcWrapper.handler = handler;
- }
-
- public static void setIsActityAlive(boolean status) {
- TuiTlcWrapper.isActityAlive.set(status);
- }
-
- public static void setIsActivityCreated(boolean status) {
- TuiTlcWrapper.isActivityCreated.set(status);
- }
-
- public static boolean startTuiSession(){
-
- try {
- synchronized (startSignal) {
- /* create activities */
- Intent myIntent = new Intent(context, TuiActivity.class);
- myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_DEBUG_LOG_RESOLUTION
- | Intent.FLAG_ACTIVITY_NO_ANIMATION);
- context.startActivity(myIntent);
- /* Wait activity created*/
- startSignal.wait(5000);
- if( ! TuiTlcWrapper.isActityAlive.get()) {
- tLog.d(TAG, "ERROR ACTIVITY timout");
- finishTuiSession();
- return false;
- }
- }
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- /* Enable cancel events catching */
- synchronized (sessionSignal) {
- TuiTlcWrapper.sessionOpened = true;
- }
-
- return true;
- }
-
- public static void acquireWakeLock() {
- /* Ensure that CPU is still running */
- try {
- wl.acquire();
- } catch (Exception e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
-
- public static void finishTuiSession(){
- tLog.d(TAG, "finishTuiSession!");
- if(TuiTlcWrapper.isActivityCreated.get()) {
- /* Disable cancel events catching */
- synchronized (sessionSignal) {
- TuiTlcWrapper.sessionOpened = false;
- }
-
- try{
- synchronized (finishSignal) {
- /* Send a message to the activity UI thread */
- handler.sendMessage(handler.obtainMessage(CLOSE_SESSION));
- /* Wait activity closed */
- finishSignal.wait(5000);
- if(TuiTlcWrapper.isActivityCreated.get()) {
- tLog.d(TAG, "ERROR ACTIVITY timout");
- }
- }
- }catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- }
- }
- try {
- if (wl.isHeld()) {
- wl.release();
- }
- } catch (Exception e2) {
- // TODO Auto-generated catch block
- e2.printStackTrace();
- }
- }
-
-
- /* Initialize static members */
- public static void init(Context ctxt) {
- /* Save context */
- context = ctxt;
-
- pm = (PowerManager) ctxt.getSystemService(Context.POWER_SERVICE);
- wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TuiService");
-
- /* Start the TlcTui native thread */
- startTlcTui();
- }
-
- /* Native functions */
- public static native int startTlcTui();
- public static native boolean notifyEvent(int eventType);
-
- /**
- * this is used to load the library on application startup. The
- * library has already been unpacked to the app specific folder
- * at installation time by the package manager.
- */
- static {
- System.loadLibrary("Tui");
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.trustonic.util;
-
-import android.util.Log;
-
-public class tLog {
- /* Enable log with the command:
- * adb shell setprop log.tag.YOUR_APP_TAG LEVEL
- * e.g adb shell setprop log.tag.TuiActivity DEBUG
- * */
- public static void d(String tag, String msg) {
- if (Log.isLoggable(tag, Log.DEBUG)) {
- Log.d(tag, msg);
- }
- }
-
- public static void i(String tag, String msg) {
- if (Log.isLoggable(tag, Log.INFO)) {
- Log.i(tag, msg);
- }
- }
-
- public static void e(String tag, String msg) {
- if (Log.isLoggable(tag, Log.ERROR)) {
- Log.e(tag, msg);
- }
- }
-
- public static void v(String tag, String msg) {
- if (Log.isLoggable(tag, Log.VERBOSE)) {
- Log.v(tag, msg);
- }
- }
-
- public static void w(String tag, String msg) {
- if (Log.isLoggable(tag, Log.WARN)) {
- Log.w(tag, msg);
- }
- }
-}
-
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+/**
+ * @file dci.h
+ * @brief Contains DCI (Driver Control
+ * Interface) definitions and data structures
+ *
+ */
+
+#ifndef __DCI_H__
+#define __DCI_H__
+
+
+typedef uint32_t dciCommandId_t;
+typedef uint32_t dciResponseId_t;
+typedef uint32_t dciReturnCode_t;
+
+/**< Responses have bit 31 set */
+#define RSP_ID_MASK (1U << 31)
+#define RSP_ID(cmdId) (((uint32_t)(cmdId)) | RSP_ID_MASK)
+#define IS_CMD(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == 0)
+#define IS_RSP(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == RSP_ID_MASK)
+
+/**
+ * Return codes of driver commands.
+ */
+#define RET_OK 0
+#define RET_ERR_UNKNOWN_CMD 1
+#define RET_ERR_NOT_SUPPORTED 2
+#define RET_ERR_INTERNAL_ERROR 3
+/* ... add more error codes when needed */
+
+/**
+ * DCI command header.
+ */
+typedef struct{
+ dciCommandId_t commandId; /**< Command ID */
+} dciCommandHeader_t;
+
+/**
+ * DCI response header.
+ */
+typedef struct{
+ dciResponseId_t responseId; /**< Response ID (must be command ID | RSP_ID_MASK )*/
+ dciReturnCode_t returnCode; /**< Return code of command */
+} dciResponseHeader_t;
+
+#endif // __DCI_H__
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+/**
+ * @file drError.h
+ * @brief Error id definitions
+ *
+ */
+
+#ifndef __DRERROR_H__
+#define __DRERROR_H__
+
+/**
+ * Driver fatal error codes.
+ */
+typedef enum {
+ E_DR_OK = 0, /**< Success */
+ E_DR_IPC = 1, /**< IPC error */
+ E_DR_INTERNAL = 2, /**< Internal error */
+ /* ... add more error codes when required */
+} drError_t;
+
+
+#endif // __DRERROR_H__
+
+
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+/**
+ * @file drSecureStorage_Api.h
+ * @brief Contains DCI command definitions and data structures
+ *
+ */
+
+#ifndef __DRTEMPLATEAPI_H__
+#define __DRTEMPLATEAPI_H__
+
+#include "dci.h"
+#include "tee_internal_api.h"
+
+
+#define RW_DATA_SIZE 4096
+
+/**
+ * Command ID's for communication
+ * FSD <--> STH
+ */
+
+#define STH_MESSAGE_TYPE_LOOK 0
+#define STH_MESSAGE_TYPE_READ 1
+#define STH_MESSAGE_TYPE_WRITE 2
+#define STH_MESSAGE_TYPE_DELETE 3
+
+#define CMD_ST_SYNC 5
+#define NOTIFY_DCIH 6
+#define NOTIFY_IPCH 7
+/*... add more command ids when needed */
+
+#define STH_PUBLIC_FILE_NAME_SIZE 20
+
+typedef struct {
+ uint32_t status;
+ uint8_t type;
+ uint8_t reserved0;
+ uint16_t flags;
+ uint32_t payloadLen;
+ TEE_UUID uuid;
+ unsigned char filename[STH_PUBLIC_FILE_NAME_SIZE];
+ unsigned char payload[];
+} STH_FSD_message_t;
+
+typedef struct
+{
+ char header[5];
+ unsigned char version;
+ uint16_t cryptoLen;
+ uint32_t dataLen;
+}FSD_plaintext;
+
+/**
+ * command message.
+ *
+ * @param len Lenght of the data to process.
+ * @param data Data to be processed
+ */
+typedef struct {
+ dciCommandHeader_t header; /**< Command header */
+ uint32_t len; /**< Length of data to process */
+} cmd_t;
+
+
+/**
+ * Response structure
+ */
+typedef struct {
+ dciResponseHeader_t header; /**< Response header */
+ uint32_t len;
+} rsp_t;
+
+/**
+ * DCI message data.
+ */
+typedef struct {
+ union {
+ cmd_t command;
+ rsp_t response;
+ };
+
+ STH_FSD_message_t sth_request;
+} dciMessage_t;
+
+/**
+ * Driver UUID. Update accordingly after reserving UUID
+ */
+#define DRV_STH_UUID { { 0x07, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
+
+
+#endif // __DRTEMPLATEAPI_H__
--- /dev/null
+/*
+ * Copyright (c) 2012 Trusted Logic Mobility SAS.
+ * All Rights Reserved.
+ *
+ * The present software is the confidential and proprietary information of
+ * Trusted Logic Mobility SAS. You shall not disclose the present software
+ * and shall use it only in accordance with the terms of the license
+ * agreement you entered into with Trusted Logic Mobility SAS.
+ * "Trusted Logic" is a registered trademark of Trusted Logic SAS.
+ * This software may be subject to export or import laws in certain
+ * countries.
+ */
+
+//TODO: Remove functions that are not provided in potato release
+
+#ifndef __TEE_INTERNAL_API_H__
+#define __TEE_INTERNAL_API_H__
+
+typedef uint32_t TEE_Result;
+
+#define TEE_SUCCESS ((TEE_Result)0x00000000)
+
+/**
+ * Generic error code : Generic error
+ **/
+#define TEE_ERROR_GENERIC ((TEE_Result)0xFFFF0000)
+
+/**
+ * Generic error code : The underlying security system denies the access to the
+ * object
+ **/
+#define TEE_ERROR_ACCESS_DENIED ((TEE_Result)0xFFFF0001)
+
+/**
+ * Generic error code : The pending operation is cancelled.
+ **/
+#define TEE_ERROR_CANCEL ((TEE_Result)0xFFFF0002)
+
+/**
+ * Generic error code : The underlying system detects a conflict
+ **/
+#define TEE_ERROR_ACCESS_CONFLICT ((TEE_Result)0xFFFF0003)
+
+/**
+ * Generic error code : Too much data for the operation or some data remain
+ * unprocessed by the operation.
+ **/
+#define TEE_ERROR_EXCESS_DATA ((TEE_Result)0xFFFF0004)
+
+/**
+ * Generic error code : Error of data format
+ **/
+#define TEE_ERROR_BAD_FORMAT ((TEE_Result)0xFFFF0005)
+
+/**
+ * Generic error code : The specified parameters are invalid
+ **/
+#define TEE_ERROR_BAD_PARAMETERS ((TEE_Result)0xFFFF0006)
+
+/**
+ * Generic error code : Illegal state for the operation.
+ **/
+#define TEE_ERROR_BAD_STATE ((TEE_Result)0xFFFF0007)
+
+/**
+ * Generic error code : The item is not found
+ **/
+#define TEE_ERROR_ITEM_NOT_FOUND ((TEE_Result)0xFFFF0008)
+
+/**
+ * Generic error code : The specified operation is not implemented
+ **/
+#define TEE_ERROR_NOT_IMPLEMENTED ((TEE_Result)0xFFFF0009)
+
+/**
+ * Generic error code : The specified operation is not supported
+ **/
+#define TEE_ERROR_NOT_SUPPORTED ((TEE_Result)0xFFFF000A)
+
+/**
+ * Generic error code : Insufficient data is available for the operation.
+ **/
+#define TEE_ERROR_NO_DATA ((TEE_Result)0xFFFF000B)
+
+/**
+ * Generic error code : Not enough memory to perform the operation
+ **/
+#define TEE_ERROR_OUT_OF_MEMORY ((TEE_Result)0xFFFF000C)
+
+/**
+ * Generic error code : The service is currently unable to handle the request;
+ * try later
+ **/
+#define TEE_ERROR_BUSY ((TEE_Result)0xFFFF000D)
+
+/**
+ * Generic error code : security violation
+ **/
+#define TEE_ERROR_SECURITY ((TEE_Result)0xFFFF000F)
+
+/**
+ * Generic error code : the buffer is too short
+ **/
+#define TEE_ERROR_SHORT_BUFFER ((TEE_Result)0xFFFF0010)
+
+/**
+ * Generic error code : the operation is not terminated
+ **/
+#define TEE_PENDING ((TEE_Result)0xFFFF2000)
+
+/**
+ * Generic error code : A timeout occurred
+ **/
+#define TEE_ERROR_TIMEOUT ((TEE_Result)0xFFFF3001)
+
+/**
+ * Generic error code : Overflow
+ **/
+#define TEE_ERROR_OVERFLOW ((TEE_Result)0xFFFF300F)
+
+/*------------------------------------------------------------------------------
+ Communication Error Codes
+------------------------------------------------------------------------------*/
+
+/**
+ * Generic communication error
+ **/
+#define TEE_ERROR_COMMUNICATION ((TEE_Result)0xFFFF000E)
+
+/**
+ * Error of communication: The target of the connection is dead
+ **/
+#define TEE_ERROR_TARGET_DEAD ((TEE_Result)0xFFFF3024)
+
+/*------------------------------------------------------------------------------
+ Storage Error Codes
+------------------------------------------------------------------------------*/
+
+/** File system error code: not enough space to complete the operation. */
+#define TEE_ERROR_STORAGE_NO_SPACE ((TEE_Result)0xFFFF3041)
+
+/*------------------------------------------------------------------------------
+ Crypto error codes
+------------------------------------------------------------------------------*/
+#define TEE_ERROR_MAC_INVALID ((TEE_Result)0xFFFF3071)
+
+#define TEE_ERROR_SIGNATURE_INVALID ((TEE_Result)0xFFFF3072)
+
+/*------------------------------------------------------------------------------
+ Date error codes
+------------------------------------------------------------------------------*/
+#define TEE_ERROR_TIME_NOT_SET ((TEE_Result)0xFFFF5000)
+
+#define TEE_ERROR_TIME_NEEDS_RESET ((TEE_Result)0xFFFF5001)
+
+
+/** Definition of an UUID (from RFC 4122 http://www.ietf.org/rfc/rfc4122.txt) */
+typedef struct
+{
+ uint32_t timeLow;
+ uint16_t timeMid;
+ uint16_t timeHiAndVersion;
+ uint8_t clockSeqAndNode[8];
+} TEE_UUID;
+
+/** Type definition for a TEE Identity */
+typedef struct TEE_Identity
+{
+ uint32_t login;
+ TEE_UUID uuid;
+} TEE_Identity;
+
+typedef uint32_t S_HANDLE;
+
+#define S_VAR_NOT_USED(variable) do{(void)(variable);}while(0);
+
+#define OUT
+#define IN
+
+#define TEE_EXPORT
+#define TA_EXPORT
+
+
+/*---------------------------------------------------------
+ Common type definition
+---------------------------------------------------------*/
+
+typedef union
+{
+
+ struct
+ {
+ void* buffer;
+ size_t size;
+ } memref;
+
+ struct
+ {
+ uint32_t a;
+ uint32_t b;
+ } value;
+
+}
+TEE_Param;
+
+typedef S_HANDLE TEE_TASessionHandle;
+typedef S_HANDLE TEE_PropSetHandle;
+typedef S_HANDLE TEE_ObjectHandle;
+typedef S_HANDLE TEE_ObjectEnumHandle;
+typedef S_HANDLE TEE_OperationHandle;
+
+#define TEE_HANDLE_NULL ((S_HANDLE)0)
+
+#define TEE_PARAM_TYPES(t0,t1,t2,t3) ((t0) | ((t1) << 4) | ((t2) << 8) | ((t3) << 12))
+#define TEE_PARAM_TYPE_GET(t, i) (((t) >> (i*4)) & 0xF)
+
+typedef enum {
+ TEE_DATA_SEEK_SET,
+ TEE_DATA_SEEK_CUR,
+ TEE_DATA_SEEK_END
+ } TEE_Whence;
+
+typedef struct TEE_Time
+{
+ uint32_t seconds;
+ uint32_t millis;
+} TEE_Time;
+
+typedef struct {
+ uint32_t algorithm;
+ uint32_t operationClass;
+ uint32_t mode;
+ uint32_t digestLength;
+ uint32_t maxKeySize;
+ uint32_t keySize;
+ uint32_t requiredKeyUsage;
+ uint32_t handleState;
+ } TEE_OperationInfo;
+
+
+typedef enum {
+ TEE_MODE_ENCRYPT,
+ TEE_MODE_DECRYPT,
+ TEE_MODE_SIGN,
+ TEE_MODE_VERIFY,
+ TEE_MODE_MAC,
+ TEE_MODE_DIGEST,
+ TEE_MODE_DERIVE
+ } TEE_OperationMode;
+
+
+typedef struct {
+ uint32_t attributeID;
+ union
+ {
+ struct
+ {
+ void* buffer;
+ size_t length;
+ }ref;
+ struct
+ {
+ uint32_t a, b;
+ }value;
+ }content;
+ } TEE_Attribute;
+
+typedef struct {
+ uint32_t objectType;
+ uint32_t objectSize;
+ uint32_t maxObjectSize;
+ uint32_t objectUsage;
+ uint32_t dataSize;
+ uint32_t dataPosition;
+ uint32_t handleFlags;
+ } TEE_ObjectInfo;
+
+
+/*------------------------------------------------------------------------------
+ Constants
+------------------------------------------------------------------------------*/
+
+#define TEE_TIMEOUT_INFINITE 0xFFFFFFFF
+
+/* Login types */
+#define TEE_LOGIN_PUBLIC 0x00000000
+#define TEE_LOGIN_USER 0x00000001
+#define TEE_LOGIN_GROUP 0x00000002
+#define TEE_LOGIN_APPLICATION 0x00000004
+#define TEE_LOGIN_APPLICATION_USER 0x00000005
+#define TEE_LOGIN_APPLICATION_GROUP 0x00000006
+#define TEE_LOGIN_TRUSTED_APP 0xF0000000
+
+/* Parameter types */
+#define TEE_PARAM_TYPE_NONE 0x0
+#define TEE_PARAM_TYPE_VALUE_INPUT 0x1
+#define TEE_PARAM_TYPE_VALUE_OUTPUT 0x2
+#define TEE_PARAM_TYPE_VALUE_INOUT 0x3
+#define TEE_PARAM_TYPE_MEMREF_INPUT 0x5
+#define TEE_PARAM_TYPE_MEMREF_OUTPUT 0x6
+#define TEE_PARAM_TYPE_MEMREF_INOUT 0x7
+
+#define TEE_MEMORY_ACCESS_READ 0x00000001
+#define TEE_MEMORY_ACCESS_WRITE 0x00000002
+#define TEE_MEMORY_ACCESS_ANY_OWNER 0x00000004
+
+#define TEE_ORIGIN_API 1
+#define TEE_ORIGIN_COMMS 2
+#define TEE_ORIGIN_TEE 3
+#define TEE_ORIGIN_TRUSTED_APP 4
+
+/* Property Sets Pseudo Handles */
+#define TEE_PROPSET_CURRENT_TA (TEE_PropSetHandle)0xFFFFFFFF
+#define TEE_PROPSET_CURRENT_CLIENT (TEE_PropSetHandle)0xFFFFFFFE
+#define TEE_PROPSET_TEE_IMPLEMENTATION (TEE_PropSetHandle)0xFFFFFFFD
+
+/* Allocation hints */
+#define TEE_ALLOCATION_HINT_ZEROED 0x00000000
+
+/* Crypto Usage Constants */
+#define TEE_USAGE_EXTRACTABLE 0x00000001
+#define TEE_USAGE_ENCRYPT 0x00000002
+#define TEE_USAGE_DECRYPT 0x00000004
+#define TEE_USAGE_MAC 0x00000008
+#define TEE_USAGE_SIGN 0x00000010
+#define TEE_USAGE_VERIFY 0x00000020
+#define TEE_USAGE_DERIVE 0x00000040
+
+/* Crypto Handle Flag Constants */
+#define TEE_HANDLE_FLAG_PERSISTENT 0x00010000
+#define TEE_HANDLE_FLAG_INITIALIZED 0x00020000
+#define TEE_HANDLE_FLAG_KEY_SET 0x00040000
+#define TEE_HANDLE_FLAG_EXPECT_TWO_KEYS 0x00080000
+
+/* Crypto Operation Constants */
+#define TEE_OPERATION_CIPHER 1
+#define TEE_OPERATION_MAC 3
+#define TEE_OPERATION_AE 4
+#define TEE_OPERATION_DIGEST 5
+#define TEE_OPERATION_ASYMMETRIC_CIPHER 6
+#define TEE_OPERATION_ASYMMETRIC_SIGNATURE 7
+#define TEE_OPERATION_KEY_DERIVATION 8
+
+/* Crypto Algortithm Constants */
+#define TEE_ALG_AES_ECB_NOPAD 0x10000010
+#define TEE_ALG_AES_CBC_NOPAD 0x10000110
+#define TEE_ALG_AES_CTR 0x10000210
+#define TEE_ALG_AES_CTS 0x10000310
+#define TEE_ALG_AES_XTS 0x10000410
+#define TEE_ALG_AES_CBC_MAC_NOPAD 0x30000110
+#define TEE_ALG_AES_CBC_MAC_PKCS5 0x30000510
+#define TEE_ALG_AES_CMAC 0x30000610
+#define TEE_ALG_AES_CCM 0x40000710
+#define TEE_ALG_AES_GCM 0x40000810
+#define TEE_ALG_DES_ECB_NOPAD 0x10000011
+#define TEE_ALG_DES_CBC_NOPAD 0x10000111
+#define TEE_ALG_DES_CBC_MAC_NOPAD 0x30000111
+#define TEE_ALG_DES_CBC_MAC_PKCS5 0x30000511
+#define TEE_ALG_DES_CMAC 0x30000611
+#define TEE_ALG_DES3_ECB_NOPAD 0x10000013
+#define TEE_ALG_DES3_CBC_NOPAD 0x10000113
+#define TEE_ALG_DES3_CBC_MAC_NOPAD 0x30000113
+#define TEE_ALG_DES3_CBC_MAC_PKCS5 0x30000513
+#define TEE_ALG_DES3_CMAC 0x30000613
+#define TEE_ALG_RSASSA_PKCS1_V1_5_MD5 0x70001830
+#define TEE_ALG_RSASSA_PKCS1_V1_5_SHA1 0x70002830
+#define TEE_ALG_RSASSA_PKCS1_V1_5_SHA224 0x70003830
+#define TEE_ALG_RSASSA_PKCS1_V1_5_SHA256 0x70004830
+#define TEE_ALG_RSASSA_PKCS1_V1_5_SHA384 0x70005830
+#define TEE_ALG_RSASSA_PKCS1_V1_5_SHA512 0x70006830
+#define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA1 0x70212930
+#define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA224 0x70313930
+#define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256 0x70414930
+#define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384 0x70515930
+#define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512 0x70616930
+#define TEE_ALG_RSAES_PKCS1_V1_5 0x60000130
+#define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA1 0x60210230
+#define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224 0x60310230
+#define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256 0x60410230
+#define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384 0x60510230
+#define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512 0x60610230
+#define TEE_ALG_RSA_NOPAD 0x60000030
+#define TEE_ALG_DSA_SHA1 0x70002131
+#define TEE_ALG_DH_DERIVE_SHARED_SECRET 0x80000032
+#define TEE_ALG_MD5 0x50000001
+#define TEE_ALG_SHA1 0x50000002
+#define TEE_ALG_SHA224 0x50000003
+#define TEE_ALG_SHA256 0x50000004
+#define TEE_ALG_SHA384 0x50000005
+#define TEE_ALG_SHA512 0x50000006
+#define TEE_ALG_HMAC_MD5 0x30000001
+#define TEE_ALG_HMAC_SHA1 0x30000002
+#define TEE_ALG_HMAC_SHA224 0x30000003
+#define TEE_ALG_HMAC_SHA256 0x30000004
+#define TEE_ALG_HMAC_SHA384 0x30000005
+#define TEE_ALG_HMAC_SHA512 0x30000006
+
+/* Storage ID Values */
+#define TEE_STORAGE_PRIVATE 0x00000001
+
+/* Data Flags */
+#define TEE_DATA_FLAG_ACCESS_READ 0x00000001
+#define TEE_DATA_FLAG_ACCESS_WRITE 0x00000002
+#define TEE_DATA_FLAG_ACCESS_WRITE_META 0x00000004
+#define TEE_DATA_FLAG_SHARE_READ 0x00000010
+#define TEE_DATA_FLAG_SHARE_WRITE 0x00000020
+#define TEE_DATA_FLAG_CREATE 0x00000200
+#define TEE_DATA_FLAG_EXCLUSIVE 0x00000400
+
+/* Misc */
+#define TEE_DATA_MAX_POSITION 0xFFFFFFFF
+#define TEE_OBJECT_ID_MAX_LEN 0x40
+
+/* Object Types */
+#define TEE_TYPE_AES 0xA0000010
+#define TEE_TYPE_DES 0xA0000011
+#define TEE_TYPE_DES3 0xA0000013
+#define TEE_TYPE_HMAC_MD5 0xA0000001
+#define TEE_TYPE_HMAC_SHA1 0xA0000002
+#define TEE_TYPE_HMAC_SHA224 0xA0000003
+#define TEE_TYPE_HMAC_SHA256 0xA0000004
+#define TEE_TYPE_HMAC_SHA384 0xA0000005
+#define TEE_TYPE_HMAC_SHA512 0xA0000006
+#define TEE_TYPE_RSA_PUBLIC_KEY 0xA0000030
+#define TEE_TYPE_RSA_KEYPAIR 0xA1000030
+#define TEE_TYPE_DSA_PUBLIC_KEY 0xA0000031
+#define TEE_TYPE_DSA_KEYPAIR 0xA1000031
+#define TEE_TYPE_DH_KEYPAIR 0xA1000032
+#define TEE_TYPE_GENERIC_SECRET 0xA0000000
+
+/* Object Attribute Identifier Flags - bits 28 and 29 indicate the type (value/ref) and its visibility */
+#define TEE_ATTR_FLAG_VALUE 0x20000000
+#define TEE_ATTR_FLAG_PUBLIC 0x10000000
+
+/* Operation and Object Attribute ID Values */
+#define TEE_ATTR_SECRET_VALUE 0xC0000000
+#define TEE_ATTR_RSA_MODULUS 0xD0000130
+#define TEE_ATTR_RSA_PUBLIC_EXPONENT 0xD0000230
+#define TEE_ATTR_RSA_PRIVATE_EXPONENT 0xC0000330
+#define TEE_ATTR_RSA_PRIME1 0xC0000430 // p
+#define TEE_ATTR_RSA_PRIME2 0xC0000530 // q
+#define TEE_ATTR_RSA_EXPONENT1 0xC0000630 // dp
+#define TEE_ATTR_RSA_EXPONENT2 0xC0000730 // dq
+#define TEE_ATTR_RSA_COEFFICIENT 0xC0000830 // iq
+#define TEE_ATTR_DSA_PRIME 0xD0001031 // p
+#define TEE_ATTR_DSA_SUBPRIME 0xD0001131 // q
+#define TEE_ATTR_DSA_BASE 0xD0001231 // g
+#define TEE_ATTR_DSA_PUBLIC_VALUE 0xD0000131 // y
+#define TEE_ATTR_DSA_PRIVATE_VALUE 0xC0000231 // x
+#define TEE_ATTR_DH_PRIME 0xD0001032 // p
+#define TEE_ATTR_DH_SUBPRIME 0xD0001132 // q
+#define TEE_ATTR_DH_BASE 0xD0001232 // g
+#define TEE_ATTR_DH_X_BITS 0xF0001332 // type "Value" not "Ref"
+#define TEE_ATTR_DH_PUBLIC_VALUE 0xD0000132 // y
+#define TEE_ATTR_DH_PRIVATE_VALUE 0xC0000232 // x
+#define TEE_ATTR_RSA_OAEP_LABEL 0xD0000930
+#define TEE_ATTR_RSA_PSS_SALT_LENGTH 0xF0000A30 // type "Value" not "Ref"
+
+/*------------------------------------------------------------------------------
+ Trusted Application Interface
+ ------------------------------------------------------------------------------*/
+
+TEE_Result TA_EXPORT TA_CreateEntryPoint(void);
+
+void TA_EXPORT TA_DestroyEntryPoint(void);
+
+TEE_Result TA_EXPORT TA_OpenSessionEntryPoint(uint32_t nParamTypes,
+ TEE_Param pParams[4],
+ void** ppSessionContext);
+
+void TA_EXPORT TA_CloseSessionEntryPoint(void* pSessionContext);
+
+TEE_Result TA_EXPORT TA_InvokeCommandEntryPoint(
+ void* pSessionContext,
+ uint32_t nCommandID,
+ uint32_t nParamTypes,
+ TEE_Param pParams[4]
+ );
+
+
+/*------------------------------------------------------------------------------
+ Trusted Core Framework APIs
+ ------------------------------------------------------------------------------*/
+
+void TEE_EXPORT TEE_Panic(TEE_Result nPanicCode);
+
+
+/*------------------------------------------------------------------------------
+ Property Access Functions
+ ------------------------------------------------------------------------------*/
+
+TEE_Result TEE_EXPORT TEE_GetPropertyAsString(
+ TEE_PropSetHandle propsetOrEnumerator,
+ char* name,
+ char* valueBuffer,
+ size_t* valueBufferLen );
+
+TEE_Result TEE_EXPORT TEE_GetPropertyAsBool(
+ TEE_PropSetHandle propsetOrEnumerator,
+ char* name,
+ bool* value );
+
+TEE_Result TEE_EXPORT TEE_GetPropertyAsU32 (
+ TEE_PropSetHandle propsetOrEnumerator,
+ char* name,
+ uint32_t* value );
+
+TEE_Result TEE_EXPORT TEE_GetPropertyAsBinaryBlock(
+ TEE_PropSetHandle propsetOrEnumerator,
+ char* name,
+ void* valueBuffer,
+ size_t* valueBufferLen );
+
+TEE_Result TEE_EXPORT TEE_GetPropertyAsUUID(
+ TEE_PropSetHandle propsetOrEnumerator,
+ char* name,
+ TEE_UUID* value );
+
+TEE_Result TEE_EXPORT TEE_GetPropertyAsIdentity(
+ TEE_PropSetHandle propsetOrEnumerator,
+ char* name,
+ TEE_Identity* value );
+
+TEE_Result TEE_EXPORT TEE_AllocatePropertyEnumerator(
+ TEE_PropSetHandle* enumerator );
+
+void TEE_EXPORT TEE_FreePropertyEnumerator(
+ TEE_PropSetHandle enumerator );
+
+void TEE_EXPORT TEE_StartPropertyEnumerator(
+ TEE_PropSetHandle enumerator,
+ TEE_PropSetHandle propSet );
+
+void TEE_EXPORT TEE_ResetPropertyEnumerator(
+ TEE_PropSetHandle enumerator );
+
+TEE_Result TEE_EXPORT TEE_GetPropertyName(
+ TEE_PropSetHandle enumerator,
+ void* nameBuffer,
+ size_t* nameBufferLen );
+
+TEE_Result TEE_EXPORT TEE_GetNextProperty(
+ TEE_PropSetHandle enumerator );
+
+
+/*------------------------------------------------------------------------------
+ Internal Client API
+ ------------------------------------------------------------------------------*/
+
+TEE_Result TEE_EXPORT TEE_OpenTASession( TEE_UUID* destination, // [in]
+ uint32_t cancellationRequestTimeout,
+ uint32_t paramTypes,
+ TEE_Param params[4], // [inout]
+ TEE_TASessionHandle* session, // [out]
+ uint32_t* returnOrigin
+ );
+
+void TEE_EXPORT TEE_CloseTASession(TEE_TASessionHandle session);
+
+TEE_Result TEE_EXPORT TEE_InvokeTACommand(TEE_TASessionHandle session,
+ uint32_t cancellationRequestTimeout,
+ uint32_t commandID,
+ uint32_t paramTypes,
+ TEE_Param params[4],
+ uint32_t* returnOrigin
+ );
+
+/*------------------------------------------------------------------------------
+ Cancellation Functions
+ ------------------------------------------------------------------------------*/
+
+bool TEE_EXPORT TEE_GetCancellationFlag( void );
+bool TEE_EXPORT TEE_UnmaskCancellation( void );
+bool TEE_EXPORT TEE_MaskCancellation( void );
+
+
+/*------------------------------------------------------------------------------
+ Memory Management Functions
+ ------------------------------------------------------------------------------*/
+
+TEE_Result TEE_EXPORT TEE_CheckMemoryAccessRights(uint32_t accessFlags,
+ void* buffer, size_t size
+ );
+
+void TEE_EXPORT TEE_SetInstanceData( void* instanceData );
+
+TEE_EXPORT void* TEE_GetInstanceData( void );
+
+/**
+ * Allocates a block of memory from a heap. The address of the allocated block
+ * is aligned on a 8-bytes boundary. A block allocated by {malloc} must
+ * be freed by {free}.
+ *
+ * @param nSize Number of bytes to be allocated. A zero value is invalid.
+ *
+ * @return A pointer to the allocated memory block or
+ * NULL if the block cannot be allocated.
+ **/
+TEE_EXPORT void* TEE_Malloc(uint32_t size, uint32_t hint);
+
+/**
+ * Reallocates a block of memory from a heap.
+ * This function enables you to resize a memory block.
+ *
+ * If <tt>pBlock</tt> is NULL, {realloc} is equivalent to {malloc}.
+ * In particular, if nNewSize is 0, the function returns NULL.
+ *
+ * If <tt>pBlock</tt> is not NULL and <tt>nNewSize</tt> is 0, then
+ * {realloc} is equivalent to {free} and returns NULL.
+ *
+ * If <tt>nNewSize</tt> is less or equal to the current size of the block,
+ * the block is trucated, the content of the block is left unchanged and
+ * the function returns <tt>pBlock</tt>.
+ *
+ * If <tt>nNewSize</tt> is greater than the current size of the block, the size
+ * of the block is increased. The whole content of the block is copied at the
+ * beginning of the new block. If possible, the block is enlarged in place and
+ * the function retuns <tt>pBlock</tt>. If this is not possible, a new block
+ * is allocated with the new size, the content of the current block is copied,
+ * the current block is freed and the function retuns the pointer on the new
+ * block.
+ * @param pBlock Pointer to the block of memory that the function
+ * reallocates. This value may be null or returned by an
+ * earlier call to the {malloc} or {realloc}
+ * function.
+ *
+ * @param nNewSize New size of the memory block, in bytes.
+ * This value may be zero. A memory block's size can be
+ * increased or decreased by using this function.
+ *
+ * @return A pointer to the reallocated memory block or
+ * NULL if <tt>nNewSize</tt> is zero or if an error is detected.
+ **/
+TEE_EXPORT void* TEE_Realloc(void* buffer, uint32_t newSize);
+
+/**
+ * Frees a memory block allocated from a heap by the {malloc} or
+ * {realloc} function.
+ *
+ * This function does nothing if pBlock is set to NULL.
+ *
+ * @param pBlock Pointer to the memory block to be freed.
+ * This pointer is returned by an earlier call
+ * to the {malloc} or {realloc} function.
+ **/
+void TEE_EXPORT TEE_Free(void *buffer);
+
+void TEE_EXPORT TEE_MemMove(void* dest, void* src, uint32_t size);
+
+int32_t TEE_EXPORT TEE_MemCompare(void* buffer1, void* buffer2, uint32_t size);
+
+void TEE_EXPORT TEE_MemFill(void* buffer, uint32_t x, uint32_t size );
+
+
+/*------------------------------------------------------------------------------
+ Time Functions
+ ------------------------------------------------------------------------------*/
+
+TEE_Result TEE_EXPORT TEE_Wait(uint32_t timeout);
+
+void TEE_EXPORT TEE_GetSystemTime(TEE_Time* time);
+
+void TEE_EXPORT TEE_GetREETime(TEE_Time* time);
+
+TEE_Result TEE_EXPORT TEE_GetTAPersistentTime(TEE_Time* time);
+
+TEE_Result TEE_EXPORT TEE_SetTAPersistentTime(TEE_Time* time);
+
+
+/*------------------------------------------------------------------------------
+ Arithmetical Functions
+------------------------------------------------------------------------------*/
+
+typedef uint32_t TEE_BigInt;
+typedef uint32_t TEE_BigIntFMMContext;
+typedef uint32_t TEE_BigIntFMM;
+
+#define TEE_BigIntSizeInU32(n) ((((n)+31)/32)+2)
+
+void TEE_EXPORT TEE_BigIntInit(
+ OUT TEE_BigInt *bigInt,
+ IN size_t len);
+
+int32_t TEE_EXPORT TEE_BigIntCmp(
+ IN TEE_BigInt *op1,
+ IN TEE_BigInt *op2);
+
+int32_t TEE_EXPORT TEE_BigIntCmpS32(
+ IN TEE_BigInt *op,
+ IN int32_t shortVal);
+
+TEE_Result TEE_EXPORT TEE_BigIntConvertFromOctetString(
+ OUT TEE_BigInt *dest,
+ IN uint8_t *buffer,
+ IN size_t bufferLen,
+ IN int32_t sign);
+
+TEE_Result TEE_EXPORT TEE_BigIntConvertToOctetString(
+ OUT void *buffer,
+ OUT size_t *bufferLen,
+ IN TEE_BigInt *bigInt);
+
+void TEE_EXPORT TEE_BigIntConvertFromS32(
+ OUT TEE_BigInt *dest,
+ IN int32_t shortVal);
+
+TEE_Result TEE_EXPORT TEE_BigIntConvertToS32(
+ OUT int32_t *dest,
+ IN TEE_BigInt *src);
+
+void TEE_EXPORT TEE_BigIntShiftRight(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op,
+ IN size_t bits);
+
+bool TEE_EXPORT TEE_BigIntGetBit(
+ IN TEE_BigInt *src,
+ IN uint32_t bitIndex);
+
+uint32_t TEE_EXPORT TEE_BigIntGetBitCount(
+ IN TEE_BigInt *src);
+
+void TEE_EXPORT TEE_BigIntAdd(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op1,
+ IN TEE_BigInt *op2);
+
+void TEE_EXPORT TEE_BigIntSub(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op1,
+ IN TEE_BigInt *op2);
+
+size_t TEE_EXPORT TEE_BigIntFMMContextSizeInU32(
+ size_t modulusSizeInBits);
+
+size_t TEE_EXPORT TEE_BigIntFMMSizeInU32(
+ size_t modulusSizeInBits);
+
+void TEE_EXPORT TEE_BigIntInitFMMContext(
+ OUT TEE_BigIntFMMContext *context,
+ size_t len,
+ IN TEE_BigInt *modulus);
+
+void TEE_EXPORT TEE_BigIntInitFMM(
+ OUT TEE_BigIntFMM *bigIntFMM,
+ size_t len);
+
+void TEE_EXPORT TEE_BigIntNeg(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op);
+
+void TEE_EXPORT TEE_BigIntMul(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op1,
+ IN TEE_BigInt *op2);
+
+void TEE_EXPORT TEE_BigIntSquare(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op);
+
+void TEE_EXPORT TEE_BigIntDiv(
+ OUT TEE_BigInt *dest_q,
+ OUT TEE_BigInt *dest_r,
+ IN TEE_BigInt *op1,
+ IN TEE_BigInt *op2);
+
+void TEE_EXPORT TEE_BigIntMod(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op,
+ IN TEE_BigInt *n);
+
+void TEE_EXPORT TEE_BigIntAddMod(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op1,
+ IN TEE_BigInt *op2,
+ IN TEE_BigInt *n);
+
+void TEE_EXPORT TEE_BigIntSubMod(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op1,
+ IN TEE_BigInt *op2,
+ IN TEE_BigInt *n);
+
+void TEE_EXPORT TEE_BigIntMulMod(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op1,
+ IN TEE_BigInt *op2,
+ IN TEE_BigInt *n);
+
+void TEE_EXPORT TEE_BigIntSquareMod(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op,
+ IN TEE_BigInt *n);
+
+void TEE_EXPORT TEE_BigIntInvMod(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigInt *op,
+ IN TEE_BigInt *n);
+
+bool TEE_EXPORT TEE_BigIntRelativePrime(
+ IN TEE_BigInt *op1,
+ IN TEE_BigInt *op2);
+
+void TEE_EXPORT TEE_BigIntComputeExtendedGcd(
+ OUT TEE_BigInt *gcd,
+ OUT TEE_BigInt *u,
+ OUT TEE_BigInt *v,
+ IN TEE_BigInt *op1,
+ IN TEE_BigInt *op2);
+
+int32_t TEE_EXPORT TEE_BigIntIsProbablePrime(
+ IN TEE_BigInt *op,
+ uint32_t confidenceLevel);
+
+void TEE_EXPORT TEE_BigIntConvertToFMM(
+ OUT TEE_BigIntFMM *dest,
+ IN TEE_BigInt *src,
+ IN TEE_BigInt *n,
+ IN TEE_BigIntFMMContext *context);
+
+void TEE_EXPORT TEE_BigIntConvertFromFMM(
+ OUT TEE_BigInt *dest,
+ IN TEE_BigIntFMM *src,
+ IN TEE_BigInt *n,
+ IN TEE_BigIntFMMContext *context);
+
+void TEE_EXPORT TEE_BigIntComputeFMM(
+ OUT TEE_BigIntFMM *dest,
+ IN TEE_BigIntFMM *op1,
+ IN TEE_BigIntFMM *op2,
+ IN TEE_BigInt *n,
+ IN TEE_BigIntFMMContext *context);
+
+ /*------------------------------------------------------------------------------
+ Cryptographic Operations API
+ ------------------------------------------------------------------------------*/
+
+ /*------------------------------------------------------------------------------
+ Generic Operations Functions
+ ------------------------------------------------------------------------------*/
+TEE_Result TEE_EXPORT TEE_AllocateOperation(TEE_OperationHandle* operation,
+ uint32_t algorithm,
+ uint32_t mode,
+ uint32_t maxKeySize);
+
+void TEE_EXPORT TEE_FreeOperation(TEE_OperationHandle operation);
+
+void TEE_EXPORT TEE_GetOperationInfo(TEE_OperationHandle operation,
+ TEE_OperationInfo* operationInfo);
+
+
+void TEE_EXPORT TEE_ResetOperation(TEE_OperationHandle operation);
+
+TEE_Result TEE_EXPORT TEE_SetOperationKey(TEE_OperationHandle operation,
+ TEE_ObjectHandle key);
+
+TEE_Result TEE_EXPORT TEE_SetOperationKey2(TEE_OperationHandle operation,
+ TEE_ObjectHandle key1,
+ TEE_ObjectHandle key2);
+
+void TEE_EXPORT TEE_CopyOperation(TEE_OperationHandle dstOperation,
+ TEE_OperationHandle srcOperation);
+
+
+/* Message Digest Functions */
+void TEE_EXPORT TEE_DigestUpdate(TEE_OperationHandle operation,
+ void* chunk,
+ size_t chunkSize);
+
+TEE_Result TEE_EXPORT TEE_DigestDoFinal(TEE_OperationHandle operation,
+ void* chunk,
+ size_t chunkLen,
+ void* hash,
+ size_t* hashLen);
+
+/* Symmetric Cipher Functions */
+void TEE_EXPORT TEE_CipherInit(TEE_OperationHandle operation,
+ void* IV,
+ size_t IVLen);
+
+TEE_Result TEE_EXPORT TEE_CipherUpdate(TEE_OperationHandle operation,
+ void* srcData,
+ size_t srcLen,
+ void* destData,
+ size_t* destLen);
+
+TEE_Result TEE_EXPORT TEE_CipherDoFinal(TEE_OperationHandle operation,
+ void* srcData,
+ size_t srcLen,
+ void* destData,
+ size_t* destLen);
+
+/*----------------------------------------------------------------------------
+ MAC Functions
+-----------------------------------------------------------------------------*/
+void TEE_EXPORT TEE_MACInit(TEE_OperationHandle operation,
+ void* IV,
+ size_t IVLen);
+
+void TEE_EXPORT TEE_MACUpdate(TEE_OperationHandle operation,
+ void* chunk,
+ size_t chunkSize);
+
+TEE_Result TEE_EXPORT TEE_MACComputeFinal(TEE_OperationHandle operation,
+ void* message,
+ size_t messageLen,
+ void* mac,
+ size_t* macLen);
+
+TEE_Result TEE_EXPORT TEE_MACCompareFinal(TEE_OperationHandle operation,
+ void* message,
+ size_t messageLen,
+ void* mac,
+ size_t macLen);
+
+/*----------------------------------------------------------------------------
+ Authenticated Encryption Functions ----------------------------------------
+ ---------------------------------------------------------------------------*/
+TEE_Result TEE_EXPORT TEE_AEInit(TEE_OperationHandle operation,
+ void* nonce,
+ size_t nonceLen,
+ uint32_t tagLen,
+ uint32_t AADLen,
+ uint32_t payloadLen);
+
+void TEE_EXPORT TEE_AEUpdateAAD(TEE_OperationHandle operation,
+ void* AADdata,
+ size_t AADdataLen);
+
+TEE_Result TEE_EXPORT TEE_AEUpdate(TEE_OperationHandle operation,
+ void* srcData,
+ size_t srcLen,
+ void* destData,
+ size_t* destLen);
+
+ TEE_Result TEE_EXPORT TEE_AEEncryptFinal(TEE_OperationHandle operation,
+ void* srcData,
+ size_t srcLen,
+ void* destData,
+ size_t* destLen,
+ void* tag,
+ size_t* tagLen);
+
+TEE_Result TEE_EXPORT TEE_AEDecryptFinal(TEE_OperationHandle operation,
+ void* srcData,
+ size_t srcLen,
+ void* destData,
+ size_t* destLen,
+ void* tag,
+ size_t tagLen);
+
+/*-----------------------------------------------------------------------------
+ Asymmetric Functions
+-----------------------------------------------------------------------------*/
+TEE_Result TEE_EXPORT TEE_AsymmetricEncrypt(TEE_OperationHandle operation,
+ TEE_Attribute* params,
+ uint32_t paramCount,
+ void* srcData,
+ size_t srcLen,
+ void* destData,
+ size_t* destLen);
+
+TEE_Result TEE_EXPORT TEE_AsymmetricDecrypt(TEE_OperationHandle operation,
+ TEE_Attribute* params,
+ uint32_t paramCount,
+ void* srcData,
+ size_t srcLen,
+ void* destData,
+ size_t* destLen);
+
+TEE_Result TEE_EXPORT TEE_AsymmetricSignDigest(TEE_OperationHandle operation,
+ TEE_Attribute* params,
+ uint32_t paramCount,
+ void* digest,
+ size_t digestLen,
+ void* signature,
+ size_t* signatureLen);
+
+TEE_Result TEE_EXPORT TEE_AsymmetricVerifyDigest(TEE_OperationHandle operation,
+ TEE_Attribute* params,
+ uint32_t paramCount,
+ void* digest,
+ size_t digestLen,
+ void* signature,
+ size_t signatureLen);
+
+/*-----------------------------------------------------------------------------
+ Key Derivation Functions
+-----------------------------------------------------------------------------*/
+void TEE_EXPORT TEE_DeriveKey(TEE_OperationHandle operation,
+ TEE_Attribute* params,
+ uint32_t paramCount,
+ TEE_ObjectHandle derivedKey);
+
+
+/*-----------------------------------------------------------------------------
+ Random Data Generation Function
+-----------------------------------------------------------------------------*/
+void TEE_EXPORT TEE_GenerateRandom(void* randomBuffer,
+ size_t randomBufferLen);
+
+
+/*------------------------------------------------------------------------------
+ Trusted Storage Functions
+------------------------------------------------------------------------------*/
+
+/* Generic Object Functions */
+void TEE_EXPORT TEE_GetObjectInfo(TEE_ObjectHandle object,
+ TEE_ObjectInfo* objectInfo);
+
+void TEE_EXPORT TEE_RestrictObjectUsage(TEE_ObjectHandle object,
+ uint32_t objectUsage);
+
+TEE_Result TEE_EXPORT TEE_GetObjectBufferAttribute(TEE_ObjectHandle object,
+ uint32_t attributeID,
+ void* buffer,
+ size_t* size);
+
+TEE_Result TEE_EXPORT TEE_GetObjectValueAttribute(TEE_ObjectHandle object,
+ uint32_t attributeID,
+ uint32_t* a,
+ uint32_t* b);
+
+void TEE_EXPORT TEE_CloseObject(TEE_ObjectHandle object);
+
+/* Transient Object Functions */
+TEE_Result TEE_EXPORT TEE_AllocateTransientObject(uint32_t objectType,
+ uint32_t maxObjectSize,
+ TEE_ObjectHandle* object);
+
+void TEE_EXPORT TEE_FreeTransientObject(TEE_ObjectHandle object);
+
+void TEE_EXPORT TEE_ResetTransientObject(TEE_ObjectHandle object);
+
+TEE_Result TEE_EXPORT TEE_PopulateTransientObject(TEE_ObjectHandle object,
+ TEE_Attribute* attrs,
+ uint32_t attrCount);
+
+void TEE_EXPORT TEE_InitRefAttribute(TEE_Attribute* attr,
+ uint32_t attributeID,
+ void* buffer,
+ size_t length);
+
+void TEE_EXPORT TEE_InitValueAttribute(TEE_Attribute* attr,
+ uint32_t attributeID,
+ uint32_t a,
+ uint32_t b);
+
+void TEE_EXPORT TEE_CopyObjectAttributes(TEE_ObjectHandle destObject,
+ TEE_ObjectHandle srcObject);
+
+TEE_Result TEE_EXPORT TEE_GenerateKey(TEE_ObjectHandle object,
+ uint32_t keySize,
+ TEE_Attribute* params,
+ uint32_t paramCount);
+
+/* Persistant Object Functions */
+TEE_Result TEE_EXPORT TEE_CreatePersistentObject(uint32_t storageID,
+ void* objectID,
+ size_t objectIDLen,
+ uint32_t flags,
+ TEE_ObjectHandle attributes,
+ void* initialData,
+ size_t initialDataLen,
+ TEE_ObjectHandle* object);
+
+TEE_Result TEE_EXPORT TEE_OpenPersistentObject(uint32_t storageID,
+ void* objectID,
+ size_t objectIDLen,
+ uint32_t flags,
+ TEE_ObjectHandle* object);
+
+void TEE_EXPORT TEE_CloseAndDeletePersistentObject(TEE_ObjectHandle object);
+
+TEE_Result TEE_EXPORT TEE_RenamePersistentObject(TEE_ObjectHandle object,
+ void* newObjectID,
+ size_t newObjectIDLen);
+
+TEE_Result TEE_EXPORT TEE_AllocatePersistentObjectEnumerator(TEE_ObjectEnumHandle* objectEnumerator);
+
+void TEE_EXPORT TEE_FreePersistentObjectEnumerator(TEE_ObjectEnumHandle objectEnumerator);
+
+void TEE_EXPORT TEE_ResetPersistentObjectEnumerator(TEE_ObjectEnumHandle objectEnumerator);
+
+TEE_Result TEE_EXPORT TEE_StartPersistentObjectEnumerator(TEE_ObjectEnumHandle objectEnumerator,
+ uint32_t storageID);
+
+TEE_Result TEE_EXPORT TEE_GetNextPersistentObject(TEE_ObjectEnumHandle objectEnumerator,
+ TEE_ObjectInfo* objectInfo,
+ void* objectID,
+ size_t* objectIDLen);
+
+TEE_Result TEE_EXPORT TEE_ReadObjectData(TEE_ObjectHandle object,
+ void* buffer,
+ size_t size,
+ uint32_t* count);
+
+TEE_Result TEE_EXPORT TEE_WriteObjectData(TEE_ObjectHandle object,
+ void* buffer,
+ size_t size);
+
+TEE_Result TEE_EXPORT TEE_TruncateObjectData(TEE_ObjectHandle object,
+ uint32_t size);
+
+TEE_Result TEE_EXPORT TEE_SeekObjectData(TEE_ObjectHandle object,
+ int32_t offset,
+ TEE_Whence whence);
+
+#endif /* __TEE_INTERNAL_API_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+/**
+ * @file tlDriverApi.h
+ * @brief Contains trustlet API definitions
+ *
+ */
+
+#ifndef __TLDRIVERAPI_H__
+#define __TLDRIVERAPI_H__
+
+#include "tlStd.h"
+#include "TlApi/TlApiError.h"
+
+
+/**
+ * Open session to the driver with given data
+ *
+ * @return session id
+ */
+_TLAPI_EXTERN_C uint32_t tlApiOpenSession( void );
+
+
+/**
+ * Close session
+ *
+ * @param sid session id
+ *
+ * @return TLAPI_OK upon success or specific error
+ */
+_TLAPI_EXTERN_C tlApiResult_t tlApiCloseSession( uint32_t sid );
+
+
+/**
+ * Inits session data (sample data 01)
+ *
+ * @param length data length
+ * @param address data address
+ *
+ * @return TLAPI_OK upon success or specific error
+ */
+_TLAPI_EXTERN_C tlApiResult_t tlApiInitSampleData01(
+ uint32_t sid,
+ uint32_t length,
+ uint32_t address);
+
+
+/**
+ * Inits session data (sample data 02)
+ *
+ * @param data
+ *
+ * @return TLAPI_OK upon success or specific error
+ */
+_TLAPI_EXTERN_C tlApiResult_t tlApiInitSampleData02(
+ uint32_t sid,
+ uint32_t data);
+
+
+/**
+ * Executes command
+ *
+ * @param sid session id
+ * @param commandId command id
+ *
+ * @return TLAPI_OK upon success or specific error
+ */
+_TLAPI_EXTERN_C tlApiResult_t tlApiExecute(
+ uint32_t sid,
+ uint32_t commandId);
+
+
+/** tlApi function to call driver via IPC.
+ * Sends a MSG_RQ message via IPC to a MobiCore driver.
+ *
+ * @param driverID The driver to send the IPC to.
+ * @param pMarParam MPointer to marshaling parameters to send to the driver.
+ *
+ * @return TLAPI_OK
+ * @return E_TLAPI_COM_ERROR in case of an IPC error.
+ */
+_TLAPI_EXTERN_C tlApiResult_t tlApi_callDriver(
+ uint32_t driver_ID,
+ void* pMarParam);
+
+
+#endif // __TLDRIVERAPI_H__
--- /dev/null
+/** Log wrapper for Android.
+ * @{
+ * @file
+ *
+ * Maps LOG_*() macros to __android_log_print() if LOG_ANDROID is defined.
+ * Adds some extra info to log output like LOG_TAG, file name and line number.
+ *
+ * <!-- Copyright Trustonic 2012-2013 -->
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef TLCWRAPPERANDROIDLOG_H_
+#define TLCWRAPPERANDROIDLOG_H_
+
+#ifndef WIN32
+#include <unistd.h>
+#define GETPID getpid
+#else
+#include <process.h>
+#define GETPID _getpid
+#endif
+#include <stdio.h>
+#ifndef WIN32
+#include <android/log.h>
+#endif
+#include <inttypes.h>
+#include <string.h>
+
+/** LOG_I(fmt, args...)
+ * Informative logging, only shown in debug version
+ */
+
+/** LOG_W(fmt, args...)
+ * Warnings logging, only shown in debug version
+ */
+
+/** LOG_E(fmt, args...)
+ * Error logging, shown in debug and release version
+ */
+
+/** LOG_V(fmt, args...)
+ * Verbose logging, shown in debug version if the including file defines LOG_VERBOSE
+ */
+
+/** LOG_I_BUF(szDescriptor, blob, sizeOfBlob)
+ * Binary logging, line-wise output to LOG_I
+ */
+
+#define EOL "\n"
+#define DUMMY_FUNCTION() do{}while(0)
+
+#ifdef LOG_ANDROID
+// log to adb logcat
+#ifdef NDEBUG // no logging in debug version
+ #define LOG_I(fmt, args...) DUMMY_FUNCTION()
+ #define LOG_W(fmt, args...) DUMMY_FUNCTION()
+#else
+ // add LINE
+ #define LOG_I(fmt, args...) LOG_i(fmt ";%d", ## args, __LINE__)
+ #define LOG_W(fmt, args...) LOG_w(fmt ";%d", ## args, __LINE__)
+#endif
+ // LOG_E is always defined
+ #define _LOG_E(fmt, args...) LOG_e(fmt, ## args)
+
+ // actually mapping to log system, adding level and tag.
+ #define LOG_i(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+ #define LOG_w(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
+ #define LOG_e(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
+
+#else //!defined(LOG_ANDROID)
+// log to std.out using printf
+
+ // #level / #LOG_TAG ( process_id): __VA_ARGS__
+ // Example:
+ // I/McDrvBasicTest_0_1( 4075): setUp
+ #define _LOG_x(_x_,...) \
+ do \
+ { \
+ printf("%s/%s(%d): ",_x_,LOG_TAG,GETPID()); \
+ printf(__VA_ARGS__); \
+ printf(EOL); \
+ } while(1!=1)
+
+
+#ifdef NDEBUG // no logging in debug version
+ #define LOG_I(fmt, ...) DUMMY_FUNCTION()
+ #define LOG_W(fmt, ...) DUMMY_FUNCTION()
+#else
+ #define LOG_I(...) _LOG_x("I", __VA_ARGS__)
+ #define LOG_W(...) _LOG_x("W", __VA_ARGS__)
+#endif
+ #define _LOG_E(...) _LOG_x("E", __VA_ARGS__)
+
+ #define LOG_i(...) printf(__VA_ARGS__)
+ #define LOG_w(...) printf(__VA_ARGS__)
+ #define LOG_e(...) printf(__VA_ARGS__)
+
+#endif //defined(LOG_ANDROID)
+
+#if defined(LOG_VERBOSE)
+#define LOG_V LOG_I
+#else
+#define LOG_V(...) DUMMY_FUNCTION()
+#endif
+
+/** LOG_E() needs to be more prominent:
+ * Display "*********** ERROR ***********" before actual error message.
+ */
+#define LOG_E(...) \
+ do \
+ { \
+ _LOG_E(" *****************************"); \
+ _LOG_E(" *** ERROR: " __VA_ARGS__); \
+ _LOG_E(" *** Detected in %s/%u()", __FUNCTION__, __LINE__); \
+ _LOG_E(" *****************************"); \
+ } while(1!=1)
+
+#define LOG_ERRNO(MESSAGE) \
+ LOG_E("%s failed with \"%s\"(errno %i)", MESSAGE, strerror(errno), errno);
+
+#define LOG_I_BUF LOG_I_Buf
+
+#ifndef WIN32
+__attribute__ ((unused))
+#endif
+static void LOG_I_Buf(
+ const char * szDescriptor,
+ const void * blob,
+ size_t sizeOfBlob
+) {
+
+ #define CPL 0x10 // chars per line
+ #define OVERHEAD 20
+
+ char buffer[CPL * 4 + OVERHEAD];
+
+ uint32_t index = 0;
+
+ uint32_t moreThanOneLine = (sizeOfBlob > CPL);
+ uint32_t blockLen = CPL;
+ uint32_t addr = 0;
+ uint32_t i = 0;
+
+ if (NULL != szDescriptor)
+ {
+ index += sprintf(&buffer[index], "%s", szDescriptor);
+ }
+
+ if (moreThanOneLine)
+ {
+ if (NULL == szDescriptor)
+ {
+ index += sprintf(&buffer[index], "memory dump");
+ }
+ index += sprintf(&buffer[index], " (0x%" PRIxPTR ", %zu bytes)", (uintptr_t)blob,sizeOfBlob);
+ LOG_I("%s", buffer);
+ index = 0;
+ }
+ else if (NULL == szDescriptor)
+ {
+ index += sprintf(&buffer[index], "Data at 0x%" PRIxPTR ": ", (uintptr_t)blob);
+ }
+
+ if(sizeOfBlob == 0) {
+ LOG_I("%s", buffer);
+ }
+ else
+ {
+ while (sizeOfBlob > 0)
+ {
+ if (sizeOfBlob < blockLen)
+ {
+ blockLen = sizeOfBlob;
+ }
+
+ // address
+ if (moreThanOneLine)
+ {
+ index += sprintf(&buffer[index], "0x%08X | ",addr);
+ addr += CPL;
+ }
+ // bytes as hex
+ for (i=0; i<blockLen; ++i)
+ {
+ index += sprintf(&buffer[index], "%02x ", ((const char *)blob)[i] );
+ }
+ // spaces if necessary
+ if ((blockLen < CPL) && (moreThanOneLine))
+ {
+ // add spaces
+ for (i=0; i<(3*(CPL-blockLen)); ++i) {
+ index += sprintf(&buffer[index], " ");
+ }
+ }
+ // bytes as ASCII
+ index += sprintf(&buffer[index], "| ");
+ for (i=0; i<blockLen; ++i)
+ {
+ char c = ((const char *)blob)[i];
+ index += sprintf(&buffer[index], "%c",(c>32)?c:'.');
+ }
+
+ blob = &(((const char *)blob)[blockLen]);
+ sizeOfBlob -= blockLen;
+
+ // print line to logcat / stdout
+ LOG_I("%s", buffer);
+ index = 0;
+ }
+ }
+}
+
+#endif /** TLCWRAPPERANDROIDLOG_H_ */
+
+/** @} */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __DRAPI_H__
+#define __DRAPI_H__
+
+#if defined(DRIVER)
+#include "drStd.h"
+#endif
+#include "DrApi/version.h"
+#include "DrApi/DrApiError.h"
+#include "DrApi/DrApiMcSystem.h"
+#include "DrApi/DrApiMm.h"
+#include "DrApi/DrApiThread.h"
+#include "DrApi/DrApiLogging.h"
+#include "DrApi/DrApiHeap.h"
+#include "DrApi/DrApiFastCall.h"
+#include "DrApi/DrApiTime.h"
+
+#endif // __DRAPI_H__
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __DRAPICOMMON_H__
+#define __DRAPICOMMON_H__
+
+#include "DrApi/DrApiError.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//------------------------------------------------------------------------------
+/** Definitions */
+
+#define SHIFT_4KB (12U) /**< SIZE_4KB is 1 << SHIFT_4KB aka. 2^SHIFT_4KB. */
+#define SIZE_4KB (1 << SHIFT_4KB) /**< Size of 1 KiB. */
+typedef uint8_t page4KB_t[SIZE_4KB]; /**< 4 KiB page. */
+typedef page4KB_t *page4KB_ptr; /**< pointer to 4 KiB page. */
+
+#define PTR2VAL(p) ((uintptr_t)(p))
+#define VAL2PTR(v) ((addr_t)(v))
+#define FUNC_PTR(func) VAL2PTR( PTR2VAL( func ) )
+
+//Stack types
+typedef uint32_t stackEntry_t;
+typedef stackEntry_t *stackEntry_ptr;
+typedef stackEntry_ptr stackTop_ptr;
+
+//==============================================================================
+//Common integer types
+typedef unsigned int u32_t;
+typedef unsigned short u16_t;
+typedef unsigned char u08_t;
+typedef u32_t word_t;
+
+//Common result type
+typedef word_t drApiResult_t;
+
+//MTK types
+typedef word_t taskid_t, *taskid_ptr; /**< task id data type. */
+typedef word_t threadno_t, *threadno_ptr; /**< thread no. data type. */
+typedef word_t threadid_t, *threadid_ptr; /**< thread id data type. */
+
+
+// interrupt mode flags. The design of the bits is that most common setting
+// RISING, EDGE, PERIODIC maps to the value the value 0. Not all mode
+// combinations may be available for each interrupt.
+#define INTR_MODE_MASK_TRIGGER (1U<<0)
+#define INTR_MODE_TRIGGER_LEVEL INTR_MODE_MASK_TRIGGER
+#define INTR_MODE_TRIGGER_EDGE 0
+#define INTR_MODE_MASK_CONDITION (1U<<1)
+#define INTR_MODE_CONDITION_FALLING INTR_MODE_MASK_CONDITION
+#define INTR_MODE_CONDITION_LOW INTR_MODE_MASK_CONDITION
+#define INTR_MODE_CONDITION_RISING 0
+#define INTR_MODE_CONDITION_HIGH 0
+#define INTR_MODE_MASK_OCCURANCE (1U<<2)
+#define INTR_MODE_OCCURANCE_ONESHOT INTR_MODE_MASK_OCCURANCE
+#define INTR_MODE_OCCURANCE_PERIODIC 0
+
+// convenience constants
+#define INTR_MODE_RAISING_EDGE (INTR_MODE_TRIGGER_EDGE | INTR_MODE_CONDITION_RISING)
+#define INTR_MODE_FALLING_EDGE (INTR_MODE_TRIGGER_EDGE | INTR_MODE_CONDITION_FALLING)
+#define INTR_MODE_LOW_LEVEL (INTR_MODE_TRIGGER_LEVEL | INTR_MODE_CONDITION_LOW)
+#define INTR_MODE_HIGH_LEVEL (INTR_MODE_TRIGGER_LEVEL | INTR_MODE_CONDITION_HIGH)
+
+//Interrupt types
+typedef word_t intrNo_t, *intrNo_ptr; /**< interrupt number. */
+typedef word_t intrMode_t, *intrMode_ptr; /**< interrupt mode. */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__DRAPICOMMON_H__
+
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __DRAPIERROR_H__
+#define __DRAPIERROR_H__
+
+/*
+ * DRAPI error codes.
+ * MAJOR part of error code is stable.
+ * MAJOR part may be used in testing for specific error code.
+ *
+ * Detail error codes may change in different releases
+ * Please do not test DETAIL part when comparing error codes.
+ */
+#define DRAPI_ERROR_MAJOR(ecode) ((ecode) & 0xFFF) /**< Get MAJOR part of error code. */
+#define DRAPI_ERROR_MAJOR_CODE(ecode) ((ecode) & 0xFF) /**< Get MAJOR_CODE part of error code. */
+#define DRAPI_ERROR_MAJOR_COMPONENT(ecode) (((ecode)>>8) & 0xF) /**< Get MAJOR_COMPONENT part of error code. */
+
+#define DRAPI_ERROR_DETAIL(ecode) (((ecode)>>12) & 0xFFF) /**< Get detail part of error code. */
+
+#define DRAPI_ERROR_CREATE(ecode, detail) (((ecode)&0xFFF)|((detail&0xFFF)<<12)) /**< Create error code */
+
+//==============================================================================
+// Error code defintitions
+
+#define DRAPI_OK 0x0 /**< Returns on successful execution of a function. */
+
+#define E_DRAPI_KERNEL_ERROR 0xF01 /**< Kernel returned error. */
+#define E_DRAPI_INVALID_PARAMETER 0xF02 /**< Invalid parameter. */
+#define E_DRAPI_NOT_PERMITTED 0xF03 /**< Permission error */
+#define E_DRAPI_IPC_ERROR 0xF04 /**< Error in IPC. */
+#define E_DRAPI_TASK_NOT_ACCEPTABLE 0xF05 /**< Task not acceptable for operation. */
+#define E_DRAPI_CANNOT_MAP 0xF06 /**< Cannot create mapping. */
+#define E_DRAPI_DRV_NO_SUCH_CLIENT 0xF07 /**< Client does not exist. */
+#define E_DRAPI_CANNOT_INIT 0xF08 /**< Cannot be initialized. */
+#define E_DRAPI_NOT_IMPLEMENTED 0xF09 /**< Function not yet implemented. */
+
+
+// Error codes inherited from MTK
+#define E_OK 0 /**< no error. */
+#define E_INVALID 1 /**< invalid argument. */
+#define E_BADTASK 2 /**< current task does not own target task. */
+#define E_NOTACTIVATED 3 /**< task has not been activated. */
+#define E_NOTOWNER 4 /**< current task does not own specified task. */
+#define E_ACTIVATED 5 /**< task has been activated. */
+#define E_LIMIT 6 /**< limit broken. */
+#define E_NOABILITY 7 /**< no permission. */
+#define E_STARTED 8 /**< task or thread does have been started. */
+#define E_BADMAP 9 /**< invalid mapping. architecture specific error. */
+#define E_MAPPED 10 /**< mapping overlaps existing mapping. */
+#define E_NOTSTARTED 11 /**< thread has been started. */
+#define E_TIMEOUT 12 /**< timeout period expired. */
+#define E_ABORT 13 /**< operation aborted. */
+#define E_MSGTYPE 14 /**< message to send is not of the type the receiver is waiting for. */
+#define E_MSGLENGTH 15 /**< message to send exceeds message length the receiver is waiting for. */
+
+
+#endif // __DRAPIERROR_H__
+
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef FASTCALL_H_
+#define FASTCALL_H_
+
+/** Firmware Driver and Fastcall Handlers
+ *
+ * Mobicore can have one firmware driver. Such driver is loaded
+ * typically at boot, and cannot be unloaded. Firmware driver is
+ * intended to act as system integration means, and is not intended
+ * to act as typical peripheral driver.
+ *
+ * Fastcall handlers
+ * Firmware driver can register fastcall handler in some platforms.
+ * Fastcall handler is called for fastcalls unknown to Mobicore.
+ *
+ * Fastcall handlers get driver memory mappings in range of 0-2MB
+ * at the time handler is installed. Driver must not unmap any of
+ * these mappings. If new mappings are made, they cannot be relied
+ * to be visible in fastcall hook function.
+ *
+ * Fastcall handler may map sections (of size 1M). These mappings are not
+ * visible to driver.
+ *
+ * Fastcall handler gets access to number of registers at the time of
+ * fastcall was made in NWd. Actual number of registers depends on
+ * platform, but is always at least 4 (r0-r3).
+ *
+ * Notes on use of Fastcall handlers
+ * Fastcall handlers
+ * - cannot call any TlApi or DrApi functions.
+ * - cannot have synchronization with firmware driver.
+ * - do not have large stack. If stack is needed, switch to your own.
+ * - may be executed concurrently in all CPUs.
+ * - must not cause exceptions. There is no means to recover in case
+ * of exception.
+ *
+ */
+
+#define FASTCALL_OWNER_TZOS (0xFF000000)
+#define FASTCALL_OWNER_SIP (0x81000000)
+#define FASTCALL_OWNER_OEM (0x83000000)
+#define FASTCALL_OWNER_STD (0x84000000)
+
+#define FASTCALL_OWNER_MASK (0xFF000000)
+
+#define FCH_L1_MAX 12
+
+typedef word_t *fastcall_registers_t;
+
+/** Context for FCs hook call
+ *
+ * This is (currently) shared between all processors
+ */
+struct fcContext {
+ word_t size; // Size of context
+ // Callback to modify L1 entry.
+ // idx is the address in MBytes of the entry to modify (starting at 8MB).
+ // (for example idx=2 will modify the entry for address 10MB)
+ // Return the virtual address corresponding to modified entry.
+ // Return NULL if there is an error.
+ // 64 bits version must be used to modify L1 table in LPAE mode.
+ void *(*setL1Entry)(struct fcContext *context, word_t idx, word_t entry);
+ word_t registers; // Number of registers available in fastcall
+ void (*prepareIdenticalMapping)(struct fcContext *context, addr_t start, word_t length, word_t flags);
+ void (*generateFcNotification)(struct fcContext *context);
+ void *(*setL1Entry64)(struct fcContext *context, word_t idx, uint64_t entry);
+};
+
+/* Fastcall handler initialization
+ *
+ * Called once before any fastcall.
+ * Can map memories for fastcall context.
+ * This function must never cause any exceptions.
+ * Call is executed in SVC mode.
+ *
+ * Return value
+ * 0 Successfull initialization.
+ * Other cancel hook installation
+ */
+typedef word_t (*fcInitHook)(
+ struct fcContext *context
+);
+
+
+/* Fastcall handler
+ *
+ * Executed possibly concurrently in all CPUs.
+ * This function must never cause any exceptions.
+ * Call is executed in IRQ mode.
+ * On Entry
+ * fastcall_regs_t[0]...fastcall_regs_t[15] contain input registers.
+ * On exit
+ * fastcall_regs_t[0]...fastcall_regs_t[N] contain r0...rN.
+ * If driver did not handle fastcall, registers must be unmodified.
+ * If driver handled fastcall registers r0...r3 may be modified.
+ * Registers beyond r3 must not be modified. Result of any
+ * modification is unpredictable.
+ * Return values
+ * Nonzero return value means that fastcall is handled.
+ */
+typedef word_t (*fcEntryHook)(
+ fastcall_registers_t *regs_t,
+ struct fcContext *context
+);
+
+
+#endif /* FASTCALL_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __DRAPIHEAP_H__
+#define __DRAPIHEAP_H__
+
+#if TBASE_API_LEVEL >= 3
+
+#include "DrApi/DrApiCommon.h"
+#include "DrApi/DrApiError.h"
+
+/**
+ * Allocates a block of memory from the heap.
+ * The address of the allocated block is aligned on a 8-bytes boundary. A block
+ * allocated by drApiMalloc must be freed by drApiFree.
+ * If the size of the space requested is zero, the value returned is still a
+ * non-NULL pointer that the Trusted Application must not attempt to access.
+ *
+ * @param size: [in] the number of bytes to be allocated.
+ *
+ * @param hint: [in] must be 0
+ *
+ * @return Upon successful completion, with size not equal to zero, the
+ * function returns a pointer to the allocated space.
+ * Otherwise, a NULL pointer is returned.
+ **/
+_DRAPI_EXTERN_C void* drApiMalloc(uint32_t size, uint32_t hint);
+
+/**
+ * Reallocates a block of memory from a heap.
+ * This function allows resizing a memory block.
+ * If buffer is NULL, drApiRealloc is equivalent to drApiMalloc.
+ * If buffer is not NULL and newSize is 0, then drApiRealloc is equivalent to
+ * drApiFree and returns a non-NULL pointer that the Trusted Application must
+ * not attempt to access.
+ * If newSize is less or equal to the current size of the block, the block is
+ * truncated, the content of the block is left unchanged and the function
+ * returns buffer.
+ * If newSize is greater than the current size of the block, the size of the
+ * block is increased. The whole content of the block is copied at the beginning
+ * of the new block. If possible, the block is enlarged in place and the
+ * function returns buffer. If this is not possible, a new block is allocated
+ * with the new size, the content of the current block is copied, the current
+ * block is freed and the function returns the pointer on the new block.
+ *
+ * @param buffer: [in] Pointer to the block of memory that the function
+ * reallocates.
+ * This value may be null or returned by an earlier call
+ * to drApiMalloc or drApiRealloc.
+ *
+ * @param newSize: [in] size of the memory block in bytes.
+ * This value may be zero.
+ *
+ * @return A pointer to the reallocated memory block, a non-NULL pointer if the
+ * newSize is zero or NULL if an error is detected.
+ **/
+_DRAPI_EXTERN_C void* drApiRealloc(void* buffer, uint32_t newSize);
+
+
+/**
+ * Frees a memory block allocated from a heap by drApiMalloc or drApiRealloc.
+ * This function does nothing if buffer is NULL.
+ *
+ * @param buffer: [in] Pointer to the block of memory to be freed.
+ **/
+_DRAPI_EXTERN_C void drApiFree(void* buffer);
+
+#endif /* TBASE_API_LEVEL */
+
+#endif /* !defined(__DRAPIHEAP_H__) */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+#ifndef __DRAPI_IPCMSG_H__
+#define __DRAPI_IPCMSG_H__
+
+#include "DrApiCommon.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//------------------------------------------------------------------------------
+/** Possible message types/event types of the system. */
+typedef enum {
+ MSG_NULL = 0, // Used for initializing state machines
+ MSG_RQ = 1,
+ // Client Request, blocks until MSG_RS is received
+ // Client -> Server
+ MSG_RS = 2,
+ // Driver Response, answer to MSG_RQ
+ // Server -> Client
+ MSG_RD = 3,
+ // Driver becomes ready
+ // Server -> IPCH
+ MSG_NOT = 4,
+ // Notification to NWd for a session, send-only message with no
+ // response
+ // client/server -> IPCH;
+ MSG_CLOSE_TRUSTLET = 5,
+ // Close Trustlet, must be answered by MSG_CLOSE_TRUSTLET_ACK
+ // MSH -> IPCH, IPCH -> Server
+ MSG_CLOSE_TRUSTLET_ACK = 6,
+ // Close Trustlet Ack, in response to MSG_CLOSE_TRUSTLET
+ // Server -> IPCH
+ MSG_MAP = 7,
+ // Map Client into Server, send-only message with no reponse
+ //Server -> IPCH;
+ MSG_ERR_NOT = 8,
+ // Error Notification
+ // EXCH/SIQH -> IPCH
+ MSG_CLOSE_DRIVER = 9,
+ // Close Driver, must be answered with MSG_CLOSE_DRIVER_ACK
+ // MSH -> IPCH, IPCH -> Driver/Server
+ MSG_CLOSE_DRIVER_ACK = 10,
+ // Close Driver Ack, response to MSG_CLOSE_DRIVER
+ // Driver/Server -> IPCH, IPCH -> MSH
+ MSG_GET_DRIVER_VERSION = 11,
+ // Get driver version, used for response also
+ // Client <-> IPCH
+ MSG_GET_DRAPI_VERSION = 12,
+ // Get DrApi version, used for response also
+ // Driver <-> IPCH */
+ MSG_SET_NOTIFICATION_HANDLER = 13,
+ // Set (change) the SIQ handler thread, used for response also
+ // Driver <-> IPCH
+ MSG_GET_REGISTRY_ENTRY = 14,
+ // Get registry entry, available only if MC_FEATURE_DEBUG_SUPPORT is
+ // set, used for response also
+ // Driver <-> IPCH
+ MSG_DRV_NOT = 15,
+ // Notification to a Trustlet, looks like a notification from NWd for
+ // the Trustlet, send-only message with no response
+ // Driver -> Trustlet
+ MSG_SET_FASTCALL_HANDLER = 16,
+ // install a FastCall handler, used for response also
+ // Driver <-> IPCH
+ MSG_GET_CLIENT_ROOT_AND_SP_ID = 17,
+ // get Root DI and SP ID, used for response also
+ // Driver <-> IPCH
+ MSG_SUSPEND = 18,
+ // Suspend, requires MSG_SUSPEND_ACK as response
+ // MSH -> IPCH, IPCH -> driver
+ MSG_SUSPEND_ACK = 19,
+ // Suspend Ack, response to MSG_SUSPEND
+ // driver -> IPCH, IPCH -> MSH
+ MSG_RESUME = 20,
+ // resume, , requires MSG_RESUME_ACK as response
+ // MSH -> IPCH, IPCH -> driver
+ MSG_RESUME_ACK = 21,
+ // resume, , response to MSG_RESUME
+ // driver -> IPCH, IPCH -> MSH
+ MSG_GET_ENDORSEMENT_SO = 22,
+ // get SO from RTM for the Endorsement functionality
+ // Driver <-> IPCH
+ MSG_GET_SERVICE_VERSION = 23,
+ // get version of service (TA)
+ // Driver <-> IPCH
+ MSG_ERROR = 24,
+ // IPCH returns error to Driver
+ // IPCH <-> DRIVER
+ MSG_CALL_FASTCALL = 25,
+ // Call fastcall from driver
+ // DRIVER -> IPCH -> MTK -> FASTCALL -> return
+} message_t;
+
+
+//------------------------------------------------------------------------------
+/** Waits with infinite timeout for IPC.
+ *
+ * @param ipcPartner IPC partner to signal.
+ * @param pMr0 IPC register 0.
+ * @param pMr1 IPC register 1.
+ * @param pMr2 IPC register 2.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiIpcWaitForMessage(
+ threadid_t *pIpcPartner,
+ uint32_t *pMr0,
+ uint32_t *pMr1,
+ uint32_t *pMr2
+);
+
+//------------------------------------------------------------------------------
+/**
+ * Send ready message or answer to IPCH and waits for a client request
+ *
+ * @param ipcPeer Destination to send message to.
+ * @param ipcMsg IPC message.
+ * @param ipcData Additional IPC data.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiIpcCallToIPCH(
+ threadid_t *pIpcPeer,
+ message_t *pIpcMsg,
+ uint32_t *pIpcData
+);
+
+//------------------------------------------------------------------------------
+/** Sets signal.
+ * The signal (SIGNAL) is used by a thread to inform another thread about an event.
+ * The signal operation is asynchronous, which means that the operation will return
+ * immediately without blocking the user. Function uses auto-clear signals, meaning that
+ * the signal is cleared automatically when the receiver receives it.
+ *
+ * It is up to the destination of the signal to pick up and process the information.
+ *
+ * @param receiver Thread to set the signal for.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiIpcSignal(
+ const threadid_t receiver
+);
+
+//------------------------------------------------------------------------------
+/** Signal wait operation.
+ * A thread uses the sigWait operation to check if a signal has occurred. If no signal is
+ * pending the thread will block until a signal arrives.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiIpcSigWait( void );
+
+//------------------------------------------------------------------------------
+/** Notify NWd driver
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiNotify( void );
+
+
+//------------------------------------------------------------------------------
+/**
+ * Makes control syscall with given parameters
+ *
+ * @param controlid control id
+ * @param param1 parameter 1
+ * @param param2 parameter 2
+ * @param param3 parameter 3
+ * @param param4 parameter 4
+ * @param *data set by control syscall
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiSyscallControl(
+ uint32_t controlid,
+ uint32_t param1,
+ uint32_t param2,
+ uint32_t param3,
+ uint32_t param4,
+ uint32_t *data
+);
+
+
+//------------------------------------------------------------------------------
+/** Reads OEM data starting from given offset
+ *
+ * @param offset data offset
+ * @param data set by control syscall
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiReadOemData(
+ const uint32_t offset,
+ uint32_t *data
+);
+
+//------------------------------------------------------------------------------
+/** Sends notification to client
+ *
+ * @param client Client's thread id
+ * *
+ * @return MTK return code
+ */
+drApiResult_t drApiNotifyClient(
+ const threadid_t client
+);
+
+//------------------------------------------------------------------------------
+/** Returns ID of Root and Service Provider ID of the specified client
+ *
+ * @param rootId ID of Root
+ * @param spId Service Provider ID
+ * @param client Thread ID
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiGetClientRootAndSpId(
+ uint32_t *rootId,
+ uint32_t *spId,
+ const threadid_t client
+);
+
+
+//------------------------------------------------------------------------------
+/**
+ * Handles unknown messages
+ * This function has to be called by Driver if it receives a message it doesn’t recognize
+ *
+ * @param ipcPeer Sender of message.
+ * @param ipcMsg IPC message.
+ * @param ipcData Additional IPC data.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiIpcUnknownMessage(
+ threadid_t *pIpcPeer,
+ message_t *pIpcMsg,
+ uint32_t *pIpcData
+);
+
+//------------------------------------------------------------------------------
+#if TBASE_API_LEVEL >= 3
+/**
+ * Makes request to t-base to update notification thread
+ *
+ * @param threadNo Number of the new notification thread.
+ *
+ * @retval DRAPI_OK or relevant error code.
+ */
+drApiResult_t drApiUpdateNotificationThread(
+ threadno_t threadno
+);
+#endif /* TBASE_API_LEVEL */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __DRAPI_IPCMSG_H__ */
+
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __DRAPILOGGING_H__
+#define __DRAPILOGGING_H__
+
+#include "DrApi/DrApiCommon.h"
+#include "DrApi/DrApiError.h"
+
+/** Formatted logging functions.
+ *
+ * drApiLogvPrintf, drApiLogPrintf
+ *
+ * Minimal printf-like function to print logging message to NWd log.
+ *
+ * Supported formatters:
+ * %s String, NULL value emit "<NULL>".
+ * %x %X hex
+ * %p pointer (hex with fixed width of 8)
+ * %d %i signed decimal
+ * %u unsigned decimal
+ * %t timestamp (if available in platform). NOTE: This does not consume any value in parameter list.
+ * %% outputs single %
+ *
+ * %s, %x, %d, and %u support width (example %5s). Width is interpreted as minimum number of characters.
+ * Hex number is left padded using '0' to desired width.
+ * Decimal number is left padded using ' ' to desired width.
+ * String is right padded to desired length.
+ *
+ * Newline is used to terminate logging line.
+ *
+ * @param fmt Formatter
+ * @param args Argument list.
+ */
+_DRAPI_EXTERN_C void drApiLogvPrintf(
+ const char *fmt,
+ va_list args);
+
+_DRAPI_EXTERN_C void drApiLogPrintf(
+ const char *fmt,
+ ...);
+
+#if defined(__INCLUDE_DEBUG)
+
+ #define drDbgPrintf(...) drApiLogPrintf(__VA_ARGS__)
+ #define drDbgvPrintf(...) drApiLogvPrintf(__VA_ARGS__)
+
+#else
+
+ #define drDbgPrintf(...) DUMMY_FUNCTION()
+ #define drDbgvPrintf(...) DUMMY_FUNCTION()
+
+#endif // __INCLUDE_DEBUG
+
+#ifndef EOL
+ #define EOL "\n"
+#endif
+
+#define drDbgPrintLnf(...) do{drDbgPrintf(__VA_ARGS__);dbgS(EOL);}while(FALSE)
+
+
+#endif // __DRAPILOGGING_H__
+
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __DRAPIMCSYSTEM_H__
+#define __DRAPIMCSYSTEM_H__
+
+#include "DrApiCommon.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Get information about the implementation of the MobiCore Driver API version.
+ *
+ * @param drApiVersion pointer to Driver Api version.
+ * @returns DRAPI_OK if version has been set
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+_DRAPI_EXTERN_C drApiResult_t drApiGetVersion(
+ uint32_t *drApiVersion);
+
+/** Install fastcall handler
+ *
+ * @param entryTable pointer to entry table.
+ * @param fastcallId fastcall ID.
+ * @returns DRAPI_OK if version has been set
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+_DRAPI_EXTERN_C drApiResult_t drApiInstallFc(
+ void *entryTable, uint32_t fastcallId);
+
+
+_DRAPI_EXTERN_C drApiResult_t drApiFastCall(
+ uint32_t *fastcall_registers,
+ uint32_t size);
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __DRAPIMCSYSTEM_H__
+
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __DRAPIMM_H__
+#define __DRAPIMM_H__
+
+#include "DrApiCommon.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//------------------------------------------------------------------------------
+/** Definitions */
+
+/** Memory mapping attributes. */
+#define MAP_READABLE (1U << 0) /**< mapping gives have the ability to do read access. */
+#define MAP_WRITABLE (1U << 1) /**< mapping gives have the ability to do write access. */
+#define MAP_EXECUTABLE (1U << 2) /**< mapping gives have the ability to do program execution. */
+#define MAP_UNCACHED (1U << 3) /**< mapping gives have uncached memory access. */
+#define MAP_IO (1U << 4) /**< mapping gives have memory mapped I/O access. Will ignore MAP_UNCACHED, as this would be implied anyway. */
+
+//------------------------------------------------------------------------------
+/** Maximum number of parameter . */
+#define MAX_MAR_LIST_LENGTH 8 /**< Maximum list of possible marshaling parameters. */
+/** Marshaled union. */
+typedef struct {
+ uint32_t functionId; /**< Function identifier. */
+ union {
+ uint32_t parameter[MAX_MAR_LIST_LENGTH]; /* untyped parameter list (expands union to 8 entries) */
+ } payload;
+} drApiMarshalingParam_t, *drApiMarshalingParam_ptr;
+
+
+//------------------------------------------------------------------------------
+/** Address translation from trustlet to Driver address space.
+ * Translates an address/pointer given by a Trustlet to the Driver mapping.
+ * Checks correct address range and null pointer.
+ *
+ * @param addr Address in trustlet address space.
+ * @returns address in Driver virtual space
+ * @returns NULL if address is equal to NULL or if address is out of D3-D8 address space
+ */
+addr_t drApiAddrTranslateAndCheck(addr_t addr);
+
+//------------------------------------------------------------------------------
+#if TBASE_API_LEVEL >= 3
+
+/** Addresses translation for a buffer from trustlet to driver address space.
+ * Checks that the buffer given by its start address and its length fits correct address range.
+ * Translate the start address/pointer given by a trustlet to the driver's mapping.
+ *
+ * @param addr Start address of the buffer in trustlet address space.
+ * @param len Length of the buffer
+ * @returns start address in Driver virtual space
+ * @returns NULL if address is equal to NULL or if the buffer is out of D3-D8 address space
+ */
+addr_t drApiAddrTranslateAndCheckBuffer(addr_t adr, uint32_t len);
+
+#endif /* TBASE_API_LEVEL */
+
+//------------------------------------------------------------------------------
+/** Maps requesting client and return translated pointer to request parameters
+ *
+ * @param ipcReqClient client requesting a service
+ * @param params pointer to marshaled parameter in client address space
+ * @returns pointer to parameter for request in the current address space
+ * @returns NULL in case of error
+ */
+drApiMarshalingParam_ptr drApiMapClientAndParams(
+ threadid_t ipcReqClient,
+ uint32_t params
+);
+
+//------------------------------------------------------------------------------
+
+/** Maps a physical page to a virtual address.
+ * All addresses and lengths must be multiples of page size (4K).
+ *
+ * @param startVirt virtual address in Driver address space
+ * @param len Length of area
+ * @param startPhys physical address of hardware
+ * @param attr mapping attributes
+ * @returns DRAPI_OK in case of success
+ * @returns E_DRAPI_INVALID_PARAMETER in case any input parameter is not page size aligned or designated virtual memory area does not fit into D1-D2 address range
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+
+drApiResult_t drApiMapPhys(
+ const addr_t startVirt,
+ const uint32_t len,
+ const addr_t startPhys,
+ const uint32_t attr
+);
+#if TBASE_API_LEVEL >= 3
+drApiResult_t drApiMapPhys64(
+ const addr_t startVirt,
+ const uint32_t len,
+ const uint64_t startPhys,
+ const uint32_t attr
+);
+#endif /* TBASE_API_LEVEL */
+
+/** Removes mapping for virtual pages.
+ * All addresses and lengths must be multiples of page size (4K).
+ *
+ * @param startVirt virtual address in Driver address space
+ * @param len Length of area
+ * @returns DRAPI_OK in case of success
+ * @returns E_DRAPI_INVALID_PARAMETER in case any input parameter is not page size aligned or designated virtual memory area does not fit into D1-D2 address range
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+
+drApiResult_t drApiUnmap(
+ const addr_t startVirt,
+ const uint32_t len
+);
+
+//------------------------------------------------------------------------------
+/** The function removes mapping for a single page.
+ *
+ * @param startVirt virtual address in Driver address space
+ * @returns DRAPI_OK in case of success
+ * @returns E_DRAPI_INVALID_PARAMETER in case any input parameter is not page size aligned or designated virtual memory area does not fit into D1-D2 address range
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiUnmapPage4KB(
+ const page4KB_ptr virtPage
+);
+
+//------------------------------------------------------------------------------
+/** Maps a single physical page to a virtual address
+ *
+ * @param physPage virtual address in Driver address space
+ * @param startPhys physical address of hardware
+ * @param attr mapping attributes
+ * @returns DRAPI_OK in case of success
+ * @returns E_DRAPI_INVALID_PARAMETER in case any input parameter is not page size aligned or designated virtual memory area does not fit into D1-D2 address range
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiMapPhysPage4KB(
+ const page4KB_ptr virtPage,
+ const page4KB_ptr physPage,
+ const uint32_t attr
+);
+#if TBASE_API_LEVEL >= 3
+drApiResult_t drApiMapPhysPage4KB64(
+ const page4KB_ptr virtPage,
+ const uint64_t physPage,
+ const uint32_t attr
+);
+#endif /* TBASE_API_LEVEL */
+
+//------------------------------------------------------------------------------
+/** Maps a physical page with hardware interface
+ * This is prepared auxiliary function that at first removes mapping of the virtPage (if present)
+ * and then maps it with MAP_READABLE | MAP_WRITABLE | MAP_IO attributes
+ *
+ * @param physPage virtual address in Driver address space
+ * @param startPhys physical address of hardware
+ * @returns DRAPI_OK in case of success
+ * @returns E_DRAPI_INVALID_PARAMETER in case any input parameter is not page size aligned or designated virtual memory area does not fit into D1-D2 address range
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiMapPhysPage4KBWithHardware(
+ const page4KB_ptr virtPage,
+ const page4KB_ptr physPage
+);
+#if TBASE_API_LEVEL >= 3
+drApiResult_t drApiMapPhysPage4KBWithHardware64(
+ const page4KB_ptr virtPage,
+ const uint64_t physPage
+);
+#endif /* TBASE_API_LEVEL */
+
+//------------------------------------------------------------------------------
+/** Converts virtual address (in Driver address space) to physical address
+ *
+ * @param taskid Reserved for Future Use. It must be set to zero.
+ * @param virtAddr virtual address in Driver address space
+ * @param physAddr physical address
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiVirt2Phys(
+ const taskid_t taskid,
+ const addr_t virtAddr,
+ addr_t * physAddr
+);
+#if TBASE_API_LEVEL >= 3
+drApiResult_t drApiVirt2Phys64(
+ const taskid_t taskid,
+ const addr_t virtAddr,
+ uint64_t * physAddr
+);
+#endif /* TBASE_API_LEVEL */
+
+//------------------------------------------------------------------------------
+/** Clean all data cache
+ *
+ * NOTE: Currently addr is always NULL.
+ * When extending this for not-clean-all, one can assume that there is
+ * more parameters ONLY if addr is non-NULL.
+ * Also this ensures that more specific cleans are mapped to cleanall, if specific clean is not supported.
+ *
+ * @param none
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiCacheDataCleanAll( void );
+
+
+//------------------------------------------------------------------------------
+/** Cleans and invalidates all data cache
+ *
+ * NOTE: Currently addr is always NULL.
+ * When extending this for not-clean-invalidate-all, one can assume that there is
+ * more parameters ONLY if addr is non-NULL.
+ * Also this ensures that more specific cleans are mapped to cleanall, if specific clean is not supported.
+ *
+ * @param none
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiCacheDataCleanInvalidateAll( void );
+
+
+//------------------------------------------------------------------------------
+#if TBASE_API_LEVEL >= 3
+
+/** Clean a portion of the data cache by MVA
+ *
+ * @param virtAddrStart
+ * @param virtAddrEnd
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiCacheDataCleanRange(
+ addr_t *virtAddrStart,
+ uint32_t len,
+ uint32_t flags
+);
+
+
+//------------------------------------------------------------------------------
+/** Cleans and invalidates a portion of data cache by MVA
+ *
+ * @param virtAddrStart
+ * @param virtAddrEnd
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiCacheDataCleanInvalidateRange(
+ addr_t *virtAddrStart,
+ uint32_t len,
+ uint32_t flags
+);
+
+//------------------------------------------------------------------------------
+/** Cache clean attributes */
+#define DRAPI_CACHE_ALL (0xff)
+#define DRAPI_CACHE_L1_ONLY (0x1)
+#define DRAPI_CACHE_L1_L2 (0x2)
+#endif /* TBASE_API_LEVEL */
+
+//------------------------------------------------------------------------------
+/** Memory type attributes */
+#define DRAPI_PHYS_MEM_TYPE_HIGH_SECURE (1U<<0) /**< High secure memory. (Typically iRam) */
+#define DRAPI_PHYS_MEM_TYPE_SECURE (1U<<1) /**< Secure memory in Dram */
+#define DRAPI_PHYS_MEM_TYPE_NON_SECURE (1U<<2) /**< NonSecure memory in Dram. Accessible from NonSecure world */
+
+/** Returns physical memory type (secure or non-secure)
+ *
+ * @param type pointer to address where type is returned
+ * @param addr start address of checked memory
+ * @param size size checked memory
+ * @returns E_OK in case of success
+ */
+
+drApiResult_t drApiGetPhysMemType(
+ uint32_t *type,
+ addr_t addr,
+ uint32_t size
+ );
+#if TBASE_API_LEVEL >= 3
+drApiResult_t drApiGetPhysMemType64(
+ uint32_t *type,
+ uint64_t addr,
+ uint32_t size
+ );
+#endif /* TBASE_API_LEVEL */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __DRAPIMM_H__
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __DRAPI_THREAD_H__
+#define __DRAPI_THREAD_H__
+
+#include "DrApiCommon.h"
+#include "DrApiIpcMsg.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//------------------------------------------------------------------------------
+/** Definitions */
+#define NILTASK 0 /**< returns NILTASK. */
+#define NILTHREAD 0 /**< returns NILTHREAD. */
+
+#define MAX_PRIORITY (15U) /**< maximum priority of a task or thread. */
+
+#if defined(DRIVER)
+#define ANYINTR 0x0000FFFF /**< returns ANYINTR. */
+#endif
+
+#define TASK_THREAD_QUOTA_SHL 24
+#define TASK_TIME_QUOTA_MASK ((1 << TASK_THREAD_QUOTA_SHL) - 1) /**< mask to get/set time quota of a task. */
+#define TIME_INFINITE ((time_t)TASK_TIME_QUOTA_MASK) /**< returns infinite. */
+
+/* Control ids for drApiThreadExRegs() API call */
+#define THREAD_EX_REGS_IP (1U << 0) /**< currently set instruction pointer of the thread is replaced by the specified instruction pointer. */
+#define THREAD_EX_REGS_SP (1U << 1) /**< currently set stack pointer of the thread is replaced by the specified stack pointer. */
+
+//------------------------------------------------------------------------------
+// Time data type
+typedef word_t time_t, *time_ptr;
+
+
+//------------------------------------------------------------------------------
+/**
+ * Returns task ID for current task.
+ *
+ * @returns taskid
+ * @returns 0 in case of any error
+ */
+taskid_t drApiGetTaskid( void );
+
+//------------------------------------------------------------------------------
+/**
+ * The function returns thread ID corresponding to task ID and thread number specified.
+ *
+ * @param taskid taskid having the thread.
+ * @param threadno Thread number in task.
+ *
+ * @returns Thread ID in case of success
+ * @returns 0 if task ID or thread number are invalid.
+ */
+threadid_t drApiTaskidGetThreadid(
+ taskid_t taskid,
+ threadno_t threadNo
+);
+
+//------------------------------------------------------------------------------
+/**
+ * The function returns thread ID for current task corresponding to thread number specified.
+ *
+ * @param threadNo Thread number in current task.
+ *
+ * @returns Thread ID in case of success
+ * @returns 0 thread number is invalid.
+ *
+ */
+threadid_t drApiGetLocalThreadid(
+ threadno_t threadNo
+);
+
+//------------------------------------------------------------------------------
+/** Suspend current thread.
+ *
+ * @param timeout Time to suspend thread.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiThreadSleep(
+ time_t timeout
+);
+
+//------------------------------------------------------------------------------
+/** Starts a thread in Driver.
+ * @param threadNo Thread number in task.
+ * @param threadEntry Thread entry function
+ * @param stackPointer Thread top stack pointer (declared statically using DECLARE_STACK)
+ * @param priority Thread priority (Maximum level is defined as MAX_PRIORITY, higher priority level corresponds to higher priority thread)
+ * @param localExceptionHandler The parameter specifies the number of a thread that serves as an exception handler
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiStartThread(
+ const threadno_t threadNo,
+ const addr_t threadEntry,
+ const stackTop_ptr stackPointer,
+ const uint32_t priority,
+ const threadno_t localExceptionHandlerThreadNo
+);
+
+
+//------------------------------------------------------------------------------
+/** Stop a thread in Driver.
+ * If thread no. of thread to stop is set to NILTHREAD,
+ * the current thread is stopped. The to stopped thread is detached from any
+ * previously attached interrupts. If any thread is waiting for stopped thread
+ * to do any ipc, this ipc is aborted.
+ *
+ * @param threadNo Thread number in task.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+
+drApiResult_t drApiStopThread(
+ const threadno_t threadNo
+);
+
+
+//------------------------------------------------------------------------------
+/** Resumes a thread in Driver.
+ *
+ * @param threadNo Thread number in task.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+
+drApiResult_t drApiResumeThread(
+ const threadno_t threadNo
+);
+
+
+//------------------------------------------------------------------------------
+/** Sets priority level for a thread in Driver.
+ * @param threadNo Thread number in task.
+ * @param priority Thread priority (Maximum level is defined as MAX_PRIORITY, higher priority level corresponds to higher priority thread)
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiSetThreadPriority(
+ const threadno_t threadNo,
+ const uint32_t priority
+);
+
+//------------------------------------------------------------------------------
+/**
+ * Sets the value registers for specified thread.
+ * if the @ref THREAD_EX_REGS_IP bit of argument ctrl is set, the currently set instruction pointer is exchanged by the value of the argument ip (3).
+ * if the @ref THREAD_EX_REGS_SP bit of argument ctrl is set, the currently set stack pointer is exchanged by the value of the argument sp (4).
+ *
+ * @param threadNo Number of the thread.
+ * @param ctrl Control flags
+ * @param ip ip value
+ * @param sp sp value
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiThreadExRegs(
+ const threadno_t threadNo,
+ const uint32_t ctrl,
+ const addr_t ip,
+ const addr_t sp
+);
+
+//------------------------------------------------------------------------------
+#if TBASE_API_LEVEL >= 3
+/**
+ * Restart an internal thread with given IP and SP.
+ *
+ * @param threadNo Number of the thread.
+ * @param ip ip value
+ * @param sp sp value
+ *
+ * @retval DRAPI_OK or relevant error code.
+ */
+drApiResult_t drApiRestartThread(
+ const threadno_t threadno,
+ const addr_t ip,
+ const addr_t sp
+);
+#endif /* TBASE_API_LEVEL */
+
+//------------------------------------------------------------------------------
+/** Attaches an interrupt with the specified trigger condition to current thread.
+ * Please refer to the target platform specific MobiCore documentation about
+ * the trigger modes supported for each interrupt. In most cases, the mode
+ * parameters will be INTR_MODE_RAISING_EDGE, as interrupts usually indicate
+ * that a certain event has happened.
+ *
+ * @param intrNo interrupt number.
+ * @param intrMode interrupt mode.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiIntrAttach(
+ intrNo_t intrNo,
+ intrMode_t intrMode
+);
+
+
+//------------------------------------------------------------------------------
+/** Detaches interrupt from current thread.
+ *
+ * @param intrNo interrupt number.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiIntrDetach(
+ intrNo_t intrNo
+);
+
+//------------------------------------------------------------------------------
+/** Wait with infinite timeout for interrupt message from kernel.
+ *
+ * @param intrNo interrupt number (if ANYINTR is used, the interrupt is returned in the parameter intrRet).
+ * @param timeout timeout to wait (allowed the same values as for MTK signal_wait()).
+ * @param pIntrRet receives interrupt. Parameter can be NULL if caller does not need this.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiWaitForIntr(
+ const intrNo_t intrNo,
+ const uint32_t timeout,
+ intrNo_t *pIntrRet
+);
+
+//------------------------------------------------------------------------------
+/**
+ * Trigger software interrupt in the NWd to notify it.
+ *
+ * @param intrNo interrupt number.
+ *
+ * @returns DRAPI_OK in case of success
+ * @returns any combination of DRAPI_ERROR_CREATE(Driver specific error code, MTK error code)
+ */
+drApiResult_t drApiTriggerIntr(
+ intrNo_t intrNo
+);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __DRAPI_THREAD_H__
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+#ifndef DRAPI_VERSION_H_
+#define DRAPI_VERSION_H_
+
+#define DRAPI_VERSION_MAJOR 1
+#define DRAPI_VERSION_MINOR 1
+
+#endif /** DRAPI_VERSION_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef FASTCALL_H_
+#define FASTCALL_H_
+
+/** Firmware Driver and Fastcall Handlers
+ *
+ * Mobicore can have one firmware driver. Such driver is loaded
+ * typically at boot, and cannot be unloaded. Firmware driver is
+ * intended to act as system integration means, and is not intended
+ * to act as typical peripheral driver.
+ *
+ * Fastcall handlers
+ * Firmware driver can register fastcall handler in some platforms.
+ * Fastcall handler is called for fastcalls unknown to Mobicore.
+ *
+ * Fastcall handlers get driver memory mappings in range of 0-2MB
+ * at the time handler is installed. Driver must not unmap any of
+ * these mappings. If new mappings are made, they cannot be relied
+ * to be visible in fastcall hook function.
+ *
+ * Fastcall handler may map sections (of size 1M). These mappings are not
+ * visible to driver.
+ *
+ * Fastcall handler gets access to number of registers at the time of
+ * fastcall was made in NWd. Actual number of registers depends on
+ * platform, but is always at least 4 (r0-r3).
+ *
+ * Notes on use of Fastcall handlers
+ * Fastcall handlers
+ * - cannot call any TlApi or DrApi functions.
+ * - cannot have synchronization with firmware driver.
+ * - do not have large stack. If stack is needed, switch to your own.
+ * - may be executed concurrently in all CPUs.
+ * - must not cause exceptions. There is no means to recover in case
+ * of exception.
+ *
+ */
+
+#define FASTCALL_OWNER_TZOS (0xFF000000)
+#define FASTCALL_OWNER_SIP (0x81000000)
+#define FASTCALL_OWNER_OEM (0x83000000)
+#define FASTCALL_OWNER_STD (0x84000000)
+
+#define FASTCALL_OWNER_MASK (0xFF000000)
+
+#define FCH_L1_MAX 12
+
+typedef word_t *fastcall_registers_t;
+
+/** Context for FCs hook call
+ *
+ * This is (currently) shared between all processors
+ */
+struct fcContext {
+ word_t size; // Size of context
+ // Callback to modify L1 entry.
+ // idx is the address in MBytes of the entry to modify (starting at 8MB).
+ // (for example idx=2 will modify the entry for address 10MB)
+ // Return the virtual address corresponding to modified entry.
+ // Return NULL if there is an error.
+ // 64 bits version must be used to modify L1 table in LPAE mode.
+ void *(*setL1Entry)(struct fcContext *context, word_t idx, word_t entry);
+ word_t registers; // Number of registers available in fastcall
+ void (*prepareIdenticalMapping)(struct fcContext *context, addr_t start, word_t length, word_t flags);
+ void (*generateFcNotification)(struct fcContext *context);
+ void *(*setL1Entry64)(struct fcContext *context, word_t idx, uint64_t entry);
+};
+
+/* Fastcall handler initialization
+ *
+ * Called once before any fastcall.
+ * Can map memories for fastcall context.
+ * This function must never cause any exceptions.
+ * Call is executed in SVC mode.
+ *
+ * Return value
+ * 0 Successfull initialization.
+ * Other cancel hook installation
+ */
+typedef word_t (*fcInitHook)(
+ struct fcContext *context
+);
+
+
+/* Fastcall handler
+ *
+ * Executed possibly concurrently in all CPUs.
+ * This function must never cause any exceptions.
+ * Call is executed in IRQ mode.
+ * On Entry
+ * fastcall_regs_t[0]...fastcall_regs_t[15] contain input registers.
+ * On exit
+ * fastcall_regs_t[0]...fastcall_regs_t[N] contain r0...rN.
+ * If driver did not handle fastcall, registers must be unmodified.
+ * If driver handled fastcall registers r0...r3 may be modified.
+ * Registers beyond r3 must not be modified. Result of any
+ * modification is unpredictable.
+ * Return values
+ * Nonzero return value means that fastcall is handled.
+ */
+typedef word_t (*fcEntryHook)(
+ fastcall_registers_t *regs_t,
+ struct fcContext *context
+);
+
+
+#endif /* FASTCALL_H_ */
--- /dev/null
+/**
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+/**
+ * Definition of the machine-specific integer types
+ **/
+#ifndef __TEE_TYPE_H__
+#define __TEE_TYPE_H__
+
+/* C99 integer types */
+#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) &&(!defined(ANDROID))
+
+#include <limits.h>
+
+/* Figure out if a 64-bit integer types is available */
+#if \
+ defined(_MSC_VER) || \
+ defined(__SYMBIAN32__) || \
+ defined(_WIN32_WCE) || \
+ (defined(ULLONG_MAX) && ULLONG_MAX == 0xFFFFFFFFFFFFFFFFULL) || \
+ (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 0xFFFFFFFFFFFFFFFFULL)
+typedef unsigned long long uint64_t;
+typedef long long int64_t;
+#else
+#define __S_TYPE_INT64_UNDEFINED
+#endif
+
+#if UINT_MAX == 0xFFFFFFFF
+typedef unsigned int uint32_t;
+typedef int int32_t;
+#elif ULONG_MAX == 0xFFFFFFFF
+typedef unsigned long uint32_t;
+typedef long int32_t;
+#else
+#error This compiler is not supported.
+#endif
+
+#if USHRT_MAX == 0xFFFF
+typedef unsigned short uint16_t;
+typedef short int16_t;
+#else
+#error This compiler is not supported.
+#endif
+
+#if UCHAR_MAX == 0xFF
+typedef unsigned char uint8_t;
+typedef signed char int8_t;
+#else
+#error This compiler is not supported.
+#endif
+
+#if !defined(__cplusplus)
+typedef unsigned char bool;
+#define false ( (bool)0 )
+#define true ( (bool)1 )
+#endif
+
+#else /* !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L */
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#endif /* !(!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) */
+
+#include <stddef.h>
+
+#ifndef NULL
+# ifdef __cplusplus
+# define NULL 0
+# else
+# define NULL ((void *)0)
+# endif
+#endif
+
+#define IN
+#define OUT
+
+/*
+ * Definition of other common types
+ */
+
+// to delete when all completed
+typedef uint32_t TEE_Result;
+typedef TEE_Result TEEC_Result;
+
+typedef uint32_t TEE_HANDLE;
+
+/** Definition of an UUID (from RFC 4122 http://www.ietf.org/rfc/rfc4122.txt) */
+typedef struct TEE_UUID {
+ uint32_t timeLow;
+ uint16_t timeMid;
+ uint16_t timeHiAndVersion;
+ uint8_t clockSeqAndNode[8];
+} TEE_UUID;
+typedef TEE_UUID TEEC_UUID;
+
+/** Type definition for a TEE Identity */
+typedef struct TEE_Identity {
+ uint32_t login;
+ TEE_UUID uuid;
+} TEE_Identity;
+
+typedef struct __TEE_PropSetHandle {
+ unsigned char reserved;
+} __TEE_PropSetHandle;
+
+typedef struct __TEE_PropSetHandle* TEE_PropSetHandle;
+
+/* Property Sets Pseudo Handles */
+#define TEE_PROPSET_CURRENT_TA (TEE_PropSetHandle)0xFFFFFFFF
+#define TEE_PROPSET_CURRENT_CLIENT (TEE_PropSetHandle)0xFFFFFFFE
+#define TEE_PROPSET_TEE_IMPLEMENTATION (TEE_PropSetHandle)0xFFFFFFFD
+
+
+/* DLL Import/Export directives */
+
+#if defined(WIN32) || defined(__ARMCC_VERSION) || defined(__WINSCW__) || defined(_WIN32_WCE)
+# define S_DLL_EXPORT __declspec(dllexport)
+# define S_DLL_IMPORT __declspec(dllimport)
+# define S_NO_RETURN __declspec(noreturn)
+#elif defined(__GNUC__)
+# define S_DLL_EXPORT __attribute__ ((visibility ("default")))
+# define S_DLL_IMPORT __attribute__ ((visibility ("default")))
+# define S_NO_RETURN __attribute__ ((noreturn))
+#else
+# define S_DLL_EXPORT
+# define S_DLL_IMPORT
+# define S_NO_RETURN
+#endif
+
+#if defined(_MSC_VER)
+#define __func__ __FUNCTION__
+#endif
+
+#endif /* __TEE_TYPE_H__ */
--- /dev/null
+/**
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __TEE_UUID_ATTESTATION_H__
+#define __TEE_UUID_ATTESTATION_H__
+
+#include "tee_type.h"
+
+// Sizes of the fields of attestation structure
+#define AT_MAGIC_SIZE 8
+#define AT_SIZE_SIZE sizeof(uint32_t)
+#define AT_VERSION_SIZE sizeof(uint32_t)
+#define AT_UUID_SIZE sizeof(TEE_UUID)
+
+// Sizes of the fields used to generate signature
+#define AT_TAG_SIZE 20
+#define AT_SHA1_HASH_SIZE 20
+
+// Max size of RSA modulus supported
+#define AT_MODULUS_MAX_SIZE 256
+// Max size of RSA public exponent supported
+#define AT_PUBLIC_EXPO_MAX_SIZE 4
+
+// Attestation version
+#define AT_VERSION 1
+
+// Name space ID (the UUID of the RSA OID)
+const uint8_t RSA_OID_UUID[AT_UUID_SIZE] = {0x6b, 0x8e, 0x02, 0x6b, 0x63, 0xc1, 0x5d, 0x58, 0xb0, 0x64, 0x00, 0xd3, 0x51, 0x89, 0xce, 0x65};
+// Magic word
+const char MAGIC[AT_MAGIC_SIZE] = "TAUUID\0";
+
+// Tag for signature generation
+const char TAG[AT_TAG_SIZE]="Trusted Application";
+
+// Public key structure
+typedef struct uuid_public_key {
+ uint32_t type; // TEE TYPE RSA KEYPAIR: 0xa0000030
+ uint16_t modulus_bytes; // Length of the modulus in bytes
+ uint16_t exponent_bytes; // Length of the exponent in bytes
+ uint8_t data[]; // Key material
+} uuid_public_key;
+
+// Attestation structure
+typedef struct uuid_attestation {
+ uint8_t magic[AT_MAGIC_SIZE]; // Magic word: "TAUUID\0\0"
+ uint32_t size; // Attestation size (4 bytes)
+ uint32_t version; // Version number: 1 (4 bytes)
+ uint8_t uuid[AT_UUID_SIZE]; // UUID
+ uuid_public_key key; // Public key
+} uuid_attestation;
+
+#endif /* __TEE_UUID_ATTESTATION_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _GP_TCI_H_
+#define _GP_TCI_H_
+
+typedef struct {
+ uint32_t a;
+ uint32_t b;
+} TEE_Value;
+
+#if defined (TRUSTEDAPP)
+typedef struct {
+ void *sVirtualAddr; /**< The virtual address of the Bulk buffer regarding the address space of the Trustlet, already includes a possible offset! */
+ uint32_t sVirtualLen; /**< Length of the mapped Bulk buffer */
+} mcBulkMap_t;
+#endif
+
+typedef struct {
+ mcBulkMap_t mapInfo;
+ uint32_t outputSize;
+} _TEEC_MemoryReferenceInternal;
+
+typedef union {
+ TEE_Value value;
+ _TEEC_MemoryReferenceInternal memref;
+} _TEEC_ParameterInternal;
+
+typedef enum {
+ _TA_OPERATION_OPEN_SESSION = 1,
+ _TA_OPERATION_INVOKE_COMMAND = 2,
+ _TA_OPERATION_CLOSE_SESSION = 3,
+} _TEEC_TCI_type;
+
+typedef struct {
+ _TEEC_TCI_type type;
+ uint32_t commandId;
+ uint32_t paramTypes;
+ _TEEC_ParameterInternal params[4];
+ bool isCancelled;
+} _TEEC_OperationInternal;
+
+typedef struct {
+ char header[8];// = "TCIGP000"`: version indicator (to support future format changes)
+ TEEC_UUID destination;
+ _TEEC_OperationInternal operation; //the data of the ongoing operation (if any)
+ uint32_t ready;
+ // The following fields are set by the secure world (in a future version, they may also be set by the normal world communication layer):
+ uint32_t returnOrigin;
+ uint32_t returnStatus;
+} _TEEC_TCI;
+
+#define TEEC_MEMREF_WHOLE 0xC
+#define TEEC_MEMREF_PARTIAL_INPUT 0xD
+#define TEEC_MEMREF_PARTIAL_OUTPUT 0xE
+#define TEEC_MEMREF_PARTIAL_INOUT 0xF
+
+/**
+ * Termination codes
+ */
+#define TA_EXIT_CODE_PANIC (300)
+#define TA_EXIT_CODE_TCI (301)
+#define TA_EXIT_CODE_PARAMS (302)
+#define TA_EXIT_CODE_FINISHED (303)
+#define TA_EXIT_CODE_SESSIONSTATE (304)
+#define TA_EXIT_CODE_CREATEFAILED (305)
+
+#endif // _GP_TCI_H_
--- /dev/null
+ /*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ *
+ *
+ * @addtogroup TlApi
+ * @{
+ * @file
+ * Marshaling types and declarations.
+ *
+ * Functions for the marshaling of function ID and parameters.
+ *
+ */
+
+#ifndef __TLAPICRYPTOMARSHAL_H__
+#define __TLAPICRYPTOMARSHAL_H__
+
+
+#include "mcDriverId.h"
+
+#include "TlApi/TlApiError.h"
+#include "TlApi/TlApiCrypto.h"
+#include "TlApi/TlApiSecurity.h"
+#include "TlApi/TlApiMcSystem.h"
+#include "TlApi/TlApiTime.h"
+
+
+/** Each function must have its own ID.
+ * Extend this list if you add a new function.
+ */
+typedef enum {
+ FID_KPD_GRAB_KEYPAD = 0, /**< Function to reserve the keypad. */
+ FID_KPD_GET_C, /**< Function to read a character from the keypad. */
+ FID_KPD_GET_MULTIPLE_C, /**< Function to read multiple characters from the keypad. */
+ FID_KPD_RELEASE_KEYPAD /**< Function to release the grabbed keypad. */
+} kpdFuncID_t;
+
+
+/** Each function must have its own ID.
+ * Extend this list if you add a new function.
+ */
+typedef enum {
+ FID_CRYPTO_MD = 0, /**< ID for message digest algorithms. */
+ FID_CRYPTO_MD_INIT = 1, /**< Function to init a message digest. */
+ FID_CRYPTO_MD_INIT_WITH_DATA = 2, /**< Function to init a message digest with data. */
+ FID_CRYPTO_MD_UPDATE = 3, /**< Function to update a message digest. */
+ FID_CRYPTO_MD_DOFINAL = 4, /**< Function to finalize a message digest. */
+
+ FID_CRYPTO_SIG = 5, /**< ID for signature algorithms. */
+ FID_CRYPTO_SIG_INIT = 6, /**< Function to init a signature. */
+ FID_CRYPTO_SIG_INIT_WITH_DATA = 7, /**< Function to init a signature with data. */
+ FID_CRYPTO_SIG_UPDATE = 8, /**< Function to update a signature. */
+ FID_CRYPTO_SIG_SIGN = 9, /**< Function to make a signature. */
+ FID_CRYPTO_SIG_VERIFY = 10, /**< Function to verify a signature. */
+
+ FID_CRYPTO_RNG = 11, /**< ID for RNG algorithms. */
+ FID_CRYPTO_RNG_GENERATE_DATA = 12, /**< Function to generate random data. */
+
+ FID_CRYPTO_CIPHER = 13, /**< ID for cipher algorithms. */
+ FID_CRYPTO_CIPHER_INIT = 14, /**< Function to init a cipher. */
+ FID_CRYPTO_CIPHER_INIT_WITH_DATA = 15, /**< Function to init a cipher with data. */
+ FID_CRYPTO_CIPHER_UPDATE = 16, /**< Function to update a cipher. */
+ FID_CRYPTO_CIPHER_DOFINAL = 17, /**< Function to finalize a cipher. */
+
+ FID_CRYPTO_SESSION_ABORT = 18, /**< Function to abort a crypto session. */
+
+ FID_CRYPTO_GENERATE_KEY_PAIR = 19, /**< Function to generate a key pair. */
+ FID_CRYPTO_GENERATE_KEY_PAIR_BUFFER = 20, /**< Function to generate a key pair into a buffer. */
+
+ FID_SECURITY_WRAP_OBJECT = 21, /**< Function to wrap given data and create a secure object. */
+ FID_SECURITY_UNWRAP_OBJECT = 22, /**< Function to unwrap given secure object and create plaintext data. */
+ FID_SECURITY_GET_SUID = 23, /**< Function to acquire System on chip Unique ID. */
+ FID_SECURITY_IS_DEVICE_BOUND = 24, /**< Currently not used. */
+ FID_SECURITY_BIND_DEVICE = 25, /**< Currently not used. */
+
+ FID_SYSTEM_GET_VERSION = 26, /**< Function to get information about the underlying MobiCore version. */
+
+ FID_SECURITY_GET_TIME_STAMP = 27, /**< Function to get a secure time stamp. */
+
+ FID_SECURITY_DERIVE_KEY = 28, /**< Function to derive key. */
+
+ FID_CRYPTO_MD_DOFINAL_WITHOUT_CLOSE = 29, /**< Function to finalize a message digest without close. */
+ FID_CRYPTO_OVERWRITE_KEY = 30, /**< Function to overwrite key. */
+ FID_CRYPTO_MAC_INIT = 31, /**< Function to initialize hmac structures with key that is earlier given. */
+ FID_CRYPTO_SIG_SIGN_WITHOUT_CLOSE = 32, /**< Function to finalize a sign without close. */
+ FID_CRYPTO_SIG_VERIFY_WITHOUT_CLOSE = 33, /**< Function to finalize a verify without close. */
+ FID_CRYPTO_CIPHER_WITHOUT_CLOSE = 34, /**< Function to finalize a cipher without close. */
+ FID_SECURITY_ENDORSE = 35, /**< Function to create endorsement */
+
+ FID_CRYPTO_CIPHER_UPDATE_IV = 36, /**< Function to update cipher IV */
+
+} cryptoFuncID_t;
+
+
+/** Marshaled function parameters.
+ * structs and union of marshaling parameters via TlApi.
+ *
+ * @note The structs can NEVER be packed !
+ * @note The structs can NOT used via sizeof(..) !
+ */
+typedef struct {
+ tlApiCrSession_t sessionHandle; /* handle of session to be aborted */
+} tlApiCrAbort_t, *tlApiCrAbort_ptr;
+
+
+typedef struct {
+ tlApiKeyPair_t *keyPair; /* reference to key pair structure */
+ tlApiKeyPairType_t type; /* see enum keyPairType_t */
+ size_t len; /* requested byte length of keys */
+ uint8_t *buffer; /* reference to buffer into which generated key components are written */
+ size_t bufferLen; /* length of buffer for generated components */
+} tlApiCrGenerateKeyPair_t, *tlApiCrGenerateKeyPair_ptr;
+
+
+typedef struct {
+ tlApiCrSession_t *pSessionHandle; /* reference to generated Cipher session handle */
+ tlApiCipherAlg_t alg; /* see enum cipherMode_t */
+ tlApiCipherMode_t mode; /* TLAPI_MODE_ENCRYPT or TLAPI_MODE_DECRYPT */
+ const tlApiKey_t *key; /* key for this session */
+ const uint8_t *buffer; /* reference to algorithm specific data like initial values for CBC */
+ size_t bufferLen; /* length of buffer containing algorithm specific data */
+} tlApiCipherInit_t, *tlApiCipherInit_ptr;
+
+typedef struct {
+ tlApiCrSession_t sessionHandle; /* handle of a running Cipher session */
+ const uint8_t *srcData; /* reference to input data to be encrypted/decrypted */
+ size_t srcLen; /* byte length of input data to be encrypted/decrypted */
+ uint8_t *destData; /* reference to result area */
+ size_t *destLen; /* [in] byte length of output buffer. [out] byte length of generated output data */
+} tlApiCipherUpdate_t, *tlApiCipherUpdate_ptr;
+
+
+typedef struct {
+ tlApiCrSession_t sessionHandle; /* handle of a running Cipher session */
+ const uint8_t *srcData; /* reference to input data to be encrypted/decrypted */
+ size_t srcLen; /* byte length of input data to be encrypted/decrypted */
+ uint8_t *destData; /* reference to result area */
+ size_t *destLen; /* [in] byte length of buffer for output data. [out] byte length of generated output */
+} tlApiCipherDoFinal_t, *tlApiCipherDoFinal_ptr;
+
+
+typedef struct {
+ tlApiCrSession_t *pSessionHandle; /* reference to generated Signatures session handle */
+ const tlApiKey_t *key; /* key for this session */
+ tlApiSigMode_t mode; /* TLAPI_MODE_SIGN or TLAPI_MODE_VERIFY */
+ tlApiSigAlg_t alg; /* see enum of algorithms */
+ const uint8_t *buffer; /* reference to algorithm specific data like seed for hash */
+ size_t bufferLen; /* length of buffer containing algorithm specific data */
+} tlApiSignatureInit_t, *tlApiSignatureInit_ptr;
+
+
+typedef struct {
+ tlApiCrSession_t sessionHandle; /* handle of a running Signature session */
+ const uint8_t *message; /* reference to message to be signed/verified */
+ size_t messageLen; /* byte length of message */
+} tlApiSignatureUpdate_t, *tlApiSignatureUpdate_ptr;
+
+
+typedef struct {
+ tlApiCrSession_t sessionHandle; /* handle of a running Signature session */
+ const uint8_t *message; /* reference to message to be signed */
+ size_t messageLen; /* byte length of message */
+ uint8_t *signature; /* reference to generated signature */
+ size_t *signatureLen; /* [in] byte length of signature buffer. [out] byte length of generated signature */
+} tlApiSignatureSign_t, *tlApiSignatureSign_ptr;
+
+
+typedef struct {
+ tlApiCrSession_t sessionHandle; /* handle of a running Signature session */
+ const uint8_t *message; /* reference to message to be verified */
+ size_t messageLen; /* byte length of message */
+ const uint8_t *signature; /* reference to signature to be verified */
+ size_t signatureLen; /* byte length of signature */
+ bool *validity; /* reference to verification result, TRUE if verified, otherwise FALSE */
+} tlApiSignatureVerify_t, *tlApiSignatureVerify_ptr;
+
+typedef struct {
+ tlApiCrSession_t *pSessionHandle; /* reference to generated Message Digest session handle */
+ tlApiMdAlg_t alg; /* see enum mdAlg_t */
+ const uint8_t *buffer; /* reference to previously calculated hash data */
+ const uint8_t *lenPreHashedData; /* byte array in big endian format containing length of previously calculated hash */
+} tlApiMessageDigestInit_t, *tlApiMessageDigestInit_ptr;
+
+
+typedef struct {
+ tlApiCrSession_t sessionHandle; /* handle of a running session Message Digest session */
+ const uint8_t *message; /* reference to message to be hashed */
+ size_t messageLen; /* byte length of input data to be hashed */
+} tlApiMessageDigestUpdate_t, *tlApiMessageDigestUpdate_ptr;
+
+
+typedef struct {
+ tlApiCrSession_t sessionHandle; /* handle of a running session Message Digest session */
+ const uint8_t *message; /* reference to message to be hashed */
+ size_t messageLen; /* byte length of message */
+ uint8_t *hash; /* reference to generated hash */
+ size_t *hashLen; /* [in] byte length of hash buffer. [out] byte length of generated hash data */
+} tlApiMessageDigestDoFinal_t, *tlApiMessageDigestDoFinal_ptr;
+
+
+typedef struct {
+ tlApiRngAlg_t alg; /* see enum randomDataGenerationAlg_t */
+ uint8_t *randomBuffer; /* reference to generated random data */
+ size_t *randomLen; /* byte length of requested random data */
+} tlApiRandomGenerateData_t, *tlApiRandomGenerateData_ptr;
+
+
+typedef struct {
+ uint32_t unused; /* place holder - unused !!! */
+} tlApiGrabKeypad_t, *tlApiGrabKeypad_ptr;
+
+
+typedef struct {
+ uint32_t *c; /* pointer to the rx-character */
+ uint32_t timeout; /* time in milliseconds to wait */
+} tlApiGetKeypadEvent_t, *tlApiGetKeypadEvent_ptr;
+
+
+typedef struct {
+ uint32_t unused; /* place holder - unused !!! */
+} tlApiReleaseKeypadGrab_t, *tlApiReleaseKeypadGrab_ptr;
+
+
+typedef struct {
+ const void *src; /* Source data. */
+ size_t plainLen; /* Length of header. */
+ size_t encryptedLen; /* Length of payload to encrypt. */
+ void *dest; /* Destination buffer (secure object). */
+ size_t *destLen; /* [in] Length of the destination buffer.
+ [out] Length of output data. */
+ mcSoContext_t context; /* Context of operation. */
+ mcSoLifeTime_t lifetime; /** Secure object lifetime and flags combined. */
+ const tlApiSpTrustletId_t *consumer; /* NULL or trustlet identifier for delegated wrapping. */
+} tlApiWrapObject_t, *tlApiWrapObject_ptr;
+
+
+typedef struct {
+ void *src; /* Source data (secure object). */
+ void *dest; /* Destination buffer (unwrapped data). */
+ size_t *destLen; /* [in] Length of the destination buffer.
+ [out] Length of output data. */
+ size_t srcLen; /* [in] Length of the source buffer. */
+ uint32_t flags; /* [in] Flags for unwrap. */
+} tlApiUnwrapObject_t, *tlApiUnwrapObject_ptr;
+
+
+typedef struct {
+ mcSuid_t *suid; /**< System on chip Unique ID */
+} tlApiGetSuid_t, *tlApiGetSuid_ptr;
+
+
+typedef struct {
+ mcVersionInfo_t *mcVersionInfo; /**< Version of MobiCore */
+} tlApiGetMcVersion_t, *tlApiGetMcVersion_ptr;
+
+
+typedef struct {
+ timestamp_t *ts; /**< Returned time stamp */
+ tsSource_t source; /**< Requested timer source */
+} tlApiGetTimeStamp_t, *tlApiGetTimeStamp_ptr;
+
+
+typedef struct {
+ const void *seed; /* Source seed. */
+ size_t seedLen; /* Length of seed. */
+ void *dest; /* Destination buffer (key). */
+ size_t destLen; /* Length of the destination buffer. */
+ mcSoContext_t context; /* Context of operation. */
+ mcSoLifeTime_t lifetime; /** key lifetime. */
+} tlApiDeriveKey_t, *tlApiDeriveKey_ptr;
+
+typedef struct {
+ tlApiCrSession_t sessionHandle; /* handle of a running session Message Digest session */
+ const uint8_t *message; /* reference to message to be hashed */
+ size_t messageLen; /* byte length of message */
+ uint8_t *hash; /* reference to generated hash */
+ size_t *hashLen; /* [in] byte length of hash buffer. [out] byte length of generated hash data */
+} tlApiMessageDigestDoFinalWithOutClose_t, *tlApiMessageDigestDoFinalWithOutClose_ptr;
+
+typedef struct {
+ tlApiCrSession_t sessionHandle;
+ const tlApiKey_t *keyData;
+} tlApiOverwriteKey_t, *tlApiOverwriteKey_ptr;
+
+typedef struct {
+ tlApiCrSession_t sessionHandle;
+ uint8_t *iv;
+ size_t ivLen;
+} tlApiMacInit_t, *tlApiMacInit_ptr;
+
+typedef struct {
+ tlApiCrSession_t sessionHandle;
+ const uint8_t *iv;
+ size_t ivLen;
+} tlApiCipherUpdateIV_t, *tlApiCipherUpdateIV_ptr;
+
+#define STH_PUBLIC_FILE_NAME_SIZE 20
+typedef struct S_UUID_t {
+ uint32_t timeLow;
+ uint16_t timeMid;
+ uint16_t timeHiAndVersion;
+ uint8_t clockSeqAndNode[8];
+} UUID_t;
+
+typedef enum {
+ STH_MESSAGE_TYPE_LOOK = 0,
+ STH_MESSAGE_TYPE_READ,
+ STH_MESSAGE_TYPE_WRITE,
+ STH_MESSAGE_TYPE_DELETE
+} tlApiStorageOps_t;
+
+typedef struct {
+ uint32_t status;
+ uint8_t type;
+ uint8_t reserved0;
+ uint16_t flags;
+ uint32_t payloadLen;
+ UUID_t uuid;
+ unsigned char filename[STH_PUBLIC_FILE_NAME_SIZE];
+ unsigned char payload[];
+} STH_TA_message_t;
+
+/*typedef struct {
+ storageOps_t operation;
+ union {
+ storageLook_t look;
+ storageRead_t read;
+ storageWrite_t write;
+ storageDelete_t del;
+ }payload;
+} marshalingParam;*/ // merge to marshalingParam
+
+typedef struct {
+ const void *msg; /* Source message. */
+ size_t msgLen; /* Length of message. */
+ void *dst; /* Destination buffer (endorsement). */
+ size_t *dstLen; /* Length of the destination buffer. */
+ mcScope_t scope; /* Scope of the endorsement. */
+} tlApiEndorse_t;
+
+/** Maximum number of parameter . */
+#define MAX_MAR_LIST_LENGTH 8 /**< Maximum list of possible marshaling parameters. */
+
+/** Marshaled union. */
+typedef struct {
+ uint32_t functionId; /**< Function identifier. */
+ union {
+ tlApiCrAbort_t crAbort;
+ tlApiCrGenerateKeyPair_t crGenerateKeyPair;
+ tlApiCipherInit_t cipherInit;
+ tlApiCipherUpdate_t cipherUpdate;
+ tlApiCipherDoFinal_t cipherDoFinal;
+ tlApiSignatureInit_t signatureInit;
+ tlApiSignatureUpdate_t signatureUpdate;
+ tlApiSignatureSign_t signatureSign;
+ tlApiSignatureVerify_t signatureVerify;
+ tlApiMessageDigestInit_t messageDigestInit;
+ tlApiMessageDigestUpdate_t messageDigestUpdate;
+ tlApiMessageDigestDoFinal_t messageDigestDoFinal;
+ tlApiRandomGenerateData_t randomGenerateData;
+ tlApiGrabKeypad_t grabKeypad;
+ tlApiGetKeypadEvent_t getKeypadEvent;
+ tlApiReleaseKeypadGrab_t releaseKeypadGrab;
+ tlApiWrapObject_t wrapObject;
+ tlApiUnwrapObject_t unwrapObject;
+ tlApiGetSuid_t getSuid;
+ tlApiGetMcVersion_t getVersion;
+ tlApiGetTimeStamp_t getTimeStamp;
+ tlApiDeriveKey_t deriveKey;
+ tlApiOverwriteKey_t overwriteKey;
+ tlApiMacInit_t macInit;
+ tlApiEndorse_t endorse;
+ tlApiCipherUpdateIV_t cipherUpdateIV;
+ tlApiResult_t retVal;
+ STH_TA_message_t taMessage;
+ uint32_t parameter[MAX_MAR_LIST_LENGTH]; /* untyped parameter list (expands union to 8 entries) */
+ } payload;
+} marshalingParamCR_t, *marshalingParamCR_ptr;
+
+#endif // __TLAPICRYPTOMARSHAL_H__
+
+/** @} */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+
+#ifndef __TEE_STORAGE_H__
+#define __TEE_STORAGE_H__
+#include <mcstd.h>
+#include <mcutil.h>
+
+#include "tee_internal_api.h"
+#include "TlApi/TlApi.h"
+
+#include "TlApiCryptoMarshal.h"
+#include "TlApiImpl.h"
+
+#define MC_FLAG_FILE_MAY_EXIST ( 1 << 0 )
+#define MC_DRV_ID_STORAGE 0x0200
+
+#define TLAPI_FNC_CR_SIGN_INIT_ID 19
+#define TLAPI_FNC_CR_SIGN_UPDATE_ID 20
+#define TLAPI_FNC_CR_SIGN_SIGN_ID 21
+#define TLAPI_FNC_CR_SIGN_VERIFY_ID 22
+
+
+/* ** should be put in TlApiMarshal.h ** */
+typedef struct
+{
+ uint32_t dataLen;
+ uint32_t position;
+ unsigned char objectID[TEE_OBJECT_ID_MAX_LEN];
+ unsigned char data[0];
+}_TEE_PersistentData;
+
+
+typedef struct
+{
+ uint32_t flags;
+ uint8_t version;
+ uint8_t objectIDLen;
+ uint16_t cryptoLen;
+ _TEE_PersistentData *persistent;
+ unsigned char crypto[0];
+}TEE_FileObject;
+
+typedef struct
+{
+ uint32_t flags;
+ uint8_t version;
+ uint8_t objectIDLen;
+ uint16_t cryptoLen;
+ _TEE_PersistentData *persistent;
+}__TEE_ObjectHandle;
+
+typedef struct
+{
+ char header[5];
+ unsigned char version;
+ uint16_t cryptoLen;
+ uint32_t dataLen;
+}STH_plaintext;
+
+typedef struct {
+ uint8_t objectIDLen;
+ unsigned char reserved1[7];
+ unsigned char objectID[TEE_OBJECT_ID_MAX_LEN];
+ unsigned char data[];
+}STH_ciphertext;
+
+typedef struct {
+ char header[6];
+ unsigned char version;
+ unsigned char objectIDLen;
+ TEE_UUID uuid;
+ unsigned char objectID[TEE_OBJECT_ID_MAX_LEN];
+} STH_file_name;
+
+#define PLAIN_TEXT_HEADER ("fname")
+
+
+#endif // __TEE_STORAGE_H__
--- /dev/null
+/** @addtogroup DRIVER_TUI
+ * @{
+ * @file drApiMarshal.h
+ * Marshaling types and declarations for TUI driver and trustlet.
+ *
+ * Functions for the marshaling of function ID and parameters.
+ *
+ * <Copyright goes here>
+ */
+#ifndef __TLAPIMARSHAL_TUI_H__
+#define __TLAPIMARSHAL_TUI_H__
+
+#include "TlApi/TlApiError.h"
+#include "TlApi/TlApiTui.h"
+
+/** Invalid session id. Returned in case of an error. */
+#define DR_SID_INVALID 0xffffffff
+
+/** Each function must have its own ID.
+ * Extend this list if you add a new function.
+ */
+typedef enum {
+ FID_DR_NONE = 0,
+ FID_DR_OPEN_SESSION,
+ FID_DR_CLOSE_SESSION,
+ FID_DR_RESERVED0,
+ FID_DR_SET_IMAGE,
+ FID_DR_GET_SCREEN_INFO,
+ FID_DR_GET_TOUCH_EVENT,
+ FID_DR_RESERVED1,
+} tuiFuncID_t;
+
+/** Marshaled function parameters.
+ * structs and union of marshaling parameters via TlApi.
+ *
+ * @note The structs can NEVER be packed !
+ * @note The structs can NOT used via sizeof(..) !
+ */
+typedef struct {
+ union{
+ uint32_t *version;
+ uint32_t *securityLevel;
+ tlApiTuiImage_ptr image;
+ tlApiTuiScreenInfo_ptr screenInfo;
+ tlApiTuiTouchEvent_ptr touchEvent;
+ }content;
+ tlApiTuiCoordinates_t coordinates;
+
+} tuiMarshalingData_t, *tuiMarshalingData_ptr;
+
+/** Union of marshaling parameters. */
+/* If adding any function, add the marshaling structure here */
+typedef struct {
+ uint32_t functionId; /**< Function identifier. */
+ union {
+ tuiMarshalingData_t params;
+ tlApiResult_t retVal; /** Return value */
+ } payload;
+
+} tuiMarshalingParam_t, *tuiMarshalingParam_ptr;
+
+#endif // __TLAPIMARSHAL_TUI_H__
+
+/** @} */
--- /dev/null
+/** @addtogroup MC_RTM_START
+ * @{
+ * @file
+ *
+ * <!-- Copyright Trustonic Limited 2013 -->
+ */
+
+/** Index of flags to be checked after mcWaitNotification */
+#define MCLIB_WB_INDEX_NOTIFICATION_FLAGS (0)
+#define MCLIB_WB_NOTIFICATION_FLAG_CA_DEAD (1)
+
+/** Index of entry in which the base address of heap is stored. */
+#define MCLIB_WB_INDEX_HEAP_BASE_ADDRESS (1)
+
+/** Index of flags to be checked after mcWaitNotification */
+#define MCLIB_WB_INDEX_CONTEXT (2)
--- /dev/null
+/*
+ * mclib_size.h
+ *
+ * Created on: Oct 22, 2013
+ * Author: lukhan01
+ */
+
+#ifndef MCLIB_SIZE_H_
+#define MCLIB_SIZE_H_
+
+// Note: this file is read by .c and .sct file, no magic allowed.
+// Please modify these values manually.
+#define MCLIB_PAGES 5
+#define MCLIB_SIZE 0x00005000
+#define MCLIB_BASE 0x000FA000
+
+
+#endif /* MCLIB_SIZE_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __TPLAY_MARSHAL_H__
+#define __TPLAY_MARSHAL_H__ __FILE__
+
+#include "DrApi/DrApiCommon.h"
+#include "TlApi/TlApiError.h"
+#include "TlApi/TPlay.h"
+
+/**
+ * Driver ID
+ */
+#define TPLAY_DR_ID TB_DRV_ID_TPLAY
+
+/**
+ * Function id definitions
+ */
+#define FID_DR_OPEN_SESSION 1
+#define FID_DR_CLOSE_SESSION 2
+#define FID_DR_PROCESS_DRM_CONTENT 3
+#define FID_DR_CHECK_LINK 4
+#define FID_DR_UNKNOWN_CMD 100 /* For test purposes */
+
+/**
+ * Secure cipher request data structure.
+ * This structure helps define a buffer that contains mixed encrypted and clear data.
+ */
+typedef struct {
+ uint8_t sHandle;
+ tlApiDrmDecryptContext_t decryptCtx;
+ uint8_t *input;
+ tlApiDrmInputSegmentDescriptor_t inputDesc;
+ uint32_t processMode;
+ uint8_t *rfu;
+} tlDrmApiDrmContent_t, *tlDrmApiDrmContent_ptr;
+
+/**
+ * Link status data structure.
+ */
+typedef struct {
+ uint8_t sHandle;
+ tlApiDrmLink_t link;
+} tlDrmApiLink_t, *tlDrmApiLink_ptr;
+
+/**
+ * Union of marshaling parameters. */
+/* If adding any function, add the marshaling structure here
+ */
+typedef struct {
+ uint32_t functionId; /* Function identifier. */
+ union {
+ uint8_t *returned_sHandle;
+ uint8_t sHandle_to_close;
+ tlDrmApiDrmContent_t drmContent;
+ tlDrmApiLink_t link;
+ int32_t retVal; /* Return value */
+ } payload;
+} tplayMarshalingParam_t, *tplayMarshalingParam_ptr;
+
+
+#endif // __TPLAY_MARSHAL_H__
+
+
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * <h2>Introduction</h2>
+ * The MobiCore Control Interface (MCI) is the interface for integrating G&D MobiCore technology into the
+ * rich operating system running in the non-secure part of an ARM TrustZone enabled platform.
+ *
+ * <h2>Interface overview</h2>
+ * The Structure of the MobiCore control interface is depicted in the figure below:
+ * @image html DoxyOverviewMci500x.png "MobiCore control interface"
+ * @image latex DoxyOverviewMci500x.png "MobiCore control interface" width=12cm
+ *
+ * The MCI is composed of the following interfaces:
+ * <ul>
+ *
+ * <li><b>MobiCore control protocol (MCP) interface.</b></li><br>
+ * The MCP interface is responsible for the main communicating with the MobiCore. This involves sending commands for starting
+ * and stopping of Trustlets as well as checking their corresponding answers. MCP information is exchanged in a
+ * world shared memory buffer which needs to be initially established between NWd and SWd using the FastCall interface.<br>
+ *
+ * <li><b>Notification queue interface.</b></li><br>
+ * Notifications inform the MobiCore runtime environment that information is pending in a WSM buffer.
+ * The Trustlet Connector (TLC) and the corresponding Trustlet also utilize this buffer to
+ * notify each other about new data within the Trustlet Connector Interface (TCI). Therefore the TLC writes
+ * a notification including the session ID to the buffer. The driver informs the MobiCore
+ * about the availability of a notification with the use of a SIQ. On the secure side the Runtime Management
+ * notifies the Trustlet, according to the given session ID, about the availability of new data.
+ * The same mechanism is used vice versa for writing data back to the None-secure world.
+ *
+ * <li><b>FastCall interface.</b></li><br>
+ * The FastCall interface of the MobiCore system is used to transfer control from the Non-secure World (NWd) to the
+ * Secure World (SWd) and back. There are three mechanisms the NWd shall use to interact with the MobiCore Monitor:
+ * FastCall, N-SIQ and NQ-IRQ (Notification IRQ). FastCall and N-SIQ operations are used to hand over control
+ * to the MobiCore. Both functions make use of the SMC [ARM11] operation.
+ *
+ * </ul>
+ *
+ * You can find more information about the interfaces in the respective modules description.
+ *
+ * <h2>Version history</h2>
+ * <table class="customtab">
+ * <tr><td width="100px"><b>Date</b></td><td width="80px"><b>Version</b></td><td><b>Changes</b></td></tr>
+ * <tr><td>2009-06-25</td><td>0.1</td><td>Initial Release</td></tr>
+ * <tr><td>2009-07-01</td><td>0.2</td><td>Major rewrite</td></tr>
+ * <tr><td>2009-08-06</td><td>0.3</td><td>Added documentation for FastCall helper functions</td></tr>
+ * <tr><td>2009-09-10</td><td>0.4</td><td>Update of constant naming. Modification of doxygen config.</td></tr>
+ * <tr><td>2010-03-09</td><td>0.5</td><td>Added fastCallPower() helper function for MC_FC_POWER.</td></tr>
+ * <tr><td>2010-05-10</td><td>0.6</td><td>Restructuring of load format header.</td></tr>
+ * <tr><td>2011-07-19</td><td>0.7</td><td>update to reflect current code changes.</td></tr>
+ * </table>
+ *
+ *
+ * @file
+ * @defgroup FCI FastCall Interface
+ *
+ * @defgroup NQ Notification Queue
+ *
+ * @defgroup MCP MobiCore Control Protocol
+ *
+ */
+#ifndef MCI_H_
+#define MCI_H_
+
+#include "version.h"
+#include "mcifc.h"
+#include "mcinq.h"
+#include "mcimcp.h"
+
+#endif /** MCI_H_ */
+
+/** @} */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * @addtogroup FCI
+ * @{
+ * @file
+ * FastCall declarations.
+ *
+ * Holds the functions for SIQ, YIELD and FastCall for switching to the secure world.
+ *
+
+ */
+#ifndef MCIFC_H_
+#define MCIFC_H_
+
+/** @name MobiCore FastCall Defines
+ * Defines for the two different FastCall's.
+ */
+/** @{ */
+
+// --- global ----
+#define MC_FC_INVALID ((uint32_t) 0 ) /**< Invalid FastCall ID */
+#define MC_FC_INIT ((uint32_t)(-1)) /**< Initializing FastCall. */
+#define MC_FC_INFO ((uint32_t)(-2)) /**< Info FastCall. */
+
+// following defines are currently frozen, so they will candidate for later big-change
+// --- sleep modes ---
+#define MC_FC_SLEEP ((uint32_t)(-3)) /**< enter power-sleep */
+#define MC_FC_AFTR ((uint32_t)(-5)) /**< enter AFTR-sleep (called from core-0) */
+// --- wake-up access ---
+#define MC_FC_CORE_X_WAKEUP ((uint32_t)(-4)) /**< wakeup/boot core-x (optional core-number in r1, not "0" ) */
+#define MC_FC_C15_RESUME ((uint32_t)(-11)) /**< Write power control & diag registers */
+#define MC_FC_CMD_SAVE ((uint32_t)(-6)) /**< Save core context to CP15 table(r1 is core number) */
+#define MC_FC_CMD_SHUTDOWN ((uint32_t)(-7)) /**< Shutdown core(r1 is core number, cache flush is expected) */
+// --- L2 cache access ---
+#define MC_FC_L2X0_CTRL ((uint32_t)(-21)) /**< Write to L2X0 control register */
+#define MC_FC_L2X0_SETUP1 ((uint32_t)(-22)) /**< Setup L2X0 register - part 1 */
+#define MC_FC_L2X0_SETUP2 ((uint32_t)(-23)) /**< Setup L2X0 register - part 2 */
+#define MC_FC_L2X0_INVALL ((uint32_t)(-24)) /**< Invalidate all L2 cache */
+#define MC_FC_L2X0_DEBUG ((uint32_t)(-25)) /**< Write L2X0 debug register */
+#define MC_FC_SW_RESET ((uint32_t)(-26)) /**< SW Reset if DDR has leftover content */
+// --- MEM traces ---
+#define MC_FC_MEM_TRACE ((uint32_t)(-31)) /**< Enable SWd tracing via memory */
+// --- system settings ---
+
+#define MC_FC_STAT_COUNTER ((uint32_t)(-41)) /**< Require status counter */
+#define MC_FC_CP15_REG ((uint32_t)(-101)) /**< general CP15/cache register update */
+// --- store value in sDDRRAM ---
+#define MC_FC_STORE_BINFO ((uint32_t)(-201)) /**< write a 32bit value in secure DDRRAM in incremented art (max 2kB) */
+#define MC_FC_LOAD_BINFO ((uint32_t)(-202)) /**< load a 32bit value from secure DDRRAM using an offset */
+
+// Broadcom Specific Fastcalls
+#define MC_FC_BCM_VC_CORE_START ((uint32_t)(-301)) /**< Set the VC Core start address*/
+#define MC_FC_MAX_ID ((uint32_t)(0xFFFF0000)) /**< Maximum allowed FastCall ID */
+
+#define MC_FC_SWAP_CPU ((uint32_t)(0x84000005)) /**< Change new active Core */
+// r1 is requested status (0,1,2), on return r2 holds this status value
+
+/** @} */
+
+/** @name MobiCore SMC Defines
+ * Defines the different secure monitor calls (SMC) for world switching.
+ * @{ */
+#define MC_SMC_N_YIELD 0x3 /**< Yield to switch from NWd to SWd. */
+#define MC_SMC_N_SIQ 0x4 /**< SIQ to switch from NWd to SWd. */
+/** @} */
+
+/** @name MobiCore status
+ * MobiCore status information.
+ * @{ */
+#define MC_STATUS_NOT_INITIALIZED 0 /**< MobiCore is not yet initialized. FastCall FcInit() has to be used function to set up MobiCore.*/
+#define MC_STATUS_BAD_INIT 1 /**< Bad parameters have been passed in FcInit(). */
+#define MC_STATUS_INITIALIZED 2 /**< MobiCore did initialize properly. */
+#define MC_STATUS_HALT 3 /**< MobiCore kernel halted due to an unrecoverable exception. Further information is available extended info */
+/** @} */
+
+/** @name Extended Info Identifiers
+ * Extended info parameters for MC_FC_INFO to obtain further information depending on MobiCore state.
+ * @{ */
+#define MC_EXT_INFO_ID_MCI_VERSION 0 /**< Version of the MobiCore Control Interface (MCI) */
+#define MC_EXT_INFO_ID_FLAGS 1 /**< MobiCore control flags */
+#define MC_EXT_INFO_ID_HALT_CODE 2 /**< MobiCore halt condition code */
+#define MC_EXT_INFO_ID_HALT_IP 3 /**< MobiCore halt condition instruction pointer */
+#define MC_EXT_INFO_ID_FAULT_CNT 4 /**< MobiCore fault counter */
+#define MC_EXT_INFO_ID_FAULT_CAUSE 5 /**< MobiCore last fault cause */
+#define MC_EXT_INFO_ID_FAULT_META 6 /**< MobiCore last fault meta */
+#define MC_EXT_INFO_ID_FAULT_THREAD 7 /**< MobiCore last fault threadid */
+#define MC_EXT_INFO_ID_FAULT_IP 8 /**< MobiCore last fault instruction pointer */
+#define MC_EXT_INFO_ID_FAULT_SP 9 /**< MobiCore last fault stack pointer */
+#define MC_EXT_INFO_ID_FAULT_ARCH_DFSR 10 /**< MobiCore last fault ARM arch information */
+#define MC_EXT_INFO_ID_FAULT_ARCH_ADFSR 11 /**< MobiCore last fault ARM arch information */
+#define MC_EXT_INFO_ID_FAULT_ARCH_DFAR 12 /**< MobiCore last fault ARM arch information */
+#define MC_EXT_INFO_ID_FAULT_ARCH_IFSR 13 /**< MobiCore last fault ARM arch information */
+#define MC_EXT_INFO_ID_FAULT_ARCH_AIFSR 14 /**< MobiCore last fault ARM arch information */
+#define MC_EXT_INFO_ID_FAULT_ARCH_IFAR 15 /**< MobiCore last fault ARM arch information */
+#define MC_EXT_INFO_ID_MC_CONFIGURED 16 /**< MobiCore configured by Daemon via fc_init flag */
+#define MC_EXT_INFO_ID_MC_SCHED_STATUS 17 /**< MobiCore scheduling status: idle/non-idle */
+#define MC_EXT_INFO_ID_MC_STATUS 18 /**< MobiCore runtime status: initialized, halted */
+#define MC_EXT_INFO_ID_MC_EXC_PARTNER 19 /**< MobiCore exception handler last partner */
+#define MC_EXT_INFO_ID_MC_EXC_IPCPEER 20 /**< MobiCore exception handler last peer */
+#define MC_EXT_INFO_ID_MC_EXC_IPCMSG 21 /**< MobiCore exception handler last IPC message */
+#define MC_EXT_INFO_ID_MC_EXC_IPCDATA 22 /**< MobiCore exception handler last IPC data */
+
+/** @} */
+
+/** @name FastCall return values
+ * Return values of the MobiCore FastCalls.
+ * @{ */
+#define MC_FC_RET_OK 0 /**< No error. Everything worked fine. */
+#define MC_FC_RET_ERR_INVALID 1 /**< FastCall was not successful. */
+#define MC_FC_RET_ERR_ALREADY_INITIALIZED 5 /**< MobiCore has already been initialized. */
+/** @} */
+
+#endif /** MCIFC_H_ */
+
+/** @} */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * @addtogroup FCI
+ * @{
+ * @file
+ * Declaration of FastCall helper functions.
+ *
+ * @attention Helper functions are mostly RealView (ARM CC) specific.
+ *
+ * Holds the functions for SIQ, YIELD and FastCall for switching to the secure world.
+ * <!-- Copyright © Trustonic Limited 2013 -->
+ *
+ */
+
+#ifndef MCIFCFUNC_H_
+#define MCIFCFUNC_H_
+
+#include "mcifc.h"
+/**
+ * Execute a secure monitor call (SMC).
+ *
+ * @param mode SMC mode affects the way SMC is handled
+ *
+ * @attention This function shall not be used directly. Use N_Siq() or Yield() instead.
+ */
+__smc(0) void smc(int32_t mode);
+
+/**
+ * N-SIQ switch from NWd to SWd.
+ * Execution will continue in the SWd. The notification queue will be drained by the MC4 and MC4 system schedules its services.
+ */
+inline void N_Siq(void) { smc(MC_SMC_N_SIQ); }
+
+/**
+ * Yield switch from NWd to SWd.
+ * Execution will continue in the SWd without scheduling MC4 services.
+ */
+inline void Yield(void) { smc(MC_SMC_N_YIELD); }
+
+/** Wrapper structure for parameter passing in registers.
+ * This structure is used as a "wrapper" return value for functions that
+ * return data in the registers r0 to r3. With the RealView compiler such
+ * function are declare as: _value_in_regs reg_r0_r1_r2_r3_t foo()
+
+ */
+typedef struct {
+ uint32_t r0;
+ uint32_t r1;
+ uint32_t r2;
+ uint32_t r3;
+} reg_r0_r1_r2_r3_t;
+
+/** Parameterized SMC for FastCalls.
+ * @attention This function shall not be used directly.
+ */
+__smc(0) __value_in_regs reg_r0_r1_r2_r3_t smcFc(
+ uint32_t r0,
+ uint32_t r1,
+ uint32_t r2,
+ uint32_t r3
+);
+
+/** FastCall helper function.
+ * @attention This function shall not be used directly.
+ */
+inline static __value_in_regs reg_r0_r1_r2_r3_t fastCall(
+ uint32_t r0,
+ uint32_t r1,
+ uint32_t r2,
+ uint32_t r3
+) {
+ return smcFc(r0,r1,r2,r3);
+}
+
+/**
+ * Initialize the MobiCore.
+ * The FcMc4init FastCall shall be used to set up the MCI. The function passes the message buffers used in the MCI to the MC4 system.
+ * As long as the buffers are not set up the MC4 message passing mechanisms (notifications, MCP commands) are not available.
+ * NQ buffer and MCP buffer as well as length calculations are described in the "MobiCore4 Driver Interface Specification".
+ * <br> The fastCallInit() will not check the parameters for validity. Instead the MC4 will perform a check on first usage of the parameters.
+ *
+ * @image html DoxyMciBuffer.png "MCI buffer"
+ * @image latex DoxyMciBuffer.png "MCI buffer" width=12cm
+ *
+ * @param base Physical start address of the MCI buffer. Must be 4kB aligned.
+ * @param nqOffset Offset in bytes to the beginning of the NQ buffer.
+ * @param nqLength Length of the NQ buffer in bytes.
+ * @param mcpOffset Offset in bytes to the beginning of the MCP buffer.
+ * @param mcpLength Length of the MCP buffer in bytes
+ *
+ */
+inline static uint32_t fastCallInit(
+ uint8_t *base,
+ uint32_t nqOffset,
+ uint32_t nqLength,
+ uint32_t mcpOffset,
+ uint32_t mcpLength
+) {
+
+ reg_r0_r1_r2_r3_t ret;
+
+ ret = fastCall(
+ MC_FC_INIT,
+ (uint32_t)base,
+ ((nqOffset << 16) | (nqLength & 0xFFFF)),
+ ((mcpOffset << 16) | (mcpLength & 0xFFFF)) );
+
+
+ return ret.r1;
+}
+
+
+/** Get status information about MobiCore.
+ * The FcMcGetInfo FastCall provides information about the current state of the MobiCore.
+ * In certain states extended information is provided.
+ *
+ * @param extInfoId Extended info word to be obtained.
+ * @param mc4state Current state of the MobiCore.
+ * @param extInfo Extended information depending on state.
+ */
+inline static uint32_t fastCallGetInfo(
+ uint32_t extInfoId,
+ uint32_t *mc4state,
+ uint32_t *extInfo
+) {
+ reg_r0_r1_r2_r3_t ret;
+
+ ret = fastCall(MC_FC_INFO,extInfoId,0,0);
+
+ if (MC_FC_RET_OK == ret.r1)
+ {
+ *mc4state = ret.r2;
+ *extInfo = ret.r3;
+ }
+
+ return ret.r1;
+}
+
+/**
+ * Power management.
+ * The power management FastCall is platform specific.
+ *
+ * @param param0 platform specific parameter.
+ * @param param1 platform specific parameter.
+ * @param param2 platform specific parameter.
+ */
+inline static uint32_t fastCallPower(
+ uint32_t param0,
+ uint32_t param1,
+ uint32_t param2
+) {
+
+ reg_r0_r1_r2_r3_t ret;
+
+ ret = fastCall(
+ MC_FC_POWER,
+ param0,
+ param1,
+ param2 );
+
+ return ret.r1;
+}
+
+#endif /* MCIFCFUNC_H_ */
+/**
+ * @}*/
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * @addtogroup MCP
+ * @{
+ * The MCP defines commands and responses which are used to control the MobiCore system.
+ * MCP information is exchanged in a world share memory buffer which has been established prior between NWd
+ * and SWd using the FastCall interface. The buffer needs to be provided by the MobiCore driver and is utilized
+ * to send MCP commands to the MobiCore as well as receiving responses from the MobiCore.
+ * The command of the normal world will be overwritten with the response from the secure side.
+ *
+ * @file
+ * MCP command interface definitions.
+ *
+ */
+
+#ifndef MCP_H_
+#define MCP_H_
+
+
+#include "mcUuid.h"
+#include "mcLoadFormat.h"
+#include "mcVersionInfo.h"
+
+
+/** MobiCore Return Code Defines.
+ * List of the possible MobiCore return codes.
+ */
+typedef enum {
+ MC_MCP_RET_OK = 0, /**< Memory has successfully been mapped. */
+ MC_MCP_RET_ERR_INVALID_SESSION = 1, /**< The session ID is invalid. */
+ MC_MCP_RET_ERR_UNKNOWN_UUID = 2, /**< The UUID of the Trustlet is unknown. */
+ MC_MCP_RET_ERR_UNKNOWN_DRIVER_ID = 3, /**< The ID of the driver is unknown. */
+ MC_MCP_RET_ERR_NO_MORE_SESSIONS = 4, /**< No more session are allowed. */
+ MC_MCP_RET_ERR_CONTAINER_INVALID = 5, /**< The container is invalid. */
+ MC_MCP_RET_ERR_TRUSTLET_INVALID = 6, /**< The Trustlet is invalid. */
+ MC_MCP_RET_ERR_ALREADY_MAPPED = 7, /**< The memory block has already been mapped before. */
+ MC_MCP_RET_ERR_INVALID_PARAM = 8, /**< Alignment or length error in the command parameters. */
+ MC_MCP_RET_ERR_OUT_OF_RESOURCES = 9, /**< No space left in the virtual address space of the session. */
+ MC_MCP_RET_ERR_INVALID_WSM = 10, /**< WSM type unknown or broken WSM */
+ MC_MCP_RET_ERR_UNKNOWN = 11, /**< unknown error. */
+ MC_MCP_RET_ERR_INVALID_MAPPING_LENGTH = 12, /**< Lenght of map invalid */
+ MC_MCP_RET_ERR_MAPPING_TARGET = 13, /**< Map can only be applied to Trustlet session */
+ MC_MCP_RET_ERR_OUT_OF_CRYPTO_RESSOURCES = 14, /**< Couldn't open crypto session. */
+ MC_MCP_RET_ERR_SIGNATURE_VERIFICATION_FAILED = 15, /**< System Trustlet signature verification failed. */
+ MC_MCP_RET_ERR_WRONG_PUBLIC_KEY = 16, /**< System Trustlet public key is wrong. */
+ MC_MCP_RET_ERR_CONTAINER_TYPE_MISMATCH = 17, /**< Wrong containter type(s). */
+ MC_MCP_RET_ERR_CONTAINER_LOCKED = 18, /**< Container is locked (or not activated). */
+ MC_MCP_RET_ERR_SP_NO_CHILD = 19, /**< SPID is not registered with root container. */
+ MC_MCP_RET_ERR_TL_NO_CHILD = 20, /**< UUID is not registered with sp container. */
+ MC_MCP_RET_ERR_UNWRAP_ROOT_FAILED = 21, /**< Unwrapping of root container failed. */
+ MC_MCP_RET_ERR_UNWRAP_SP_FAILED = 22, /**< Unwrapping of service provider container failed. */
+ MC_MCP_RET_ERR_UNWRAP_TRUSTLET_FAILED = 23, /**< Unwrapping of Trustlet container failed. */
+ MC_MCP_RET_ERR_CONTAINER_VERSION_MISMATCH = 24, /**< Container version mismatch. */
+ MC_MCP_RET_ERR_SP_TL_DECRYPTION_FAILED = 25, /**< Decryption of service provider trustlet failed. */
+ MC_MCP_RET_ERR_SP_TL_HASH_CHECK_FAILED = 26, /**< Hash check of service provider trustlet failed. */
+ MC_MCP_RET_ERR_LAUNCH_TASK_FAILED = 27, /**< Activation/starting of task failed. */
+ MC_MCP_RET_ERR_CLOSE_TASK_FAILED = 28, /**< Closing of task not yet possible, try again later. */
+
+ // used for command verification
+ MC_MCP_RET_ERR_UNKNOWN_COMMAND = 50, /**< The command is unknown. */
+ MC_MCP_RET_ERR_INVALID_DATA = 51 /**< The command data is invalid. */
+} mcpResult_t;
+
+/** Possible MCP Command IDs
+ * Command ID must be between 0 and 0x7FFFFFFF.
+ */
+typedef enum {
+ MC_MCP_CMD_ID_INVALID = 0x00000000, /**< Invalid command ID. */
+ // Session commands
+ MC_MCP_CMD_OPEN_SESSION = 0x00000001, /**< Open a session to a service. */
+ MC_MCP_CMD_CLOSE_SESSION = 0x00000003, /**< Close an existing service session. */
+ MC_MCP_CMD_MAP = 0x00000004, /**< Map a block of WSM to a session. */
+ MC_MCP_CMD_UNMAP = 0x00000005, /**< Unmap a block of WSM from a session. */
+ MC_MCP_CMD_SUSPEND = 0x00000006, /**< Prepare MobiCore for suspend. */
+ MC_MCP_CMD_RESUME = 0x00000007, /**< Resume MobiCore from suspension. */
+ // obsolete: MC_MCP_CMD_DONATE_RAM = 0x00000008,
+ MC_MCP_CMD_GET_MOBICORE_VERSION = 0x00000009, /**< Get MobiCore version information. */
+ MC_MCP_CMD_CLOSE_MCP = 0x0000000A, /**< Close MCP and unmap MCI. */
+ MC_MCP_CMD_LOAD_TOKEN = 0x0000000B, /**< Load token for device attestation */
+ MC_MCP_CMD_CHECK_LOAD_TA = 0x0000000C, /**< Check that TA can be loaded */
+} mcpCmdId_t;
+
+
+#define FLAG_RESPONSE (1U << 31) /**< Flag to indicate that this is the response to a MCP command. */
+
+
+/** Types of WSM known to the MobiCore.
+ */
+typedef uint32_t wsmType_t;
+
+#define WSM_TYPE_MASK 0xFF
+#define WSM_INVALID 0 /**< Invalid memory type */
+#define WSM_CONTIGUOUS 1 /**< Reference to WSM points to a contiguous region of pages. */
+#define WSM_L2 2 /**< Reference to WSM points to an L2 table describing the memory region to share */
+#define WSM_WSM_UNCACHED 0x100 /**< Bitflag indicating that WSM should be uncached */
+#define WSM_L2_UNCACHED 0x100 /**< Bitflag indicating that L2 table should be uncached */
+
+
+/** Command header.
+ * It just contains the command ID. Only values specified in mcpCmdId_t are allowed as command IDs.
+ * If the command ID is unspecified the MobiCore returns an empty response with the result set to MC_MCP_RET_ERR_UNKNOWN_COMMAND .
+ */
+typedef struct {
+ mcpCmdId_t cmdId; /**< Command ID of the command */
+} commandHeader_t, *commandHeader_ptr;
+
+/** Response header.
+ * MobiCore will reply to every MCP command with an MCP response. Like the MCP command the response consists of a
+ * header followed by response data. The response is written to the same memory location as the MCP command.
+ */
+typedef struct {
+ uint32_t rspId; /**< Command ID | FLAG_RESPONSE. */
+ mcpResult_t result; /**< Result informs about the execution result of the command associated with the response. */
+} responseHeader_t, *responseHeader_ptr;
+
+
+
+/** @defgroup CMD MCP Commands
+ * @{ */
+
+/** @defgroup ASMCMD Administrative Commands
+ * @{ */
+
+/** @defgroup MCPGETMOBICOREVERSION GET_MOBICORE_VERSION
+ * Get MobiCore version info.
+ *
+ * @{ */
+
+/** Get MobiCore Version Command. */
+typedef struct {
+ commandHeader_t cmdHeader; /** Command header. */
+} mcpCmdGetMobiCoreVersion_t, *mcpCmdGetMobiCoreVersion_ptr;
+
+/** Get MobiCore Version Command Response. */
+typedef struct {
+ responseHeader_t rspHeader; /** Response header. */
+ mcVersionInfo_t versionInfo; /** MobiCore version info. */
+} mcpRspGetMobiCoreVersion_t, *mcpRspGetMobiCoreVersion_ptr;
+
+/** @} */// End MCPGETMOBICOREVERSION
+
+/** @} */// End ASMCMD
+
+
+/** @defgroup POWERCMD Power Management Commands
+ * @{ */
+
+/** @defgroup MCPSUSPEND SUSPEND
+ * Prepare MobiCore suspension.
+ * This command allows MobiCore and MobiCore drivers to release or clean resources and save device state.
+ *
+ * @{ */
+
+/** Suspend Command */
+typedef struct {
+ commandHeader_t cmdHeader; /**< Command header. */
+} mcpCmdSuspend_t, *mcpCmdSuspend_ptr;
+
+/** Suspend Command Response */
+typedef struct {
+ responseHeader_t rspHeader; /**< Response header. */
+} mcpRspSuspend_t, *mcpRspSuspend_ptr;
+/** @} */// End MCPSUSPEND
+
+
+/** @defgroup MCPRESUME RESUME
+ * Resume MobiCore from suspension.
+ * This command allows MobiCore and MobiCore drivers to reinitialize hardware affected by suspension.
+ *
+ * @{ */
+
+/** Resume Command */
+typedef struct {
+ commandHeader_t cmdHeader; /**< Command header. */
+} mcpCmdResume_t, *mcpCmdResume_ptr;
+
+/** Resume Command Response */
+typedef struct {
+ responseHeader_t rspHeader; /**< Response header. */
+} mcpRspResume_t, *mcpRspResume_ptr;
+
+/** @} */// End MCPRESUME
+
+/** @} */// End POWERCMD
+
+
+
+/** @defgroup SESSCMD Session Management Commands
+ * @{ */
+
+/** @defgroup MCPOPEN OPEN
+ * Load and open a session to a Trustlet.
+ * The OPEN command loads Trustlet data to the MobiCore context and opens a session to the Trustlet.
+ * If wsmTypeLoadData is WSM_INVALID MobiCore tries to start a pre-installed Trustlet
+ * associated with the uuid passed.
+ * The uuid passed must match the uuid contained in the load data (if available).
+ * On success, MobiCore returns the session ID which can be used for further communication.
+ * @{ */
+
+/** Open Command */
+typedef struct {
+ commandHeader_t cmdHeader; /**< Command header. */
+ mcUuid_t uuid; /**< Byte array containing the service UUID. */
+ uint64_t adrTciBuffer; /**< Physical address of the TCI */
+ uint64_t adrLoadData; /**< Physical address of the data to load. */
+ uint32_t ofsTciBuffer; /**< Offset to the data. */
+ uint32_t lenTciBuffer; /**< Length of the TCI. */
+ wsmType_t wsmTypeTci; /**< Type of WSM used for the TCI */
+ wsmType_t wsmTypeLoadData; /**< Type of the memory containing the data to load. */
+ uint32_t ofsLoadData; /**< Offset to the data. */
+ uint32_t lenLoadData; /**< Length of the data to load. */
+ mclfHeader_t tlHeader; /**< Service header. */
+} mcpCmdOpen_t, *mcpCmdOpen_ptr;
+
+/** Open Command Response */
+typedef struct {
+ responseHeader_t rspHeader; /**< Response header. */
+ uint32_t sessionId; /**< Session ID used for further communication. */
+} mcpRspOpen_t, *mcpRspOpen_ptr;
+
+/** TA Load Check Command */
+typedef struct {
+ commandHeader_t cmdHeader; /**< Command header. */
+ mcUuid_t uuid; /**< Byte array containing the service UUID. */
+ uint64_t adrLoadData; /**< Physical address of the data to load. */
+ wsmType_t wsmTypeLoadData; /**< Type of the memory containing the data to load. */
+ uint32_t ofsLoadData; /**< Offset to the data. */
+ uint32_t lenLoadData; /**< Length of the data to load. */
+ mclfHeader_t tlHeader; /**< Service header. */
+} mcpCmdCheckLoad_t, *mcpCmdCheckLoad_ptr;
+
+/** TA Load Check Response */
+typedef struct {
+ responseHeader_t rspHeader; /**< Response header. */
+} mcpRspCheckLoad_t, *mcpRspCheckLoad_ptr;
+
+
+/** @} */// End MCPOPEN
+
+
+/** @defgroup MCPCLOSE CLOSE
+ * Close an existing session to a Trustlet.
+ * The CLOSE command terminates a session and frees all resources in the MobiCore system which
+ * are currently occupied by the session. Before closing the session, the MobiCore runtime
+ * management waits until all pending operations, like calls to drivers, invoked by the Trustlet
+ * have been terminated.
+ * Mapped memory will automatically be unmapped from the MobiCore context. The NWd is responsible for
+ * processing the freed memory according to the Rich-OS needs.
+ *
+ * @{ */
+
+/** Close Command */
+typedef struct {
+ commandHeader_t cmdHeader; /**< Command header. */
+ uint32_t sessionId; /**< Session ID. */
+} mcpCmdClose_t, *mcpCmdClose_ptr;
+
+/** Close Command Response */
+typedef struct {
+ responseHeader_t rspHeader; /**< Response header. */
+} mcpRspClose_t, *mcpRspClose_ptr;
+
+/** @} */// End MCPCLOSE
+
+
+/** @defgroup MCPMAP MAP
+ * Map a portion of memory to a session.
+ * The MAP command provides a block of memory to the context of a service.
+ * The memory then becomes world-shared memory (WSM).
+ * The WSM can either be normal anonymous memory from malloc() or be a
+ * block of page aligned, contiguous memory.
+ * The only allowed memory type here is WSM_L2.
+ * @{ */
+
+/** Map Command */
+typedef struct {
+ commandHeader_t cmdHeader; /**< Command header. */
+ uint32_t sessionId; /**< Session ID of a valid session */
+ wsmType_t wsmType; /**< Type of WSM used of the memory*/
+ uint32_t ofsBuffer; /**< Offset to the payload. */
+ uint64_t adrBuffer; /**< Physical address of the memory */
+ uint32_t lenBuffer; /**< Length of the buffer. */
+} mcpCmdMap_t, *mcpCmdMap_ptr;
+
+#define MCP_MAP_MAX 0x100000 /**< Maximum allowed length for MCP map. */
+
+/** Map Command Response */
+typedef struct {
+ responseHeader_t rspHeader; /**< Response header. */
+ uint32_t secureVirtualAdr; /**< Virtual address in the context of the service the WSM is mapped to, already includes a possible offset! */
+} mcpRspMap_t, *mcpRspMap_ptr;
+
+/** @} *///End MCPMAP
+
+
+/** @defgroup MCPUNMAP UNMAP
+ * Unmap a portion of world-shared memory from a session.
+ * The UNMAP command is used to unmap a previously mapped block of
+ * world shared memory from the context of a session.
+ *
+ * Attention: The memory block will be immediately unmapped from the specified session.
+ * If the service is still accessing the memory, the service will trigger a segmentation fault.
+ * @{ */
+
+/** Unmap Command */
+typedef struct {
+ commandHeader_t cmdHeader; /**< Command header. */
+ uint32_t sessionId; /**< Session ID of a valid session */
+ wsmType_t wsmType; /**< Type of WSM used of the memory*/
+ uint32_t secureVirtualAdr; /**< Virtual address in the context of the service the WSM has been mapped to, already includes a possible offset! */
+ uint32_t lenVirtualBuffer; /**< Length of the virtual buffer. */
+} mcpCmdUnmap_t, *mcpCmdUnmap_ptr;
+
+/** Unmap Command Response */
+typedef struct {
+ responseHeader_t rspHeader; /**< Response header. */
+} mcpRspUnmap_t, *mcpRspUnmap_ptr;
+
+/** @} */// End MCPUNMAP
+
+/** @} */// End SESSCMD
+
+/** @defgroup MCPLOADTOKEN
+ * Load a token from the normal world and share it with <t-base
+ * If something fails, the device attestation functionality will be disabled
+ * @{ */
+
+/** Load Token */
+typedef struct {
+ commandHeader_t cmdHeader; /**< Command header. */
+ wsmType_t wsmTypeLoadData; /**< Type of the memory containing the data to load. */
+ uint64_t adrLoadData; /**< Physical address of the data to load. */
+ uint64_t ofsLoadData; /**< Offset to the data to load. */
+ uint64_t lenLoadData; /**< Length of the data to load. */
+} mcpCmdLoadToken_t, *mcpCmdLoadToken_ptr;
+
+/** Load Token Command Response */
+typedef struct {
+ responseHeader_t rspHeader; /**< Response header. */
+} mcpRspLoadToken_t, *mcpRspLoadToken_ptr;
+
+/** @} *///End MCPLOADTOKEN
+
+/** @} */// End CMD
+
+/** Structure of the MCP buffer. */
+typedef union {
+ commandHeader_t cmdHeader; /**< Command header. */
+ responseHeader_t rspHeader; /**< Response header. */
+ mcpCmdOpen_t cmdOpen; /**< Load and open service. */
+ mcpRspOpen_t rspOpen; /**< Response to load and open service. */
+ mcpCmdClose_t cmdClose; /**< Close command. */
+ mcpRspClose_t rspClose; /**< Response to close command. */
+ mcpCmdMap_t cmdMap; /**< Map WSM to service context. */
+ mcpRspMap_t rspMap; /**< Response to MAP command. */
+ mcpCmdUnmap_t cmdUnmap; /**< Unmap WSM from service context. */
+ mcpRspUnmap_t rspUnmap; /**< Response to UNMAP command. */
+ mcpCmdSuspend_t cmdSuspend; /**< Suspend MobiCore. */
+ mcpRspSuspend_t rspSuspend; /**< Response to SUSPEND command. */
+ mcpCmdResume_t cmdResume; /**< Resume MobiCore. */
+ mcpRspResume_t rspResume; /**< Response to RESUME command. */
+ mcpCmdGetMobiCoreVersion_t cmdGetMobiCoreVersion; /**< Get MobiCore Version command. */
+ mcpRspGetMobiCoreVersion_t rspGetMobiCoreVersion; /**< Response to GET_MOBICORE_VERSION command. */
+ mcpCmdLoadToken_t cmdLoadToken;
+ mcpRspLoadToken_t rspLoadToken;
+ mcpCmdCheckLoad_t cmdCheckLoad; /**< TA load check command. */
+ mcpRspCheckLoad_t rspCheckLoad; /**< Response to TA load check. */
+
+} mcpMessage_t, *mcpMessage_ptr;
+
+
+#define MIN_MCP_LEN sizeof(mcpMessage_t) /**< Minimum MCP buffer length (in bytes). */
+
+#define MC_FLAG_NO_SLEEP_REQ 0
+#define MC_FLAG_REQ_TO_SLEEP 1
+
+#define MC_STATE_NORMAL_EXECUTION 0
+#define MC_STATE_READY_TO_SLEEP 1
+
+typedef struct {
+ uint16_t SleepReq;
+ uint16_t ReadyToSleep;
+} mcSleepMod_t, *mcSleepMod_ptr;
+
+/** MobiCore status flags */
+typedef struct {
+ uint32_t schedule; /**< Scheduling hint: if <> MC_FLAG_SCHEDULE_IDLE, MobiCore should be scheduled by the NWd */
+ mcSleepMod_t sleepMode; /**< */
+ uint32_t RFU2; /**< Reserved for future use: Must not be interpreted */
+ uint32_t RFU3; /**< Reserved for future use: Must not be interpreted */
+} mcFlags_t, *mcFlags_ptr;
+
+#define MC_FLAG_SCHEDULE_IDLE 0 /**< MobiCore is idle. No scheduling required. */
+#define MC_FLAG_SCHEDULE_NON_IDLE 1 /**< MobiCore is non idle, scheduling is required. */
+
+
+
+/** MCP buffer structure */
+typedef struct {
+ mcFlags_t mcFlags; /**< MobiCore Flags */
+ mcpMessage_t mcpMessage; /**< MCP message buffer */
+} mcpBuffer_t, *mcpBuffer_ptr;
+
+/** @} */
+#endif /* MCP_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * @addtogroup NQ
+ * @{
+ * Notifications inform the MobiCore runtime environment that information is pending in a WSM buffer.
+ * The Trustlet Connector (TLC) and the corresponding trustlet also utilize this buffer to notify
+ * each other about new data within the Trustlet Connector Interface (TCI).
+ *
+ * The buffer is set up as a queue, which means that more than one notification can be written to the buffer
+ * before the switch to the other world is performed. Each side therefore facilitates an incoming and an
+ * outgoing queue for communication with the other side.
+ *
+ * Notifications hold the session ID, which is used to reference the communication partner in the other world.
+ * So if, e.g., the TLC in the normal world wants to notify his trustlet about new data in the TLC buffer
+ *
+ * @file
+ * Notification queue declarations.
+ *
+ */
+
+#ifndef NQ_H_
+#define NQ_H_
+
+/** \name NQ Size Defines
+ * Minimum and maximum count of elements in the notification queue.
+ * @{ */
+#define MIN_NQ_ELEM 1 /**< Minimum notification queue elements. */
+#define MAX_NQ_ELEM 64 /**< Maximum notification queue elements. */
+/** @} */
+
+/** \name NQ Length Defines
+ * Minimum and maximum notification queue length.
+ * @{ */
+#define MIN_NQ_LEN (MIN_NQ_ELEM * sizeof(notification_t)) /**< Minimum notification length (in bytes). */
+#define MAX_NQ_LEN (MAX_NQ_ELEM * sizeof(notification_t)) /**< Maximum notification length (in bytes). */
+/** @} */
+
+/** \name Session ID Defines
+ * Standard Session IDs.
+ * @{ */
+#define SID_MCP 0 /**< MCP session ID is used when directly communicating with the MobiCore (e.g. for starting and stopping of trustlets). */
+#define SID_INVALID 0xffffffff /**< Invalid session id is returned in case of an error. */
+/** @} */
+
+/** Notification data structure. */
+typedef struct{
+ uint32_t sessionId; /**< Session ID. */
+ int32_t payload; /**< Additional notification information. */
+} notification_t;
+
+/** Notification payload codes.
+ * 0 indicated a plain simple notification,
+ * a positive value is a termination reason from the task,
+ * a negative value is a termination reason from MobiCore.
+ * Possible negative values are given below.
+ */
+typedef enum {
+ ERR_INVALID_EXIT_CODE = -1, /**< task terminated, but exit code is invalid */
+ ERR_SESSION_CLOSE = -2, /**< task terminated due to session end, no exit code available */
+ ERR_INVALID_OPERATION = -3, /**< task terminated due to invalid operation */
+ ERR_INVALID_SID = -4, /**< session ID is unknown */
+ ERR_SID_NOT_ACTIVE = -5 /**< session is not active */
+} notificationPayload_t;
+
+/** Declaration of the notification queue header.
+ * layout as specified in the data structure specification.
+ */
+typedef struct {
+ uint32_t writeCnt; /**< Write counter. */
+ uint32_t readCnt; /**< Read counter. */
+ uint32_t queueSize; /**< Queue size. */
+} notificationQueueHeader_t;
+
+/** Queue struct which defines a queue object.
+ * The queue struct is accessed by the queue<operation> type of
+ * function. elementCnt must be a power of two and the power needs
+ * to be smaller than power of uint32_t (obviously 32).
+ */
+typedef struct {
+ notificationQueueHeader_t hdr; /**< Queue header. */
+ notification_t notification[MIN_NQ_ELEM]; /**< Notification elements. */
+} notificationQueue_t;
+
+#endif /** NQ_H_ */
+
+/** @} */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef MCI_VERSION_H_
+#define MCI_VERSION_H_
+
+#define MCI_VERSION_MAJOR 0
+#define MCI_VERSION_MINOR 6
+
+#endif /** MCI_VERSION_H_ */
--- /dev/null
+/** @addtogroup CMP_2_0
+ * Content Management Protocol 2.0 Definitions.
+ *
+ * The content management protocol (CMP) is based on the trustlet control
+ * interface (TCI) and defines commands/responses with the content management
+ * trustlet (TlCm).
+ *
+ * @{
+ *
+ * @file
+ * CMP 2.0 global definitions.
+ * Various components need access to (sub-)structures defined and used by CMP
+ * 2.0. These common definitions are made available through this header file.
+ *
+ * Copyright © Trustonic Limited 2013.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the Trustonic Limited nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CMP_H_
+#define CMP_H_
+
+#include "TlCm/cmpCommon.h"
+
+/** Key size of encryption algorithm used for secure messaging. */
+#define CMP_MSG_KEY_SIZE 32
+
+/** @defgroup MC_CMP_2_0_CMD_BEGIN_SOC_AUTHENTICATION \
+ MC_CMP_2_0_CMD_BEGIN_SOC_AUTHENTICATION
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_BEGIN_SOC_AUTHENTICATION_CMD Command_2_0
+ * @{ */
+
+/** BeginSocAuthentication non signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+} cmpBeginSocAuthenticationCmd_t;
+
+/** BeginSocAuthentication command. */
+typedef struct {
+ /** Command. */
+ cmpBeginSocAuthenticationCmd_t cmd;
+ /** AuthToken container secure object. */
+ mcSoAuthTokenCont_t soAuthTokenCont;
+} cmpCmdBeginSocAuthentication_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_BEGIN_SOC_AUTHENTICATION_RSP Response_2_0
+ * @{ */
+
+/** BeginSocAuthentication signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Suid. */
+ mcSuid_t suid;
+ /** SWd authentication random number. */
+ cmpRnd8_t rnd1;
+} cmpBeginSocAuthenticationRspSdata_t;
+
+/** BeginSocAuthentication signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpBeginSocAuthenticationRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpBeginSocAuthenticationRsp_t;
+
+/** BeginSocAuthentication response. */
+typedef struct {
+ /** Response. */
+ cmpBeginSocAuthenticationRsp_t rsp;
+} cmpRspBeginSocAuthentication_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_BEGIN_ROOT_AUTHENTICATION \
+ MC_CMP_2_0_CMD_BEGIN_ROOT_AUTHENTICATION
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_BEGIN_ROOT_AUTHENTICATION_CMD Command_2_0
+ * @{ */
+
+/** BeginRootAuthentication non signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+} cmpBeginRootAuthenticationCmd_t;
+
+/** BeginRootAuthentication command. */
+typedef struct {
+ /** Command. */
+ cmpBeginRootAuthenticationCmd_t cmd;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpCmdBeginRootAuthentication_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_BEGIN_ROOT_AUTHENTICATION_RSP Response_2_0
+ * @{ */
+
+/** BeginRootAuthentication signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Suid. */
+ mcSuid_t suid;
+ /** SWd authentication random number. */
+ cmpRnd8_t rnd1;
+} cmpBeginRootAuthenticationRspSdata_t;
+
+/** BeginRootAuthentication signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpBeginRootAuthenticationRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpBeginRootAuthenticationRsp_t;
+
+/** BeginRootAuthentication response. */
+typedef struct {
+ /** Response. */
+ cmpBeginRootAuthenticationRsp_t rsp;
+} cmpRspBeginRootAuthentication_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_BEGIN_SP_AUTHENTICATION \
+ MC_CMP_2_0_CMD_BEGIN_SP_AUTHENTICATION
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_BEGIN_SP_AUTHENTICATION_CMD Command_2_0
+ * @{ */
+
+/** BeginSpAuthentication non signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpBeginSpAuthenticationCmdSdata_t;
+
+/** BeginSpAuthentication non signed command and no signature. */
+typedef struct {
+ /** Non signed command. */
+ cmpBeginSpAuthenticationCmdSdata_t sdata;
+} cmpBeginSpAuthenticationCmd_t;
+
+/** BeginSpAuthentication command. */
+typedef struct {
+ /** Command. */
+ cmpBeginSpAuthenticationCmd_t cmd;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpCmdBeginSpAuthentication_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_BEGIN_SP_AUTHENTICATION_RSP Response_2_0
+ * @{ */
+
+/** BeginSpAuthentication signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Suid. */
+ mcSuid_t suid;
+ /** Spid. */
+ mcSpid_t spid;
+ /** SWd authentication random number. */
+ cmpRnd8_t rnd1;
+} cmpBeginSpAuthenticationRspSdata_t;
+
+/** BeginSpAuthentication signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpBeginSpAuthenticationRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpBeginSpAuthenticationRsp_t;
+
+/** BeginSpAuthentication response. */
+typedef struct {
+ /** Response. */
+ cmpBeginSpAuthenticationRsp_t rsp;
+} cmpRspBeginSpAuthentication_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE MC_CMP_2_0_CMD_AUTHENTICATE
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_CMD Command_2_0
+ * @{ */
+
+/** Authenticate encrypted data command. */
+typedef struct {
+ /** Suid. */
+ mcSuid_t suid;
+ /** EntityId. */
+ uint32_t entityId;
+ /** NWd authentication random number. */
+ cmpRnd8_t rnd2;
+ /** SWd authentication random number. */
+ cmpRnd8_t rnd1;
+ /** NWd authentication random seed. */
+ cmpRnd32_t k2;
+} cmpAuthMsgEdata_t;
+
+/** Authenticate encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpAuthMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpAuthMsgEdata_t))];
+} cmpAuthCmdEd_t;
+
+/** Authenticate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Encrypted and padded data. */
+ cmpAuthCmdEd_t ed;
+} cmpAuthCmdSdata_t;
+
+/** Authenticate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpAuthCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpAuthenticateCmd_t;
+
+/** Authenticate command. */
+typedef struct {
+ /** Command. */
+ cmpAuthenticateCmd_t cmd;
+} cmpCmdAuthenticate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_RSP Response_2_0
+ * @{ */
+
+/** Authenticate encrypted data response. */
+typedef struct {
+ /** Suid. */
+ mcSuid_t suid;
+ /** EntityId. */
+ uint32_t entityId;
+ /** SWd authentication random number. */
+ cmpRnd8_t rnd1;
+ /** NWd authentication random number. */
+ cmpRnd8_t rnd2;
+ /** SWd authentication random seed. */
+ cmpRnd32_t k1;
+} cmpAuthRspEdata_t;
+
+/** Authenticate encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpAuthRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpAuthRspEdata_t))];
+} cmpAuthRspEd_t;
+
+/** Authenticate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpAuthRspEd_t ed;
+} cmpAuthRspSdata_t;
+
+/** Authenticate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpAuthRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpAuthenticateRsp_t;
+
+/** Authenticate response. */
+typedef struct {
+ /** Response. */
+ cmpAuthenticateRsp_t rsp;
+} cmpRspAuthenticate_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_TERMINATE \
+ MC_CMP_2_0_CMD_AUTHENTICATE_TERMINATE
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_TERMINATE_CMD Command_2_0
+ * @{ */
+
+/** AuthenticateTerminate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+} cmpAuthenticateTerminateCmdSdata_t;
+
+/** AuthenticateTerminate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpAuthenticateTerminateCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpAuthenticateTerminateCmd_t;
+
+/** AuthenticateTerminate command. */
+typedef struct {
+ /** Command. */
+ cmpAuthenticateTerminateCmd_t cmd;
+} cmpCmdAuthenticateTerminate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_TERMINATE_RSP Response_2_0
+ * @{ */
+
+/** AuthenticateTerminate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+} cmpAuthenticateTerminateRspSdata_t;
+
+/** AuthenticateTerminate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpAuthenticateTerminateRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTerminateAutenticateRsp_t;
+
+/** AuthenticateTerminate response. */
+typedef struct {
+ /** Response. */
+ cmpTerminateAutenticateRsp_t rsp;
+} cmpRspAuthenticateTerminate_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_REGISTER_ACTIVATE \
+ MC_CMP_2_0_CMD_ROOT_CONT_REGISTER_ACTIVATE
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_REGISTER_ACTIVATE_CMD Command_2_0
+ * @{ */
+
+/** RootContRegisterActivate encrypted data command. */
+typedef struct {
+ /** Root authentication key. */
+ mcSymmetricKey_t kRootAuth;
+} cmpRootRegActMsgEdata_t;
+
+/** RootContRegisterActivate encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpRootRegActMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootRegActMsgEdata_t))];
+} cmpRootRegActCmdEd_t;
+
+/** RootContRegisterActivate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Rootid. */
+ mcRootid_t rootid;
+ /** Encrypted and padded data. */
+ cmpRootRegActCmdEd_t ed;
+} cmpRootRegActCmdSdata_t;
+
+/** RootContRegisterActivate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpRootRegActCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContRegisterActivateCmd_t;
+
+/** RootContRegisterActivate command. */
+typedef struct {
+ /** Command. */
+ cmpRootContRegisterActivateCmd_t cmd;
+} cmpCmdRootContRegisterActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_REGISTER_ACTIVATE_RSP Response_2_0
+ * @{ */
+
+/** RootContRegisterActivate encrypted data response. */
+typedef struct {
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpRootRegActRspEdata_t;
+
+/** RootContRegisterActivate encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpRootRegActRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootRegActRspEdata_t))];
+} cmpRootRegActRspEd_t;
+
+/** RootContRegisterActivate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpRootRegActRspEd_t ed;
+} cmpRootRegActRspSdata_t;
+
+/** RootContRegisterActivate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpRootRegActRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContRegisterActivateRsp_t;
+
+/** RooContRegisterActivate response. */
+typedef struct {
+ /** Response. */
+ cmpRootContRegisterActivateRsp_t rsp;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpRspRootContRegisterActivate_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNREGISTER \
+ MC_CMP_2_0_CMD_ROOT_CONT_UNREGISTER
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNREGISTER_CMD Command_2_0
+ * @{ */
+
+/** RootContUnregister encrypted data command. */
+typedef struct {
+ /** Suid. */
+ mcSuid_t suid;
+ /** AuthToken container secure object. */
+ mcSoAuthTokenCont_t soAuthTokenCont;
+} cmpRootUnregMsgEdata_t;
+
+/** RootContUnregister encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpRootUnregMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootUnregMsgEdata_t))];
+} cmpRootUnregCmdEd_t;
+
+/** RootContUnregister signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Encrypted and padded data. */
+ cmpRootUnregCmdEd_t ed;
+} cmpRootUnregCmdSdata_t;
+
+/** RootContUnregister signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpRootUnregCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContUnregisterCmd_t;
+
+/** RootContUnregister command. */
+typedef struct {
+ /** Command. */
+ cmpRootContUnregisterCmd_t cmd;
+} cmpCmdRootContUnregister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNREGISTER_RSP Response_2_0
+ * @{ */
+
+/** RootContUnregister encrypted data response. */
+typedef struct {
+ /** Suid. */
+ mcSuid_t suid;
+} cmpRootUnregRspEdata_t;
+
+/** RootContUnregister encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpRootUnregRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootUnregRspEdata_t))];
+} cmpRootUnregRspEd_t;
+
+/** RootContUnregister signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpRootUnregRspEd_t ed;
+} cmpRootUnregRspSdata_t;
+
+/** RootContUnregister signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpRootUnregRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContUnregisterRsp_t;
+
+/** RootContUnregister response. */
+typedef struct {
+ /** Response. */
+ cmpRootContUnregisterRsp_t rsp;
+ /** AuthToken container secure object. */
+ mcSoAuthTokenCont_t soAuthTokenCont;
+} cmpRspRootContUnregister_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_LOCK_BY_ROOT \
+ MC_CMP_2_0_CMD_ROOT_CONT_LOCK_BY_ROOT
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_LOCK_BY_ROOT_CMD Command_2_0
+ * @{ */
+
+/** RootContLockByRoot signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+} cmpRootLockByRootCmdSdata_t;
+
+/** RootContLockByRoot signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpRootLockByRootCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContLockByRootCmd_t;
+
+/** RootContLockByRoot command. */
+typedef struct {
+ /** Command. */
+ cmpRootContLockByRootCmd_t cmd;
+} cmpCmdRootContLockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_LOCK_BY_ROOT_RSP Response_2_0
+ * @{ */
+
+/** RootContLockByRoot encrypted data response. */
+typedef struct {
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpRootLockByRootRspEdata_t;
+
+/** RootContLockByRoot encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpRootLockByRootRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootLockByRootRspEdata_t))];
+} cmpRootLockByRootRspEd_t;
+
+/** RootContLockByRoot signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpRootLockByRootRspEd_t ed;
+} cmpRootLockByRootRspSdata_t;
+
+/** RootContLockByRoot signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpRootLockByRootRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContLockByRootRsp_t;
+
+/** RootContLockByRoot response. */
+typedef struct {
+ /** Response. */
+ cmpRootContLockByRootRsp_t rsp;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpRspRootContLockByRoot_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNLOCK_BY_ROOT \
+ MC_CMP_2_0_CMD_ROOT_CONT_UNLOCK_BY_ROOT
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNLOCK_BY_ROOT_CMD Command_2_0
+ * @{ */
+
+/** RootContUnlockByRoot signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+} cmpRootUnlockByRootCmdSdata_t;
+
+/** RootContUnlockByRoot signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpRootUnlockByRootCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContUnlockByRootCmd_t;
+
+/** RootContUnlockByRoot command. */
+typedef struct {
+ /** Command. */
+ cmpRootContUnlockByRootCmd_t cmd;
+} cmpCmdRootContUnlockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNLOCK_BY_ROOT_RSP Response_2_0
+ * @{ */
+
+/** RootContUnlockByRoot encrypted data response. */
+typedef struct {
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpRootUnlockByRootRspEdata_t;
+
+/** RootContUnlockByRoot encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpRootUnlockByRootRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootUnlockByRootRspEdata_t))];
+} cmpRootUnlockByRootRspEd_t;
+
+/** RootContUnlockByRoot signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpRootUnlockByRootRspEd_t ed;
+} cmpRootUnlockByRootRspSdata_t;
+
+/** RootContUnlockByRoot signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpRootUnlockByRootRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContUnlockByRootRsp_t;
+
+/** RootContUnlockByRoot response. */
+typedef struct {
+ /** Response. */
+ cmpRootContUnlockByRootRsp_t rsp;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpRspRootContUnlockByRoot_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_ACTIVATE \
+ MC_CMP_2_0_CMD_SP_CONT_REGISTER_ACTIVATE
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_ACTIVATE_CMD Command_2_0
+ * @{ */
+
+/** SpContRegisterActivate encrypted data command. */
+typedef struct {
+ /** Sp authentication key. */
+ mcSymmetricKey_t kSpAuth;
+} cmpSpRegActMsgEdata_t;
+
+/** SpContRegisterActivate encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpRegActMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegActMsgEdata_t))];
+} cmpSpRegActCmdEd_t;
+
+/** SpContRegisterActivate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ mcSpid_t spid;
+ /** Encrypted and padded data. */
+ cmpSpRegActCmdEd_t ed;
+} cmpSpRegActCmdSdata_t;
+
+/** SpContRegisterActivate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpRegActCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContRegisterActivateCmd_t;
+
+/** SpContRegisterActivate command. */
+typedef struct {
+ /** Command. */
+ cmpSpContRegisterActivateCmd_t cmd;
+} cmpCmdSpContRegisterActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_ACTIVATE_RSP Response_2_0
+ * @{ */
+
+/** SpContRegisterActivate encrypted data response. */
+typedef struct {
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpRegActRspEdata_t;
+
+/** SpContRegisterActivate encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpRegActRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegActRspEdata_t))];
+} cmpSpRegActRspEd_t;
+
+/** SpContRegisterActivate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpSpRegActRspEd_t ed;
+} cmpSpRegActRspSdata_t;
+
+/** SpContRegisterActivate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpRegActRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContRegisterActivateRsp_t;
+
+/** SpContRegisterActivate response. */
+typedef struct {
+ /** Response. */
+ cmpSpContRegisterActivateRsp_t rsp;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpRspSpContRegisterActivate_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNREGISTER \
+ MC_CMP_2_0_CMD_SP_CONT_UNREGISTER
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNREGISTER_CMD Command_2_0
+ * @{ */
+
+/** SpContUnregister signed response. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpSpContUnregCmdSdata_t;
+
+/** SpContUnregister signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpContUnregCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnregisterCmd_t;
+
+/** SpContUnregister command. */
+typedef struct {
+ /** Command. */
+ cmpSpContUnregisterCmd_t cmd;
+} cmpCmdSpContUnregister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNREGISTER_RSP Response_2_0
+ * @{ */
+
+/** SpContUnregister encrypted data response. */
+typedef struct {
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpSpUnregRspEdata_t;
+
+/** SpContUnregister encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpUnregRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpUnregRspEdata_t))];
+} cmpSpUnregRspEd_t;
+
+/** SpContUnregister signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpSpUnregRspEd_t ed;
+} cmpSpContUnregRspSdata_t;
+
+/** SpContUnregister signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpContUnregRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnregisterRsp_t;
+
+/** SpContUnregister response. */
+typedef struct {
+ /** Response. */
+ cmpSpContUnregisterRsp_t rsp;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpRspSpContUnregister_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER \
+ MC_CMP_2_0_CMD_SP_CONT_REGISTER
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_CMD Command_2_0
+ * @{ */
+
+/** SpContRegister encrypted data command. */
+typedef struct {
+ /** Sp authentication key. */
+ mcSymmetricKey_t kSpAuth;
+} cmpSpRegisterMsgEdata_t;
+
+/** SpContRegister encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpRegisterMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegisterMsgEdata_t))];
+} cmpSpRegisterCmdEd_t;
+
+/** SpContRegister signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Encrypted and padded data. */
+ cmpSpRegisterCmdEd_t ed;
+} cmpSpRegisterCmdSdata_t;
+
+/** SpContRegister signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpRegisterCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContRegisterCmd_t;
+
+/** SpContRegister command. */
+typedef struct {
+ /** Command. */
+ cmpSpContRegisterCmd_t cmd;
+} cmpCmdSpContRegister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_RSP Response_2_0
+ * @{ */
+
+/** SpContRegister encrypted data response. */
+typedef struct {
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpRegisterRspEdata_t;
+
+/** SpContRegister encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpRegisterRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegisterRspEdata_t))];
+} cmpSpRegisterRspEd_t;
+
+/** SpContRegister signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpSpRegisterRspEd_t ed;
+} cmpSpRegisterRspSdata_t;
+
+/** SpContRegister signed response and signature. */
+typedef struct {
+ cmpSpRegisterRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContRegisterRsp_t;
+
+/** SpContRegister response. */
+typedef struct {
+ /** Response. */
+ cmpSpContRegisterRsp_t rsp;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpRspSpContRegister_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_ROOT \
+ MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_ROOT
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_ROOT_CMD Command_2_0
+ * @{ */
+
+/** SpContLockByRoot signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpSpLockByRootCmdSdata_t;
+
+/** SpContLockByRoot signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpLockByRootCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContLockByRootCmd_t;
+
+/** SpContLockByRoot command. */
+typedef struct {
+ /** Command. */
+ cmpSpContLockByRootCmd_t cmd;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpCmdSpContLockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_ROOT_RSP Response_2_0
+ * @{ */
+
+/** SpContLockByRoot encrypted data response. */
+typedef struct {
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpLockByRootRspEdata_t;
+
+/** SpContLockByRoot encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpLockByRootRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpLockByRootRspEdata_t))];
+} cmpSpLockByRootRspEd_t;
+
+/** SpContLockByRoot signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpSpLockByRootRspEd_t ed;
+} cmpSpLockByRootRspSdata_t;
+
+/** SpContLockByRoot signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpLockByRootRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContLockByRootRsp_t;
+
+/** SpContLockByRoot response. */
+typedef struct {
+ /** Response. */
+ cmpSpContLockByRootRsp_t rsp;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpRspSpContLockByRoot_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_ROOT \
+ MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_ROOT
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_ROOT_CMD Command_2_0
+ * @{ */
+
+/** SpContUnlockByRoot signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpSpUnlockByRootCmdSdata_t;
+
+/** SpContUnlockByRoot signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpUnlockByRootCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnlockByRootCmd_t;
+
+/** SpContUnlockByRoot command. */
+typedef struct {
+ /** Command. */
+ cmpSpContUnlockByRootCmd_t cmd;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpCmdSpContUnlockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_ROOT_RSP Response_2_0
+ * @{ */
+
+/** SpContUnlockByRoot encrypted data response. */
+typedef struct {
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpUnlockByRootRspEdata_t;
+
+/** SpContUnlockByRoot encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpUnlockByRootRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpUnlockByRootRspEdata_t))];
+} cmpSpUnlockByRootRspEd_t;
+
+/** SpContUnlockByRoot signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpSpUnlockByRootRspEd_t ed;
+} cmpSpUnlockByRootRspSdata_t;
+
+/** SpContUnlockByRoot signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpUnlockByRootRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnlockByRootRsp_t;
+
+/** SpContUnlockByRoot response. */
+typedef struct {
+ /** Response. */
+ cmpSpContUnlockByRootRsp_t rsp;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpRspSpContUnlockByRoot_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_ACTIVATE \
+ MC_CMP_2_0_CMD_SP_CONT_ACTIVATE
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_ACTIVATE_CMD Command_2_0
+ * @{ */
+
+/** SpContActivate encrypted data command. */
+typedef struct {
+ /** Sp authentication key. */
+ mcSymmetricKey_t kSpAuth;
+} cmpSpActivateMsgEdata_t;
+
+/** SpContActivate encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpActivateMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpActivateMsgEdata_t))];
+} cmpSpActivateCmdEd_t;
+
+/** SpContActivate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Encrypted and padded data. */
+ cmpSpActivateCmdEd_t ed;
+} cmpSpActivateCmdSdata_t;
+
+/** SpContActivate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpActivateCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContActivateCmd_t;
+
+/** SpContActivate command. */
+typedef struct {
+ /** Command. */
+ cmpSpContActivateCmd_t cmd;
+} cmpCmdSpContActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_ACTIVATE_RSP Response_2_0
+ * @{ */
+
+/** SpContActivate encrypted data response. */
+typedef struct {
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpActivateRspEdata_t;
+
+/** SpContActivate encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpActivateRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpActivateRspEdata_t))];
+} cmpSpActivateRspEd_t;
+
+/** SpContActivate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpSpActivateRspEd_t ed;
+} cmpSpActivateRspSdata_t;
+
+/** SpContActivate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpActivateRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContActivateRsp_t;
+
+/** SpContActivate response. */
+typedef struct {
+ /** Response. */
+ cmpSpContActivateRsp_t rsp;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpRspSpContActivate_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_SP \
+ MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_SP
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_SP_CMD Command_2_0
+ * @{ */
+
+/** SpContLockBySp signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpSpLockBySpCmdSdata_t;
+
+/** SpContLockBySp signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpLockBySpCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContLockBySpCmd_t;
+
+/** SpContLockBySp command. */
+typedef struct {
+ /** Command. */
+ cmpSpContLockBySpCmd_t cmd;
+} cmpCmdSpContLockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_SP_RSP Response_2_0
+ * @{ */
+
+/** SpContLockBySp encrypted data response. */
+typedef struct {
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpLockBySpRspEdata_t;
+
+/** SpContLockBySp encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpLockBySpRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpLockBySpRspEdata_t))];
+} cmpSpLockBySpRspEd_t;
+
+/** SpContLockBySp signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpSpLockBySpRspEd_t ed;
+} cmpSpLockBySpRspSdata_t;
+
+/** SpContLockBySp signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpLockBySpRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContLockBySpRsp_t;
+
+/** SpContLockBySp response. */
+typedef struct {
+ /** Response. */
+ cmpSpContLockBySpRsp_t rsp;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpRspSpContLockBySp_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_SP \
+ MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_SP
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_SP_CMD Command_2_0
+ * @{ */
+
+/** SpContUnlockBySp signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpSpUnlockBySpCmdSdata_t;
+
+/** SpContUnlockBySp signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpUnlockBySpCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnlockBySpCmd_t;
+
+/** SpContUnlockBySp command. */
+typedef struct {
+ /** Command. */
+ cmpSpContUnlockBySpCmd_t cmd;
+} cmpCmdSpContUnlockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_SP_RSP Response_2_0
+ * @{ */
+
+/** SpContUnlockBySp encrypted data response. */
+typedef struct {
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpUnlockBySpRspEdata_t;
+
+/** SpContUnlockBySp encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpUnlockBySpRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpUnlockBySpRspEdata_t))];
+} cmpSpUnlockBySpRspEd_t;
+
+/** SpContUnlockBySp signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpSpUnlockBySpRspEd_t ed;
+} cmpSpUnlockBySpRspSdata_t;
+
+/** SpContUnlockBySp signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpUnlockBySpRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnlockBySpRsp_t;
+
+/** SpContUnlockBySp response. */
+typedef struct {
+ /** Response. */
+ cmpSpContUnlockBySpRsp_t rsp;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpRspSpContUnlockBySp_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_ACTIVATE \
+ MC_CMP_2_0_CMD_TLT_CONT_REGISTER_ACTIVATE
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_ACTIVATE_CMD Command_2_0
+ * @{ */
+
+/** TltContRegisterActivate encrypted data command. */
+typedef struct {
+ /** Tlt authentication key. */
+ mcSymmetricKey_t kSpTltEnc;
+} cmpTltRegActMsgEdata_t;
+
+/** TltContRegisterActivate encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltRegActMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegActMsgEdata_t))];
+} cmpTltRegActCmdEd_t;
+
+/** TltContRegisterActivate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+ /** Encrypted and padded data. */
+ cmpTltRegActCmdEd_t ed;
+} cmpTltRegActCmdSdata_t;
+
+/** TltContRegisterActivate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltRegActCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContRegisterActivateCmd_t;
+
+/** TltContRegisterActivate command. */
+typedef struct {
+ /** Command. */
+ cmpTltContRegisterActivateCmd_t cmd;
+} cmpCmdTltContRegisterActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_ACTIVATE_RSP Response_2_0
+ * @{ */
+
+/** TltContRegisterActivate encrypted data response. */
+typedef struct {
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpTltRegActRspEdata_t;
+
+/** TltContRegisterActivate encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltRegActRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegActRspEdata_t))];
+} cmpTltRegActRspEd_t;
+
+/** TltContRegisterActivate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpTltRegActRspEd_t ed;
+} cmpTltRegActRspSdata_t;
+
+/** TltContRegisterActivate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltRegActRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContRegisterActivateRsp_t;
+
+/** TltContRegisterActivate response. */
+typedef struct {
+ /** Response. */
+ cmpTltContRegisterActivateRsp_t rsp;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpRspTltContRegisterActivate_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNREGISTER \
+ MC_CMP_2_0_CMD_TLT_CONT_UNREGISTER
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNREGISTER_CMD Command_2_0
+ * @{ */
+
+/** TltContUnregister signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+} cmpTltUnregCmdSdata_t;
+
+/** TltContUnregister signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltUnregCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContUnregisterCmd_t;
+
+/** TltContUnregister command. */
+typedef struct {
+ /** Command. */
+ cmpTltContUnregisterCmd_t cmd;
+} cmpCmdTltContUnregister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNREGISTER_RSP Response_2_0
+ * @{ */
+
+/** TltContUnregister encrypted data response. */
+typedef struct {
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpTltUnregRspEdata_t;
+
+/** TltContUnregister encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltUnregRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltUnregRspEdata_t))];
+} cmpTltUnregRspEd_t;
+
+/** TltContUnregister signed command. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpTltUnregRspEd_t ed;
+} cmpTltUnregRspSdata_t;
+
+/** TltContUnregister signed command and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltUnregRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContUnregisterRsp_t;
+
+/** TltContUnregister response. */
+typedef struct {
+ /** Response. */
+ cmpTltContUnregisterRsp_t rsp;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpRspTltContUnregister_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER \
+ MC_CMP_2_0_CMD_TLT_CONT_REGISTER
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_CMD Command_2_0
+ * @{ */
+
+/** TltContRegister encrypted data command. */
+typedef struct {
+ /** Tlt authentication key. */
+ mcSymmetricKey_t kSpTltEnc;
+} cmpTltRegMsgEdata_t;
+
+/** TltContRegister encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltRegMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegMsgEdata_t))];
+} cmpTltRegCmdEd_t;
+
+/** TltContRegister signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+ /** Encrypted and padded data. */
+ cmpTltRegCmdEd_t ed;
+} cmpTltRegCmdSdata_t;
+
+/** TltContRegister signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltRegCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContRegisterCmd_t;
+
+/** TltContRegister command. */
+typedef struct {
+ /** Command. */
+ cmpTltContRegisterCmd_t cmd;
+} cmpCmdTltContRegister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_RSP Response_2_0
+ * @{ */
+
+/** TltContRegister encrypted data response. */
+typedef struct {
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpTltRegRspEdata_t;
+
+/** TltContRegister encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltRegRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegRspEdata_t))];
+} cmpTltRegRspEd_t;
+
+/** TltContRegister signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpTltRegRspEd_t ed;
+} cmpTltRegRspSdata_t;
+
+/** TltContRegister signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltRegRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContRegisterRsp_t;
+
+/** TltContRegister response. */
+typedef struct {
+ /** Response. */
+ cmpTltContRegisterRsp_t rsp;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpRspTltContRegister_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_ACTIVATE \
+ MC_CMP_2_0_CMD_TLT_CONT_ACTIVATE
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_ACTIVATE_CMD Command_2_0
+ * @{ */
+
+/** TltContActivate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+} cmpTltActCmdSdata_t;
+
+/** TltContActivate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltActCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContActivateCmd_t;
+
+/** TltContActivate command. */
+typedef struct {
+ /** Command. */
+ cmpTltContActivateCmd_t cmd;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpCmdTltContActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_ACTIVATE_RSP Response_2_0
+ * @{ */
+
+/** TltContActivate encrypted data response. */
+typedef struct {
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpTltActRspEdata_t;
+
+/** TltContActivate encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltActRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltActRspEdata_t))];
+} cmpTltActRspEd_t;
+
+/** TltContActivate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpTltActRspEd_t ed;
+} cmpTltActRspSdata_t;
+
+/** TltContActivate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltActRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContActivateRsp_t;
+
+/** TltContActivate response. */
+typedef struct {
+ /** Response. */
+ cmpTltContActivateRsp_t rsp;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpRspTltContActivate_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_LOCK_BY_SP \
+ MC_CMP_2_0_CMD_TLT_CONT_LOCK_BY_SP
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_LOCK_BY_SP_CMD Command_2_0
+ * @{ */
+
+/** TltContLockBySp signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+} cmpTltLockBySpCmdSdata_t;
+
+/** TltContLockBySp signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltLockBySpCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContLockBySpCmd_t;
+
+/** TltContLockBySp command. */
+typedef struct {
+ /** Command. */
+ cmpTltContLockBySpCmd_t cmd;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpCmdTltContLockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_LOCK_BY_SP_RSP Response_2_0
+ * @{ */
+
+/** TltContLockBySp encrypted data response. */
+typedef struct {
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpTltLockBySpRspEdata_t;
+
+/** TltContLockBySp encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltLockBySpRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltLockBySpRspEdata_t))];
+} cmpTltLockBySpRspEd_t;
+
+/** TltContLockBySp signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpTltLockBySpRspEd_t ed;
+} cmpTltLockBySpRspSdata_t;
+
+/** TltContLockBySp signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltLockBySpRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContLockBySpRsp_t;
+
+/** TltContLockBySp response. */
+typedef struct {
+ /** Response. */
+ cmpTltContLockBySpRsp_t rsp;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpRspTltContLockBySp_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNLOCK_BY_SP \
+ MC_CMP_2_0_CMD_TLT_CONT_UNLOCK_BY_SP
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNLOCK_BY_SP_CMD Command_2_0
+ * @{ */
+
+/** TltContUnlockBySp signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+} cmpTltUnlockBySpCmdSdata_t;
+
+/** TltContUnlockBySp signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltUnlockBySpCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContUnlockBySpCmd_t;
+
+/** TltContUnlockBySp command. */
+typedef struct {
+ /** Command. */
+ cmpTltContUnlockBySpCmd_t cmd;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpCmdTltContUnlockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNLOCK_BY_SP_RSP Response_2_0
+ * @{ */
+
+/** TltContUnlockBySp encrypted data response. */
+typedef struct {
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpTltUnlockBySpRspEdata_t;
+
+/** TltContUnlockBySp encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltUnlockBySpRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltUnlockBySpRspEdata_t))];
+} cmpTltUnlockBySpRspEd_t;
+
+/** TltContUnlockBySp signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data. */
+ cmpTltUnlockBySpRspEd_t ed;
+} cmpTltUnlockBySpRspSdata_t;
+
+/** TltContUnlockBySp signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltUnlockBySpRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContUnlockBySpRsp_t;
+
+/** TltContUnlockBySp response. */
+typedef struct {
+ /** Response. */
+ cmpTltContUnlockBySpRsp_t rsp;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpRspTltContUnlockBySp_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_PERSONALIZE \
+ MC_CMP_2_0_CMD_TLT_CONT_PERSONALIZE
+ * @{ */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_PERSONALIZE_CMD Command_2_0
+ * @{ */
+
+/** TltContPersonalize encrypted data command. */
+typedef struct {
+ /** Pid. */
+ mcPid_t pid;
+ /** Data. */
+ mcCoDataCont_t persoData;
+} cmpTltContPersonalizeCmdEdata_t;
+
+/** TltContPersonalize encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltContPersonalizeCmdEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltContPersonalizeCmdEdata_t))];
+} cmpTltContPersonalizeCmdEd_t;
+
+/** TltContPersonalize signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpTltContPersonalizeCmdEd_t ed;
+} cmpTltContPersonalizeCmdSdata_t;
+
+/** TltContPersonalize signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltContPersonalizeCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContPersonalizeCmd_t;
+
+/** TltContPersonalize command. */
+typedef struct {
+ /** Command. */
+ cmpTltContPersonalizeCmd_t cmd;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_0_t soTltCont;
+} cmpCmdTltContPersonalize_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_PERSONLIZE_RSP Response_2_0
+ * @{ */
+
+/** TltContPersonalize encrypted data response. */
+typedef struct {
+ /** Data container secure object. */
+ mcSoDataCont_t soDataCont;
+} cmpTltContPersonalizeRspEdata_t;
+
+/** TltContPersonalize encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltContPersonalizeRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltContPersonalizeRspEdata_t))];
+} cmpTltContPersonalizeRspEd_t;
+
+/** TltContPersonalize signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpTltContPersonalizeRspEd_t ed;
+} cmpTltContPersonalizeRspSdata_t;
+
+/** TltContPersonalize signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltContPersonalizeRspSdata_t sdata;
+ cmpMac_t mac;
+} cmpTltContPersonalizeRsp_t;
+
+/** TltContPersonalize response. */
+typedef struct {
+ /** Response. */
+ cmpTltContPersonalizeRsp_t rsp;
+ /** Data container secure object. */
+ mcSoDataCont_t soDataCont;
+} cmpRspTltContPersonalize_t;
+
+/** @} */
+
+/** @} */
+
+#endif // CMP_H_
+
+/** @} */
--- /dev/null
+/** @addtogroup CMP_2_0
+ * @{
+ * @file
+ * Interface to content management trustlet (TlCm) definitions.
+ *
+ * The TlCm is responsible for implementing content management protocol (CMP)
+ * 2.0 commands and generating approriate CMP 2.0 responses in the trustlet
+ * control interface (TCI).
+ *
+ * Copyright © Trustonic Limited 2013.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the Trustonic Limited nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TL_CM_API_H_
+#define TL_CM_API_H_
+
+#include "TlCm/tlCmApiCommon.h"
+#include "TlCm/2.0/cmp.h"
+
+/** TCI CMP 2.0 messages. */
+typedef union {
+ /** Command header. */
+ cmpCommandHeader_t commandHeader;
+ /** Response header. */
+ cmpResponseHeader_t responseHeader;
+
+ /** System command GetVersion. */
+ cmpCmdGetVersion_t cmpCmdGetVersion;
+ /** System response GetVersion. */
+ cmpRspGetVersion_t cmpRspGetVersion;
+ /** System command GetSuid. */
+ cmpCmdGetSuid_t cmpCmdGetSuid;
+ /** System response GetSuid. */
+ cmpRspGetSuid_t cmpRspGetSuid;
+ /** System command GenAuthToken. */
+ cmpCmdGenAuthToken_t cmpCmdGenAuthToken;
+ /** System response GenAuthToken. */
+ cmpRspGenAuthToken_t cmpRspGenAuthToken;
+
+ /** Authentication command BeginSocAuthentication. */
+ cmpCmdBeginSocAuthentication_t cmpCmdBeginSocAuthentication;
+ /** Authentication response BeginSocAuthentication. */
+ cmpRspBeginSocAuthentication_t cmpRspBeginSocAuthentication;
+ /** Authentication command BeginRootAuthentication. */
+ cmpCmdBeginRootAuthentication_t cmpCmdBeginRootAuthentication;
+ /** Authentication response BeginRootAuthentication. */
+ cmpRspBeginRootAuthentication_t cmpRspBeginRootAuthentication;
+ /** Authentication command BeginSpAuthentication. */
+ cmpCmdBeginSpAuthentication_t cmpCmdBeginSpAuthentication;
+ /** Authentication response BeginSpAuthentication. */
+ cmpRspBeginSpAuthentication_t cmpRspBeginSpAuthentication;
+ /** Authentication command Authenticate. */
+ cmpCmdAuthenticate_t cmpCmdAuthenticate;
+ /** Authentication response Authenticate. */
+ cmpRspAuthenticate_t cmpRspAuthenticate;
+ /** Authentication command AuthenticateTerminate. */
+ cmpCmdAuthenticateTerminate_t cmpCmdAuthenticateTerminate;
+ /** Authentication response AuthenticateTerminate. */
+ cmpRspAuthenticateTerminate_t cmpRspAuthenticateTerminate;
+
+ /** SoC administrative command RootContRegisterActivate. */
+ cmpCmdRootContRegisterActivate_t cmpCmdRootContRegisterActivate;
+ /** SoC administrative response RootContRegisterActivate. */
+ cmpRspRootContRegisterActivate_t cmpRspRootContRegisterActivate;
+
+ /** Root administrative command RootContUnregister. */
+ cmpCmdRootContUnregister_t cmpCmdRootContUnregister;
+ /** Root administrative response RootContUnregister. */
+ cmpRspRootContUnregister_t cmpRspRootContUnregister;
+ /** Root administrative command RootContLockByRoot. */
+ cmpCmdRootContLockByRoot_t cmpCmdRootContLockByRoot;
+ /** Root administrative response RootContLockByRoot. */
+ cmpRspRootContLockByRoot_t cmpRspRootContLockByRoot;
+ /** Root administrative command RootContUnlockByRoot. */
+ cmpCmdRootContUnlockByRoot_t cmpCmdRootContUnlockByRoot;
+ /** Root administrative command RootContUnlockByRoot. */
+ cmpRspRootContUnlockByRoot_t cmpRspRootContUnlockByRoot;
+ /** Root administrative command SpContRegisterActivate. */
+ cmpCmdSpContRegisterActivate_t cmpCmdSpContRegisterActivate;
+ /** Root administrative response SpContRegisterActivate. */
+ cmpRspSpContRegisterActivate_t cmpRspSpContRegisterActivate;
+ /** Root administrative command SpContUnregister. */
+ cmpCmdSpContUnregister_t cmpCmdSpContUnregister;
+ /** Root administrative response SpContUnregister. */
+ cmpRspSpContUnregister_t cmpRspSpContUnregister;
+ /** Root administrative command SpContRegister. */
+ cmpCmdSpContRegister_t cmpCmdSpContRegister;
+ /** Root administrative response SpContRegister. */
+ cmpRspSpContRegister_t cmpRspSpContRegister;
+ /** Root administrative command SpContLockByRoot. */
+ cmpCmdSpContLockByRoot_t cmpCmdSpContLockByRoot;
+ /** Root administrative response SpContLockByRoot. */
+ cmpRspSpContLockByRoot_t cmpRspSpContLockByRoot;
+ /** Root administrative command SpContUnlockByRoot. */
+ cmpCmdSpContUnlockByRoot_t cmpCmdSpContUnlockByRoot;
+ /** Root administrative response SpContUnlockByRoot. */
+ cmpRspSpContUnlockByRoot_t cmpRspSpContUnlockByRoot;
+
+ /** Sp administrative command SpContActivate. */
+ cmpCmdSpContActivate_t cmpCmdSpContActivate;
+ /** Sp administrative response SpContActivate. */
+ cmpRspSpContActivate_t cmpRspSpContActivate;
+ /** Sp administrative command SpContLockBySp. */
+ cmpCmdSpContLockBySp_t cmpCmdSpContLockBySp;
+ /** Sp administrative response SpContLockBySp. */
+ cmpRspSpContLockBySp_t cmpRspSpContLockBySp;
+ /** Sp administrative command SpContUnlockBySp. */
+ cmpCmdSpContUnlockBySp_t cmpCmdSpContUnlockBySp;
+ /** Sp administrative command SpContUnlockBySp. */
+ cmpRspSpContUnlockBySp_t cmpRspSpContUnlockBySp;
+ /** Sp administrative command TltContRegisterActivate. */
+ cmpCmdTltContRegisterActivate_t cmpCmdTltContRegisterActivate;
+ /** Sp administrative response TltContRegisterActivate. */
+ cmpRspTltContRegisterActivate_t cmpRspTltContRegisterActivate;
+ /** Sp administrative command TltContUnregister. */
+ cmpCmdTltContUnregister_t cmpCmdTltContUnregister;
+ /** Sp administrative response TltContUnregister. */
+ cmpRspTltContUnregister_t cmpRspTltContUnregister;
+ /** Sp administrative command TltContRegister. */
+ cmpCmdTltContRegister_t cmpCmdTltContRegister;
+ /** Sp administrative response TltContRegister. */
+ cmpRspTltContRegister_t cmpRspTltContRegister;
+ /** Sp administrative command TltContActivate. */
+ cmpCmdTltContActivate_t cmpCmdTltContActivate;
+ /** Sp administrative response TltContActivate. */
+ cmpRspTltContActivate_t cmpRspTltContActivate;
+ /** Sp administrative command TltContLockBySp. */
+ cmpCmdTltContLockBySp_t cmpCmdTltContLockBySp;
+ /** Sp administrative response TltContLockBySp. */
+ cmpRspTltContLockBySp_t cmpRspTltContLockBySp;
+ /** Sp administrative command TltContUnlockBySp. */
+ cmpCmdTltContUnlockBySp_t cmpCmdTltContUnlockBySp;
+ /** Sp administrative response TltContUnlockBySp. */
+ cmpRspTltContUnlockBySp_t cmpRspTltContUnlockBySp;
+ /** Sp administrative command TltContPersonalize. */
+ cmpCmdTltContPersonalize_t cmpCmdTltContPersonalize;
+ /** Sp administrative response TltContPersonalize. */
+ cmpRspTltContPersonalize_t cmpRspTltContPersonalize;
+} cmpMessage_t;
+
+/** TCI CMP 2.0. */
+typedef struct {
+ /** TCI CMP 2.0 messages. */
+ cmpMessage_t msg;
+} cmp_t;
+
+#endif // TL_CM_API_H_
+
+/** @} */
--- /dev/null
+/** @addtogroup CMP
+ * Content Management Protocol Definitions.
+ *
+ * The content management protocol (CMP) is based on the trustlet control
+ * interface (TCI) and CMP mapped interfaces. It defines commands/responses
+ * with the content management trustlet (TlCm).
+ *
+ * @{
+ *
+ * @file
+ * CMP TCI global definitions.
+ * Various components need access to (sub-)structures defined and used by CMP;
+ * these common definitions are made available through this header file.
+ *
+ * Copyright © Trustonic Limited 2013.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the Trustonic Limited nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CMP_H_
+#define CMP_H_
+
+#include "TlCm/cmpCommon.h"
+
+/** Info of the whole mapped memory with NWd. */
+typedef struct {
+ /** Address of the mapped memory. */
+ void* addr;
+ /** Size of the mapped memory. */
+ uint32_t len;
+} cmpMapInfo_t;
+
+/** Info of the mapped element from a CMP message with NWd. */
+typedef struct {
+ /** Offset of the mapped element in the mapped memory. */
+ uint32_t offset;
+ /** Size of the mapped element. */
+ uint32_t len;
+} cmpMapOffsetInfo_t;
+
+/** TCI CMP command header. */
+typedef struct {
+ /** CMP version. */
+ cmpVersionId_t version;
+ /** Command id. */
+ cmpCommandId_t commandId;
+ /** Info of the whole mapped memory with NWd. */
+ cmpMapInfo_t mapInfo;
+ /** Info of the mapped CMP command with NWd. */
+ cmpMapOffsetInfo_t cmpCmdMapOffsetInfo;
+} cmpCommandHeaderTci_t;
+
+/** TCI CMP response header. */
+typedef struct {
+ /** CMP version. */
+ cmpVersionId_t version;
+ /** Response id (must be command id | RSP_ID_MASK ). */
+ cmpResponseId_t responseId;
+ /** Required lenght (return 0 if lenght is enough) of the mapped memory
+ * with NWd. */
+ uint32_t len;
+} cmpResponseHeaderTci_t;
+
+/** @defgroup MC_CMP_CMD_GET_VERSION_TCI \
+ MC_CMP_CMD_GET_VERSION_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_GET_VERSION_TCI_CMD Command
+ * @{ */
+
+/** GetVersion TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdGetVersionTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_GET_VERSION_TCI_RSP Response
+ * @{ */
+
+/** GetVersion TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+} cmpRspGetVersionTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_GET_SUID_TCI \
+ MC_CMP_CMD_GET_SUID_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_GET_VERSION_TCI_CMD Command
+ * @{ */
+
+/** GetSuid TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdGetSuidTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_GET_VERSION_TCI_RSP Response
+ * @{ */
+
+/** GetSuid TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+} cmpRspGetSuidTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI \
+ MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI_CMD Command
+ * @{ */
+
+/** GenAuthToken TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdGenAuthTokenTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI_RSP Response
+ * @{ */
+
+/** GenAuthToken TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeaderTci;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped AuthTokenCont with NWd. */
+ cmpMapOffsetInfo_t cmpAuthTokenContMapOffsetInfo;
+} cmpRspGenAuthTokenTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_TCI \
+ MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_TCI_CMD Command
+ * @{ */
+
+/** BeginSocAuthentication TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+ /** Offset of the mapped AuthTokenCont with NWd. */
+ cmpMapOffsetInfo_t cmpAuthTokenContMapOffsetInfo;
+} cmpCmdBeginSocAuthenticationTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_TCI_RSP Response
+ * @{ */
+
+/** BeginSocAuthentication TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+} cmpRspBeginSocAuthenticationTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_TCI \
+ MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_TCI_CMD Command
+ * @{ */
+
+/** BeginRootAuthentication TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+ /** Offset of the mapped RootCont with NWd. */
+ cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
+} cmpCmdBeginRootAuthenticationTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_TCI_RSP Response
+ * @{ */
+
+/** BeginRootAuthentication TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+} cmpRspBeginRootAuthenticationTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_TCI \
+ MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_TCI_CMD Command
+ * @{ */
+
+/** BeginSpAuthentication TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+ /** Offset of the mapped RootCont with NWd. */
+ cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+} cmpCmdBeginSpAuthenticationTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_TCI_RSP Response
+ * @{ */
+
+/** BeginSpAuthentication TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+} cmpRspBeginSpAuthenticationTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE_TCI \
+ MC_CMP_CMD_AUTHENTICATE_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE_TCI_CMD Command
+ * @{ */
+
+/** Authenticate TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdAuthenticateTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE_TCI_RSP Response
+ * @{ */
+
+/** Authenticate TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+} cmpRspAuthenticateTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_TCI \
+ MC_CMP_CMD_AUTHENTICATE_TERMINATE_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_TCI_CMD Command
+ * @{ */
+
+/** AuthenticateTerminate TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdAuthenticateTerminateTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_TCI_RSP Response
+ * @{ */
+
+/** AuthenticateTerminate TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+} cmpRspAuthenticateTerminateTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_TCI \
+ MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_TCI_CMD Command
+ * @{ */
+
+/** RootContRegisterActivate TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdRootContRegisterActivateTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_TCI_RSP Response
+ * @{ */
+
+/** RootContRegisterActivate TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped RootCont with NWd. */
+ cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
+} cmpRspRootContRegisterActivateTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_TCI \
+ MC_CMP_CMD_ROOT_CONT_UNREGISTER_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_TCI_CMD Command
+ * @{ */
+
+/** RootContUnregister TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdRootContUnregisterTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_TCI_RSP Response
+ * @{ */
+
+/** RootContUnregister TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+} cmpRspRootContUnregisterTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_TCI \
+ MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_TCI_CMD Command
+ * @{ */
+
+/** RootContLockByRoot TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdRootContLockByRootTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_TCI_RSP Response
+ * @{ */
+
+/** RootContLockByRoot TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped RootCont with NWd. */
+ cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
+} cmpRspRootContLockByRootTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_TCI \
+ MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_TCI_CMD Command
+ * @{ */
+
+/** RootContUnlockByRoot TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdRootContUnlockByRootTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_TCI_RSP Response
+ * @{ */
+
+/** RootContUnlockByRoot TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped RootCont with NWd. */
+ cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
+} cmpRspRootContUnlockByRootTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_TCI \
+ MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_TCI_CMD Command
+ * @{ */
+
+/** SpContRegisterActivate TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdSpContRegisterActivateTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_TCI_RSP Response
+ * @{ */
+
+/** SpContRegisterActivate TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped RootCont with NWd. */
+ cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+} cmpRspSpContRegisterActivateTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_TCI \
+ MC_CMP_CMD_SP_CONT_UNREGISTER_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_TCI_CMD Command
+ * @{ */
+
+/** SpContUnregister TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdSpContUnregisterTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_TCI_RSP Response
+ * @{ */
+
+/** SpContUnregister TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped RootCont with NWd. */
+ cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
+} cmpRspSpContUnregisterTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_TCI \
+ MC_CMP_CMD_SP_CONT_REGISTER_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_TCI_CMD Command
+ * @{ */
+
+/** SpContRegister TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdSpContRegisterTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_TCI_RSP Response
+ * @{ */
+
+/** SpContRegister TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped RootCont with NWd. */
+ cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+} cmpRspSpContRegisterTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_TCI \
+ MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_TCI_CMD Command
+ * @{ */
+
+/** SpContLockByRoot TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+} cmpCmdSpContLockByRootTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_TCI_RSP Response
+ * @{ */
+
+/** SpContLockByRoot TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+} cmpRspSpContLockByRootTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_TCI \
+ MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_TCI_CMD Command
+ * @{ */
+
+/** SpContUnlockByRoot TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+} cmpCmdSpContUnlockByRootTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_TCI_RSP Response
+ * @{ */
+
+/** SpContUnlockByRoot TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+} cmpRspSpContUnlockByRootTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_TCI \
+ MC_CMP_CMD_SP_CONT_ACTIVATE_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_TCI_CMD Command
+ * @{ */
+
+/** SpContActivate TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdSpContActivateTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_TCI_RSP Response
+ * @{ */
+
+/** SpContActivate TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+} cmpRspSpContActivateTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_TCI \
+ MC_CMP_CMD_SP_CONT_LOCK_BY_SP_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_TCI_CMD Command
+ * @{ */
+
+/** SpContLockBySp TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdSpContLockBySpTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_TCI_RSP Response
+ * @{ */
+
+/** SpContLockBySp TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+} cmpRspSpContLockBySpTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_TCI \
+ MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_TCI_CMD Command
+ * @{ */
+
+/** SpContUnlockBySp TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdSpContUnlockBySpTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_TCI_RSP Response
+ * @{ */
+
+/** SpContUnlockBySp TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+} cmpRspSpContUnlockBySpTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_TCI \
+ MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_TCI_CMD Command
+ * @{ */
+
+/** TltContRegisterActivate TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdTltContRegisterActivateTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_TCI_RSP Response
+ * @{ */
+
+/** TltContRegisterActivate TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+ /** Offset of the mapped TltCont with NWd. */
+ cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
+} cmpRspTltContRegisterActivateTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_TCI \
+ MC_CMP_CMD_TLT_CONT_UNREGISTER_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_TCI_CMD Command
+ * @{ */
+
+/** TltContUnregister TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdTltContUnregisterTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_TCI_RSP Response
+ * @{ */
+
+/** TltContUnregister TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+} cmpRspTltContUnregisterTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_TCI \
+ MC_CMP_CMD_TLT_CONT_REGISTER_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_TCI_CMD Command
+ * @{ */
+
+/** TltContRegister TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+} cmpCmdTltContRegisterTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_TCI_RSP Response
+ * @{ */
+
+/** TltContRegister TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped SpCont with NWd. */
+ cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
+ /** Offset of the mapped TltCont with NWd. */
+ cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
+} cmpRspTltContRegisterTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_TCI \
+ MC_CMP_CMD_TLT_CONT_ACTIVATE_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_TCI_CMD Command
+ * @{ */
+
+/** TltContActivate TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+ /** Offset of the mapped TltCont with NWd. */
+ cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
+} cmpCmdTltContActivateTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_TCI_RSP Response
+ * @{ */
+
+/** TltContActivate TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped TltCont with NWd. */
+ cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
+} cmpRspTltContActivateTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_TCI \
+ MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_TCI_CMD Command
+ * @{ */
+
+/** TltContLockBySp TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+ /** Offset of the mapped TltCont with NWd. */
+ cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
+} cmpCmdTltContLockBySpTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_TCI_RSP Response
+ * @{ */
+
+/** TltContLockBySp TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped TltCont with NWd. */
+ cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
+} cmpRspTltContLockBySpTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_TCI \
+ MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_TCI_CMD Command
+ * @{ */
+
+/** TltContUnlockBySp TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+ /** Offset of the mapped TltCont with NWd. */
+ cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
+} cmpCmdTltContUnlockBySpTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_TCI_RSP Response
+ * @{ */
+
+/** TltContUnlockBySp TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped TltCont with NWd. */
+ cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
+} cmpRspTltContUnlockBySpTci_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_TCI \
+ MC_CMP_CMD_TLT_CONT_PERSONALIZE_TCI
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_TCI_CMD Command
+ * @{ */
+
+/** TltContPersonalize TCI command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderTci_t cmdHeader;
+ /** Offset of the mapped TltCont with NWd. */
+ cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
+} cmpCmdTltContPersonalizeTci_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_TCI_RSP Response
+ * @{ */
+
+/** TltContPersonalize TCI response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderTci_t rspHeader;
+ /** Offset of the mapped CMP response with NWd. */
+ cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
+ /** Offset of the mapped PersonalizeData with NWd. */
+ cmpMapOffsetInfo_t cmpTltContPersoMapOffsetInfo;
+} cmpRspTltContPersonalizeTci_t;
+
+/** @} */
+
+/** @} */
+
+#endif // CMP_H_
+
+/** @} */
--- /dev/null
+/** @addtogroup CMP
+ * Content Management Protocol Definitions.
+ *
+ * The content management protocol (CMP) is based on the trustlet control
+ * interface (TCI) and CMP mapped interfaces. It defines commands/responses with
+ * the content management trustlet (TlCm).
+ *
+ * @{
+ *
+ * @file
+ * CMP mapped global definitions.
+ * Various components need access to (sub-)structures defined and used by CMP;
+ * these common definitions are made available through this header file.
+ *
+ * Copyright © Trustonic Limited 2013.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the Trustonic Limited nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CMP_MAP_H_
+#define CMP_MAP_H_
+
+#include "TlCm/3.0/cmp.h"
+
+/** Map CMP GetVersion message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdGetVersion_t cmpCmdGetVersion;
+ /** Map CMP response. */
+ cmpRspGetVersion_t cmpRspGetVersion;
+} cmpMapGetVersion_t;
+
+/** Map CMP GetSuid message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdGetSuid_t cmpCmdGetSuid;
+ /** Map CMP response. */
+ cmpRspGetSuid_t cmpRspGetSuid;
+} cmpMapGetSuid_t;
+
+/** Map CMP GenAuthToken message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdGenAuthToken_t cmpCmdGenAuthToken;
+ /** Map CMP response. */
+ cmpRspGenAuthToken_t cmpRspGenAuthToken;
+} cmpMapGenAuthToken_t;
+
+/** Map CMP command header. */
+typedef struct {
+ /** Command id. */
+ cmpCommandId_t commandId;
+ /** Size of command. */
+ uint32_t len;
+ /** Reserved. */
+ uint32_t reserved;
+} cmpCommandHeaderMap_t;
+
+/** Map CMP response header. */
+typedef struct {
+ /** Return id. */
+ cmpResponseId_t responseId;
+ /** Return code. */
+ cmpReturnCode_t returnCode;
+ /** Size of response. */
+ uint32_t len;
+ /** Reserved. */
+ uint32_t reserved;
+} cmpResponseHeaderMap_t;
+
+/** Map CMP message header. */
+typedef union {
+ /** Map CMP command. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Map CMP response. */
+ cmpResponseHeaderMap_t rspHeader;
+} cmpMapHeader_t;
+
+/** CMP error signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpErrorRsp_t;
+
+/** Map CMP error response. */
+typedef struct {
+ /** Response. */
+ cmpErrorRsp_t rsp;
+} cmpMapError_t;
+
+/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION \
+ MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_CMD Command
+ * @{ */
+
+/** BeginSocAuthentication non signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+} cmpBeginSocAuthenticationCmd_t;
+
+/** BeginSocAuthentication command. */
+typedef struct {
+ /** Command. */
+ cmpBeginSocAuthenticationCmd_t cmd;
+} cmpCmdBeginSocAuthentication_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_RSP Response
+ * @{ */
+
+/** BeginSocAuthentication signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Suid. */
+ mcSuid_t suid;
+ /** SWd authentication random number. */
+ cmpRnd8_t rnd1;
+} cmpBeginSocAuthenticationRspSdata_t;
+
+/** BeginSocAuthentication signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpBeginSocAuthenticationRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpBeginSocAuthenticationRsp_t;
+
+/** BeginSocAuthentication response. */
+typedef struct {
+ /** Response. */
+ cmpBeginSocAuthenticationRsp_t rsp;
+} cmpRspBeginSocAuthentication_t;
+
+/** @} */
+
+/** Map CMP BeginSocAuthentication message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdBeginSocAuthentication_t cmpCmdBeginSocAuthentication;
+ /** Map CMP response. */
+ cmpRspBeginSocAuthentication_t cmpRspBeginSocAuthentication;
+} cmpMapBeginSocAuthentication_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION \
+ MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_CMD Command
+ * @{ */
+
+/** BeginRootAuthentication non signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+} cmpBeginRootAuthenticationCmd_t;
+
+/** BeginRootAuthentication command. */
+typedef struct {
+ /** Command. */
+ cmpBeginRootAuthenticationCmd_t cmd;
+} cmpCmdBeginRootAuthentication_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_RSP Response
+ * @{ */
+
+/** BeginRootAuthentication signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Suid. */
+ mcSuid_t suid;
+ /** SWd authentication random number. */
+ cmpRnd8_t rnd1;
+} cmpBeginRootAuthenticationRspSdata_t;
+
+/** BeginRootAuthentication signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpBeginRootAuthenticationRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpBeginRootAuthenticationRsp_t;
+
+/** BeginRootAuthentication response. */
+typedef struct {
+ /** Response. */
+ cmpBeginRootAuthenticationRsp_t rsp;
+} cmpRspBeginRootAuthentication_t;
+
+/** @} */
+
+/** Map CMP BeginRootAuthentication message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdBeginRootAuthentication_t cmpCmdBeginRootAuthentication;
+ /** Map CMP response. */
+ cmpRspBeginRootAuthentication_t cmpRspBeginRootAuthentication;
+} cmpMapBeginRootAuthentication_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION \
+ MC_CMP_CMD_BEGIN_SP_AUTHENTICATION
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_CMD Command
+ * @{ */
+
+/** BeginSpAuthentication non signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpBeginSpAuthenticationCmd_t;
+
+/** BeginSpAuthentication command. */
+typedef struct {
+ /** Command. */
+ cmpBeginSpAuthenticationCmd_t cmd;
+} cmpCmdBeginSpAuthentication_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_RSP Response
+ * @{ */
+
+/** BeginSpAuthentication signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Suid. */
+ mcSuid_t suid;
+ /** Spid. */
+ mcSpid_t spid;
+ /** SWd authentication random number. */
+ cmpRnd8_t rnd1;
+} cmpBeginSpAuthenticationRspSdata_t;
+
+/** BeginSpAuthentication signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpBeginSpAuthenticationRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpBeginSpAuthenticationRsp_t;
+
+/** BeginSpAuthentication response. */
+typedef struct {
+ /** Response. */
+ cmpBeginSpAuthenticationRsp_t rsp;
+} cmpRspBeginSpAuthentication_t;
+
+/** @} */
+
+/** Map CMP BeginSpAuthentication message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdBeginSpAuthentication_t cmpCmdBeginSpAuthentication;
+ /** Map CMP response. */
+ cmpRspBeginSpAuthentication_t cmpRspBeginSpAuthentication;
+} cmpMapBeginSpAuthentication_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE MC_CMP_CMD_AUTHENTICATE
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE_CMD Command
+ * @{ */
+
+/** Authenticate encrypted data command. */
+typedef struct {
+ /** NWd authentication random number. */
+ cmpRnd8_t rnd2;
+ /** Suid. */
+ mcSuid_t suid;
+ /** EntityId. */
+ uint32_t entityId;
+ /** SWd authentication random number. */
+ cmpRnd8_t rnd1;
+ /** NWd authentication random seed. */
+ cmpRnd32_t k2;
+} cmpAuthMsgEdata_t;
+
+/** Authenticate encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpAuthMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpAuthMsgEdata_t))];
+} cmpAuthCmdEd_t;
+
+/** Authenticate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpAuthCmdEd_t ed;
+} cmpAuthCmdSdata_t;
+
+/** Authenticate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpAuthCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpAuthenticateCmd_t;
+
+/** Authenticate command. */
+typedef struct {
+ /** Command. */
+ cmpAuthenticateCmd_t cmd;
+} cmpCmdAuthenticate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE_RSP Response
+ * @{ */
+
+/** Authenticate encrypted data response. */
+typedef struct {
+ /** NWd authentication random number. */
+ cmpRnd8_t rnd2;
+ /** Suid. */
+ mcSuid_t suid;
+ /** EntityId. */
+ uint32_t entityId;
+ /** SWd authentication random number. */
+ cmpRnd8_t rnd1;
+ /** SWd authentication random seed. */
+ cmpRnd32_t k1;
+} cmpAuthRspEdata_t;
+
+/** Authenticate encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpAuthRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpAuthRspEdata_t))];
+} cmpAuthRspEd_t;
+
+/** Authenticate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpAuthRspEd_t ed;
+} cmpAuthRspSdata_t;
+
+/** Authenticate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpAuthRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpAuthenticateRsp_t;
+
+/** Authenticate response. */
+typedef struct {
+ /** Response. */
+ cmpAuthenticateRsp_t rsp;
+} cmpRspAuthenticate_t;
+
+/** @} */
+
+/** Map CMP Authenticate message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdAuthenticate_t cmpCmdAuthenticate;
+ /** Map CMP response. */
+ cmpRspAuthenticate_t cmpRspAuthenticate;
+} cmpMapAuthenticate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE \
+ MC_CMP_CMD_AUTHENTICATE_TERMINATE
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_CMD Command
+ * @{ */
+
+/** AuthenticateTerminate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+} cmpAuthenticateTerminateCmdSdata_t;
+
+/** AuthenticateTerminate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpAuthenticateTerminateCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpAuthenticateTerminateCmd_t;
+
+/** AuthenticateTerminate command. */
+typedef struct {
+ /** Command. */
+ cmpAuthenticateTerminateCmd_t cmd;
+} cmpCmdAuthenticateTerminate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_RSP Response
+ * @{ */
+
+/** AuthenticateTerminate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+} cmpAuthenticateTerminateRspSdata_t;
+
+/** AuthenticateTerminate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpAuthenticateTerminateRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpAutenticateTerminateRsp_t;
+
+/** AuthenticateTerminate response. */
+typedef struct {
+ /** Response. */
+ cmpAutenticateTerminateRsp_t rsp;
+} cmpRspAuthenticateTerminate_t;
+
+/** @} */
+
+/** Map CMP AuthenticateTerminate message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdAuthenticateTerminate_t cmpCmdAuthenticateTerminate;
+ /** Map CMP response. */
+ cmpRspAuthenticateTerminate_t cmpRspAuthenticateTerminate;
+} cmpMapAuthenticateTerminate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE \
+ MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_CMD Command
+ * @{ */
+
+/** RootContRegisterActivate encrypted data command. */
+typedef struct {
+ /** Root authentication key. */
+ mcSymmetricKey_t kRootAuth;
+} cmpRootRegActMsgEdata_t;
+
+/** RootContRegisterActivate encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpRootRegActMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootRegActMsgEdata_t))];
+} cmpRootRegActCmdEd_t;
+
+/** RootContRegisterActivate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Rootid. */
+ mcRootid_t rootid;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpRootRegActCmdEd_t ed;
+} cmpRootRegActCmdSdata_t;
+
+/** RootContRegisterActivate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpRootRegActCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContRegisterActivateCmd_t;
+
+/** RootContRegisterActivate command. */
+typedef struct {
+ /** Command. */
+ cmpRootContRegisterActivateCmd_t cmd;
+} cmpCmdRootContRegisterActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_RSP Response
+ * @{ */
+
+/** RootContRegisterActivate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Root container secure object size. */
+ uint32_t soRootContLen;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpRootRegActRspSdata_t;
+
+/** RootContRegisterActivate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpRootRegActRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContRegisterActivateRsp_t;
+
+/** RooContRegisterActivate response. */
+typedef struct {
+ /** Response. */
+ cmpRootContRegisterActivateRsp_t rsp;
+} cmpRspRootContRegisterActivate_t;
+
+/** @} */
+
+/** Map CMP RootContRegisterActivate message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdRootContRegisterActivate_t cmpCmdRootContRegisterActivate;
+ /** Map CMP response. */
+ cmpRspRootContRegisterActivate_t cmpRspRootContRegisterActivate;
+} cmpMapRootContRegisterActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER \
+ MC_CMP_CMD_ROOT_CONT_UNREGISTER
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_CMD Command
+ * @{ */
+
+/** RootContUnregister encrypted data command. */
+typedef struct {
+ /** Suid. */
+ mcSuid_t suid;
+} cmpRootUnregMsgEdata_t;
+
+/** RootContUnregister encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpRootUnregMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootUnregMsgEdata_t))];
+} cmpRootUnregCmdEd_t;
+
+/** RootContUnregister signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpRootUnregCmdEd_t ed;
+} cmpRootUnregCmdSdata_t;
+
+/** RootContUnregister signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpRootUnregCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContUnregisterCmd_t;
+
+/** RootContUnregister command. */
+typedef struct {
+ /** Command. */
+ cmpRootContUnregisterCmd_t cmd;
+} cmpCmdRootContUnregister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_RSP Response
+ * @{ */
+
+/** RootContUnregister encrypted data response. */
+typedef struct {
+ /** Suid. */
+ mcSuid_t suid;
+} cmpRootUnregRspEdata_t;
+
+/** RootContUnregister encrypted and padded data response. */
+typedef struct {
+ /** Encrypted data. */
+ cmpRootUnregRspEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootUnregRspEdata_t))];
+} cmpRootUnregRspEd_t;
+
+/** RootContUnregister signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpRootUnregRspEd_t ed;
+} cmpRootUnregRspSdata_t;
+
+/** RootContUnregister signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpRootUnregRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContUnregisterRsp_t;
+
+/** RootContUnregister response. */
+typedef struct {
+ /** Response. */
+ cmpRootContUnregisterRsp_t rsp;
+} cmpRspRootContUnregister_t;
+
+/** @} */
+
+/** Map CMP RootContUnregister message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdRootContUnregister_t cmpCmdRootContUnregister;
+ /** Map CMP response. */
+ cmpRspRootContUnregister_t cmpRspRootContUnregister;
+} cmpMapRootContUnregister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT \
+ MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_CMD Command
+ * @{ */
+
+/** RootContLockByRoot signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+} cmpRootLockByRootCmdSdata_t;
+
+/** RootContLockByRoot signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpRootLockByRootCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContLockByRootCmd_t;
+
+/** RootContLockByRoot command. */
+typedef struct {
+ /** Command. */
+ cmpRootContLockByRootCmd_t cmd;
+} cmpCmdRootContLockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_RSP Response
+ * @{ */
+
+/** RootContLockByRoot signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Root container secure object size. */
+ uint32_t soRootContLen;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpRootLockByRootRspSdata_t;
+
+/** RootContLockByRoot signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpRootLockByRootRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContLockByRootRsp_t;
+
+/** RootContLockByRoot response. */
+typedef struct {
+ cmpRootContLockByRootRsp_t rsp;
+} cmpRspRootContLockByRoot_t;
+
+/** @} */
+
+/** Map CMP RootContLockByRoot message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdRootContLockByRoot_t cmpCmdRootContLockByRoot;
+ /** Map CMP response. */
+ cmpRspRootContLockByRoot_t cmpRspRootContLockByRoot;
+} cmpMapRootContLockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT \
+ MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_CMD Command
+ * @{ */
+
+/** RootContUnlockByRoot signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+} cmpRootUnlockByRootCmdSdata_t;
+
+/** RootContUnlockByRoot signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpRootUnlockByRootCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContUnlockByRootCmd_t;
+
+/** RootContUnlockByRoot command. */
+typedef struct {
+ /** Command. */
+ cmpRootContUnlockByRootCmd_t cmd;
+} cmpCmdRootContUnlockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_RSP Response
+ * @{ */
+
+/** RootContUnlockByRoot signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Root container secure object size. */
+ uint32_t soRootContLen;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpRootUnlockByRootRspSdata_t;
+
+/** RootContUnlockByRoot signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpRootUnlockByRootRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpRootContUnlockByRootRsp_t;
+
+/** RootContUnlockByRoot response. */
+typedef struct {
+ /** Response. */
+ cmpRootContUnlockByRootRsp_t rsp;
+} cmpRspRootContUnlockByRoot_t;
+
+/** @} */
+
+/** Map CMP RootContUnlockByRoot message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdRootContUnlockByRoot_t cmpCmdRootContUnlockByRoot;
+ /** Map CMP response. */
+ cmpRspRootContUnlockByRoot_t cmpRspRootContUnlockByRoot;
+} cmpMapRootContUnlockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE \
+ MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_CMD Command
+ * @{ */
+
+/** SpContRegisterActivate encrypted data command. */
+typedef struct {
+ /** Sp authentication key. */
+ mcSymmetricKey_t kSpAuth;
+} cmpSpRegActMsgEdata_t;
+
+/** SpContRegisterActivate encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpRegActMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegActMsgEdata_t))];
+} cmpSpRegActCmdEd_t;
+
+/** SpContRegisterActivate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpSpRegActCmdEd_t ed;
+} cmpSpRegActCmdSdata_t;
+
+/** SpContRegisterActivate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpRegActCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContRegisterActivateCmd_t;
+
+/** SpContRegisterActivate command. */
+typedef struct {
+ /** Command. */
+ cmpSpContRegisterActivateCmd_t cmd;
+} cmpCmdSpContRegisterActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_RSP Response
+ * @{ */
+
+/** SpContRegisterActivate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Root container secure object size. */
+ uint32_t soRootContLen;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+ /** Sp container secure object size. */
+ uint32_t soSpContLen;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpRegActRspSdata_t;
+
+/** SpContRegisterActivate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpRegActRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContRegisterActivateRsp_t;
+
+/** SpContRegisterActivate response. */
+typedef struct {
+ /** Response. */
+ cmpSpContRegisterActivateRsp_t rsp;
+} cmpRspSpContRegisterActivate_t;
+
+/** @} */
+
+/** Map CMP SpContRegisterActivate message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdSpContRegisterActivate_t cmpCmdSpContRegisterActivate;
+ /** Map CMP response. */
+ cmpRspSpContRegisterActivate_t cmpRspSpContRegisterActivate;
+} cmpMapSpContRegisterActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER \
+ MC_CMP_CMD_SP_CONT_UNREGISTER
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_CMD Command
+ * @{ */
+
+/** SpContUnregister signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpSpContUnregCmdSdata_t;
+
+/** SpContUnregister signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpContUnregCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnregisterCmd_t;
+
+/** SpContUnregister command. */
+typedef struct {
+ /** Command. */
+ cmpSpContUnregisterCmd_t cmd;
+} cmpCmdSpContUnregister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_RSP Response
+ * @{ */
+
+/** SpContUnregister signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Root container secure object size. */
+ uint32_t soRootContLen;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+} cmpSpContUnregRspSdata_t;
+
+/** SpContUnregister signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpContUnregRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnregisterRsp_t;
+
+/** SpContUnregister response. */
+typedef struct {
+ /** Response. */
+ cmpSpContUnregisterRsp_t rsp;
+} cmpRspSpContUnregister_t;
+
+/** @} */
+
+/** Map CMP SpContUnregister message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdSpContUnregister_t cmpCmdSpContUnregister;
+ /** Map CMP response. */
+ cmpRspSpContUnregister_t cmpRspSpContUnregister;
+} cmpMapSpContUnregister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER \
+ MC_CMP_CMD_SP_CONT_REGISTER
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_CMD Command
+ * @{ */
+
+/** SpContRegister encrypted data command. */
+typedef struct {
+ /** Sp authentication key. */
+ mcSymmetricKey_t kSpAuth;
+} cmpSpRegisterMsgEdata_t;
+
+/** SpContRegister encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpRegisterMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegisterMsgEdata_t))];
+} cmpSpRegisterCmdEd_t;
+
+/** SpContRegister signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpSpRegisterCmdEd_t ed;
+} cmpSpRegisterCmdSdata_t;
+
+/** SpContRegister signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpRegisterCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContRegisterCmd_t;
+
+/** SpContRegister command. */
+typedef struct {
+ /** Command. */
+ cmpSpContRegisterCmd_t cmd;
+} cmpCmdSpContRegister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_RSP Response
+ * @{ */
+
+/** SpContRegister signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Root container secure object size. */
+ uint32_t soRootContLen;
+ /** Root container secure object. */
+ mcSoRootCont_t soRootCont;
+ /** Sp container secure object size. */
+ uint32_t soSpContLen;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpRegisterRspSdata_t;
+
+/** SpContRegister signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpRegisterRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContRegisterRsp_t;
+
+/** SpContRegister response. */
+typedef struct {
+ /** Response. */
+ cmpSpContRegisterRsp_t rsp;
+} cmpRspSpContRegister_t;
+
+/** @} */
+
+/** Map CMP SpContRegister message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdSpContRegister_t cmpCmdSpContRegister;
+ /** Map CMP response. */
+ cmpRspSpContRegister_t cmpRspSpContRegister;
+} cmpMapSpContRegister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT \
+ MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_CMD Command
+ * @{ */
+
+/** SpContLockByRoot signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpSpLockByRootCmdSdata_t;
+
+/** SpContLockByRoot signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpLockByRootCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContLockByRootCmd_t;
+
+/** SpContLockByRoot command. */
+typedef struct {
+ /** Command. */
+ cmpSpContLockByRootCmd_t cmd;
+} cmpCmdSpContLockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_RSP Response
+ * @{ */
+
+/** SpContLockByRoot signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Sp container secure object size. */
+ uint32_t soSpContLen;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpLockByRootRspSdata_t;
+
+/** SpContLockByRoot signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpLockByRootRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContLockByRootRsp_t;
+
+/** SpContLockByRoot response. */
+typedef struct {
+ /** Response. */
+ cmpSpContLockByRootRsp_t rsp;
+} cmpRspSpContLockByRoot_t;
+
+/** @} */
+
+/** Map CMP SpContLockByRoot message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdSpContLockByRoot_t cmpCmdSpContLockByRoot;
+ /** Map CMP response. */
+ cmpRspSpContLockByRoot_t cmpRspSpContLockByRoot;
+} cmpMapSpContLockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT \
+ MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_CMD Command
+ * @{ */
+
+/** SpContUnlockByRoot signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpSpUnlockByRootCmdSdata_t;
+
+/** SpContUnlockByRoot signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpUnlockByRootCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnlockByRootCmd_t;
+
+/** SpContUnlockByRoot command. */
+typedef struct {
+ /** Command. */
+ cmpSpContUnlockByRootCmd_t cmd;
+} cmpCmdSpContUnlockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_RSP Response
+ * @{ */
+
+/** SpContUnlockByRoot signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Sp container secure object size. */
+ uint32_t soSpContLen;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpUnlockByRootRspSdata_t;
+
+/** SpContUnlockByRoot signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpUnlockByRootRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnlockByRootRsp_t;
+
+/** SpContUnlockByRoot response. */
+typedef struct {
+ /** Response. */
+ cmpSpContUnlockByRootRsp_t rsp;
+} cmpRspSpContUnlockByRoot_t;
+
+/** @} */
+
+/** Map CMP SpContUnlockByRoot message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdSpContUnlockByRoot_t cmpCmdSpContUnlockByRoot;
+ /** Map CMP response. */
+ cmpRspSpContUnlockByRoot_t cmpRspSpContUnlockByRoot;
+} cmpMapSpContUnlockByRoot_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE \
+ MC_CMP_CMD_SP_CONT_ACTIVATE
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_CMD Command
+ * @{ */
+
+/** SpContActivate encrypted data command. */
+typedef struct {
+ /** Sp authentication key. */
+ mcSymmetricKey_t kSpAuth;
+} cmpSpActivateMsgEdata_t;
+
+/** SpContActivate encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpSpActivateMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpActivateMsgEdata_t))];
+} cmpSpActivateCmdEd_t;
+
+/** SpContActivate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpSpActivateCmdEd_t ed;
+} cmpSpActivateCmdSdata_t;
+
+/** SpContActivate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpActivateCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContActivateCmd_t;
+
+/** SpContActivate command. */
+typedef struct {
+ /** Command. */
+ cmpSpContActivateCmd_t cmd;
+} cmpCmdSpContActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_RSP Response
+ * @{ */
+
+/** SpContActivate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Sp container secure object size. */
+ uint32_t soSpContLen;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpActivateRspSdata_t;
+
+/** SpContActivate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpActivateRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContActivateRsp_t;
+
+/** SpContActivate response. */
+typedef struct {
+ /** Response. */
+ cmpSpContActivateRsp_t rsp;
+} cmpRspSpContActivate_t;
+
+/** @} */
+
+/** Map CMP SpContActivate message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdSpContActivate_t cmpCmdSpContActivate;
+ /** Map CMP response. */
+ cmpRspSpContActivate_t cmpRspSpContActivate;
+} cmpMapSpContActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP \
+ MC_CMP_CMD_SP_CONT_LOCK_BY_SP
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_CMD Command
+ * @{ */
+
+/** SpContLockBySp signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpSpLockBySpCmdSdata_t;
+
+/** SpContLockBySp signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpLockBySpCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContLockBySpCmd_t;
+
+/** SpContLockBySp command. */
+typedef struct {
+ /** Command. */
+ cmpSpContLockBySpCmd_t cmd;
+} cmpCmdSpContLockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_RSP Response
+ * @{ */
+
+/** SpContLockBySp signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Sp container secure object size. */
+ uint32_t soSpContLen;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpLockBySpRspSdata_t;
+
+/** SpContLockBySp signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpLockBySpRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContLockBySpRsp_t;
+
+/** SpContLockBySp response. */
+typedef struct {
+ /** Response. */
+ cmpSpContLockBySpRsp_t rsp;
+} cmpRspSpContLockBySp_t;
+
+/** @} */
+
+/** Map CMP SpContLockBySp message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdSpContLockBySp_t cmpCmdSpContLockBySp;
+ /** Map CMP response. */
+ cmpRspSpContLockBySp_t cmpRspSpContLockBySp;
+} cmpMapSpContLockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP \
+ MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_CMD Command
+ * @{ */
+
+/** SpContUnlockBySp signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+} cmpSpUnlockBySpCmdSdata_t;
+
+/** SpContUnlockBySp signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpSpUnlockBySpCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnlockBySpCmd_t;
+
+/** SpContUnlockBySp command. */
+typedef struct {
+ /** Command. */
+ cmpSpContUnlockBySpCmd_t cmd;
+} cmpCmdSpContUnlockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_RSP Response
+ * @{ */
+
+/** SpContUnlockBySp signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Sp container secure object size. */
+ uint32_t soSpContLen;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpSpUnlockBySpRspSdata_t;
+
+/** SpContUnlockBySp signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpSpUnlockBySpRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpSpContUnlockBySpRsp_t;
+
+/** SpContUnlockBySp response. */
+typedef struct {
+ /** Response. */
+ cmpSpContUnlockBySpRsp_t rsp;
+} cmpRspSpContUnlockBySp_t;
+
+/** @} */
+
+/** Map CMP SpContUnlockBySp message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdSpContUnlockBySp_t cmpCmdSpContUnlockBySp;
+ /** Map CMP response. */
+ cmpRspSpContUnlockBySp_t cmpRspSpContUnlockBySp;
+} cmpMapSpContUnlockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE \
+ MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_CMD Command
+ * @{ */
+
+/** TltContRegisterActivate encrypted data command. */
+typedef struct {
+ /** Tlt authentication key. */
+ mcSymmetricKey_t kSpTltEnc;
+} cmpTltRegActMsgEdata_t;
+
+/** TltContRegisterActivate encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltRegActMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegActMsgEdata_t))];
+} cmpTltRegActCmdEd_t;
+
+/** TltContRegisterActivate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+ /** Trustlet public key hash. */
+ mcSha256_t skSpTltEnc;
+ /** Minimum trustlet version supported. */
+ mcContVersion_t tltVersion;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpTltRegActCmdEd_t ed;
+} cmpTltRegActCmdSdata_t;
+
+/** TltContRegisterActivate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltRegActCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContRegisterActivateCmd_t;
+
+/** TltContRegisterActivate command. */
+typedef struct {
+ /** Command. */
+ cmpTltContRegisterActivateCmd_t cmd;
+} cmpCmdTltContRegisterActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_RSP Response
+ * @{ */
+
+/** TltContRegisterActivate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Sp container secure object size. */
+ uint32_t soSpContLen;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+ /* TltCont mapping info is in TCI cmpRspTltContRegisterActivateTci */
+ uint32_t soTltContLen;
+ mcSoTltCont_2_1_t soTltCont;
+} cmpTltRegActRspSdata_t;
+
+/** TltContRegisterActivate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltRegActRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContRegisterActivateRsp_t;
+
+/** TltContRegisterActivate response. */
+typedef struct {
+ cmpTltContRegisterActivateRsp_t rsp;
+} cmpRspTltContRegisterActivate_t;
+
+/** @} */
+
+/** Map CMP TltContRegisterActivate message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdTltContRegisterActivate_t cmpCmdTltContRegisterActivate;
+ /** Map CMP response. */
+ cmpRspTltContRegisterActivate_t cmpRspTltContRegisterActivate;
+} cmpMapTltContRegisterActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER \
+ MC_CMP_CMD_TLT_CONT_UNREGISTER
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_CMD Command
+ * @{ */
+
+/** TltContUnregister signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+} cmpTltUnregCmdSdata_t;
+
+/** TltContUnregister signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltUnregCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContUnregisterCmd_t;
+
+/** TltContUnregister command. */
+typedef struct {
+ /** Command. */
+ cmpTltContUnregisterCmd_t cmd;
+} cmpCmdTltContUnregister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_RSP Response
+ * @{ */
+
+/** TltContUnregister signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Sp container secure object size. */
+ uint32_t soSpContLen;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+} cmpTltUnregRspSdata_t;
+
+/** TltContUnregister signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltUnregRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContUnregisterRsp_t;
+
+/** TltContUnregister response. */
+typedef struct {
+ /** Response. */
+ cmpTltContUnregisterRsp_t rsp;
+} cmpRspTltContUnregister_t;
+
+/** @} */
+
+/** Map CMP TltContUnregister message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdTltContUnregister_t cmpCmdTltContUnregister;
+ /** Map CMP response. */
+ cmpRspTltContUnregister_t cmpRspTltContUnregister;
+} cmpMapTltContUnregister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER \
+ MC_CMP_CMD_TLT_CONT_REGISTER
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_CMD Command
+ * @{ */
+
+/** TltContRegister encrypted data command. */
+typedef struct {
+ /** Tlt authentication key. */
+ mcSymmetricKey_t kSpTltEnc;
+} cmpTltRegMsgEdata_t;
+
+/** TltContRegister encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltRegMsgEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegMsgEdata_t))];
+} cmpTltRegCmdEd_t;
+
+/** TltContRegister signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+ /** Trustlet public key hash. */
+ mcSha256_t skSpTltEnc;
+ /** Minimum trustlet version supported. */
+ mcContVersion_t tltVersion;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpTltRegCmdEd_t ed;
+} cmpTltRegCmdSdata_t;
+
+/** TltContRegister signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltRegCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContRegisterCmd_t;
+
+/** TltContRegister command. */
+typedef struct {
+ /** Command. */
+ cmpTltContRegisterCmd_t cmd;
+} cmpCmdTltContRegister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_RSP Response
+ * @{ */
+
+/** TltContRegister signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Sp container secure object size. */
+ uint32_t soSpContLen;
+ /** Sp container secure object. */
+ mcSoSpCont_t soSpCont;
+ /** Tlt container secure object size. */
+ uint32_t soTltContLen;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_1_t soTltCont;
+} cmpTltRegRspSdata_t;
+
+/** TltContRegister signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltRegRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContRegisterRsp_t;
+
+/** TltContRegister response. */
+typedef struct {
+ /** Response. */
+ cmpTltContRegisterRsp_t rsp;
+} cmpRspTltContRegister_t;
+
+/** @} */
+
+/** Map CMP TltContRegister message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdTltContRegister_t cmpCmdTltContRegister;
+ /** Map CMP response. */
+ cmpRspTltContRegister_t cmpRspTltContRegister;
+} cmpMapTltContRegister_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE \
+ MC_CMP_CMD_TLT_CONT_ACTIVATE
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_CMD Command
+ * @{ */
+
+/** TltContActivate signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+} cmpTltActCmdSdata_t;
+
+/** TltContActivate signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltActCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContActivateCmd_t;
+
+/** TltContActivate command. */
+typedef struct {
+ /** Command. */
+ cmpTltContActivateCmd_t cmd;
+} cmpCmdTltContActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_RSP Response
+ * @{ */
+
+/** TltContActivate signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Tlt container secure object size. */
+ uint32_t soTltContLen;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_1_t soTltCont;
+} cmpTltActRspSdata_t;
+
+/** TltContActivate signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltActRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContActivateRsp_t;
+
+/** TltContActivate response. */
+typedef struct {
+ /** Response. */
+ cmpTltContActivateRsp_t rsp;
+} cmpRspTltContActivate_t;
+
+/** @} */
+
+/** Map CMP TltContActivate message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdTltContActivate_t cmpCmdTltContActivate;
+ /** Map CMP response. */
+ cmpRspTltContActivate_t cmpRspTltContActivate;
+} cmpMapTltContActivate_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP \
+ MC_CMP_CMD_TLT_CONT_LOCK_BY_SP
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_CMD Command
+ * @{ */
+
+/** TltContLockBySp signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+} cmpTltLockBySpCmdSdata_t;
+
+/** TltContLockBySp signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltLockBySpCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContLockBySpCmd_t;
+
+/** TltContLockBySp command. */
+typedef struct {
+ /** Command. */
+ cmpTltContLockBySpCmd_t cmd;
+} cmpCmdTltContLockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_RSP Response
+ * @{ */
+
+/** TltContLockBySp signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Tlt container secure object size. */
+ uint32_t soTltContLen;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_1_t soTltCont;
+} cmpTltLockBySpRspSdata_t;
+
+/** TltContLockBySp signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltLockBySpRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContLockBySpRsp_t;
+
+/** TltContLockBySp response. */
+typedef struct {
+ /** Response. */
+ cmpTltContLockBySpRsp_t rsp;
+} cmpRspTltContLockBySp_t;
+
+/** @} */
+
+/** Map CMP TltContLockBySp message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdTltContLockBySp_t cmpCmdTltContLockBySp;
+ /** Map CMP response. */
+ cmpRspTltContLockBySp_t cmpRspTltContLockBySp;
+} cmpMapTltContLockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP \
+ MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_CMD Command
+ * @{ */
+
+/** TltContLockBySp signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+} cmpTltUnlockBySpCmdSdata_t;
+
+/** TltContLockBySp signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltUnlockBySpCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContUnlockBySpCmd_t;
+
+/** TltContUnlockBySp command. */
+typedef struct {
+ /** Command. */
+ cmpTltContUnlockBySpCmd_t cmd;
+} cmpCmdTltContUnlockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_RSP Response
+ * @{ */
+
+/** TltContUnlockBySp signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Tlt container secure object size. */
+ uint32_t soTltContLen;
+ /** Tlt container secure object. */
+ mcSoTltCont_2_1_t soTltCont;
+} cmpTltUnlockBySpRspSdata_t;
+
+/** TltContUnlockBySp signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltUnlockBySpRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContUnlockBySpRsp_t;
+
+/** TltContUnlockBySp response. */
+typedef struct {
+ /** Response. */
+ cmpTltContUnlockBySpRsp_t rsp;
+} cmpRspTltContUnlockBySp_t;
+
+/** @} */
+
+/** Map CMP TltContUnlockBySp message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdTltContUnlockBySp_t cmpCmdTltContUnlockBySp;
+ /** Map CMP response. */
+ cmpRspTltContUnlockBySp_t cmpRspTltContUnlockBySp;
+} cmpMapTltContUnlockBySp_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE \
+ MC_CMP_CMD_TLT_CONT_PERSONALIZE
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_CMD Command
+ * @{ */
+
+/** TltContPersonalize encrypted data command. */
+typedef struct {
+ /** Data. */
+ mcCoDataCont_t dataCont;
+} cmpTltContPersonalizeCmdEdata_t;
+
+/** TltContPersonalize encrypted and padded data command. */
+typedef struct {
+ /** Encrypted data. */
+ cmpTltContPersonalizeCmdEdata_t edata;
+ /** Padding. */
+ uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltContPersonalizeCmdEdata_t))];
+} cmpTltContPersonalizeCmdEd_t;
+
+/** TltContPersonalize signed command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Spid. */
+ mcSpid_t spid;
+ /** Uuid. */
+ mcUuid_t uuid;
+ /** Pid. */
+ mcPid_t pid;
+ /** Encrypted and padded data size. */
+ uint32_t edLen;
+ /** Encrypted and padded data. */
+ cmpTltContPersonalizeCmdEd_t ed;
+} cmpTltContPersonalizeCmdSdata_t;
+
+/** TltContPersonalize signed command and signature. */
+typedef struct {
+ /** Signed command. */
+ cmpTltContPersonalizeCmdSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContPersonalizeCmd_t;
+
+/** TltContPersonalize command. */
+typedef struct {
+ cmpTltContPersonalizeCmd_t cmd;
+} cmpCmdTltContPersonalize_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_RSP Response
+ * @{ */
+
+/** TltContPersonalize signed response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+ /** Data container secure object size. */
+ uint32_t soDataContLen;
+ /** Data container secure object. */
+ mcSoDataCont_t soDataCont;
+} cmpTltContPersonalizeRspSdata_t;
+
+/** TltContPersonalize signed response and signature. */
+typedef struct {
+ /** Signed response. */
+ cmpTltContPersonalizeRspSdata_t sdata;
+ /** Signature. */
+ cmpMac_t mac;
+} cmpTltContPersonalizeRsp_t;
+
+/** TltContPersonalize response. */
+typedef struct {
+ /** Response. */
+ cmpTltContPersonalizeRsp_t rsp;
+} cmpRspTltContPersonalize_t;
+
+/** @} */
+
+/** Map CMP TltContPersonalize message. */
+typedef union {
+ /** Map CMP command. */
+ cmpCmdTltContPersonalize_t cmpCmdTltContPersonalize;
+ /** Map CMP response. */
+ cmpRspTltContPersonalize_t cmpRspTltContPersonalize;
+} cmpMapTltContPersonalize_t;
+
+/** @} */
+
+/** Map CMP messages. */
+typedef union {
+ /** Backward compatible command header. */
+ cmpCommandHeader_t commandHeader;
+ /** Backward compatible response header. */
+ cmpResponseHeader_t responseHeader;
+
+ /** Backward compatible system command GetVersion. */
+ cmpCmdGetVersion_t cmpCmdGetVersion;
+ /** Backward compatible system response GetVersion. */
+ cmpRspGetVersion_t cmpRspGetVersion;
+ /** Backward compatible system command GetSuid. */
+ cmpCmdGetSuid_t cmpCmdGetSuid;
+ /** Backward compatible system response GetSuid. */
+ cmpRspGetSuid_t cmpRspGetSuid;
+ /** Backward compatible system command GenAuthToken. */
+ cmpCmdGenAuthToken_t cmpCmdGenAuthToken;
+ /** Backward compatible system response GenAuthToken. */
+ cmpRspGenAuthToken_t cmpRspGenAuthToken;
+
+ /** Command header. */
+ cmpCommandHeaderMap_t cmdHeader;
+ /** Response header. */
+ cmpResponseHeaderMap_t rspHeader;
+
+ /** Error signed response. */
+ cmpMapError_t cmpMapError;
+
+ /** Authentication command BeginSocAuthentication. */
+ cmpCmdBeginSocAuthentication_t cmpCmdBeginSocAuthentication;
+ /** Authentication response BeginSocAuthentication. */
+ cmpRspBeginSocAuthentication_t cmpRspBeginSocAuthentication;
+ /** Authentication command BeginRootAuthentication. */
+ cmpCmdBeginRootAuthentication_t cmpCmdBeginRootAuthentication;
+ /** Authentication response BeginRootAuthentication. */
+ cmpRspBeginRootAuthentication_t cmpRspBeginRootAuthentication;
+ /** Authentication command BeginSpAuthentication. */
+ cmpCmdBeginSpAuthentication_t cmpCmdBeginSpAuthentication;
+ /** Authentication response BeginSpAuthentication. */
+ cmpRspBeginSpAuthentication_t cmpRspBeginSpAuthentication;
+ /** Authentication command Authenticate. */
+ cmpCmdAuthenticate_t cmpCmdAuthenticate;
+ /** Authentication response Authenticate. */
+ cmpRspAuthenticate_t cmpRspAuthenticate;
+ /** Authentication command AuthenticateTerminate. */
+ cmpCmdAuthenticateTerminate_t cmpCmdAuthenticateTerminate;
+ /** Authentication response AuthenticateTerminate. */
+ cmpRspAuthenticateTerminate_t cmpRspAuthenticateTerminate;
+
+ /** SoC administrative command RootContRegisterActivate. */
+ cmpCmdRootContRegisterActivate_t cmpCmdRootContRegisterActivate;
+ /** SoC administrative response RootContRegisterActivate. */
+ cmpRspRootContRegisterActivate_t cmpRspRootContRegisterActivate;
+
+ /** Root administrative command RootContUnregister. */
+ cmpCmdRootContUnregister_t cmpCmdRootContUnregister;
+ /** Root administrative response RootContUnregister. */
+ cmpRspRootContUnregister_t cmpRspRootContUnregister;
+ /** Root administrative command RootContLockByRoot. */
+ cmpCmdRootContLockByRoot_t cmpCmdRootContLockByRoot;
+ /** Root administrative response RootContLockByRoot. */
+ cmpRspRootContLockByRoot_t cmpRspRootContLockByRoot;
+ /** Root administrative command RootContUnlockByRoot. */
+ cmpCmdRootContUnlockByRoot_t cmpCmdRootContUnlockByRoot;
+ /** Root administrative response RootContUnlockByRoot. */
+ cmpRspRootContUnlockByRoot_t cmpRspRootContUnlockByRoot;
+ /** Root administrative command SpContRegisterActivate. */
+ cmpCmdSpContRegisterActivate_t cmpCmdSpContRegisterActivate;
+ /** Root administrative response SpContRegisterActivate. */
+ cmpRspSpContRegisterActivate_t cmpRspSpContRegisterActivate;
+ /** Root administrative command SpContUnregister. */
+ cmpCmdSpContUnregister_t cmpCmdSpContUnregister;
+ /** Root administrative response SpContUnregister. */
+ cmpRspSpContUnregister_t cmpRspSpContUnregister;
+ /** Root administrative command SpContRegister. */
+ cmpCmdSpContRegister_t cmpCmdSpContRegister;
+ /** Root administrative response SpContRegister. */
+ cmpRspSpContRegister_t cmpRspSpContRegister;
+ /** Root administrative command SpContLockByRoot. */
+ cmpCmdSpContLockByRoot_t cmpCmdSpContLockByRoot;
+ /** Root administrative response SpContLockByRoot. */
+ cmpRspSpContLockByRoot_t cmpRspSpContLockByRoot;
+ /** Root administrative command SpContUnlockByRoot. */
+ cmpCmdSpContUnlockByRoot_t cmpCmdSpContUnlockByRoot;
+ /** Root administrative response SpContUnlockByRoot. */
+ cmpRspSpContUnlockByRoot_t cmpRspSpContUnlockByRoot;
+
+ /** Sp administrative command SpContActivate. */
+ cmpCmdSpContActivate_t cmpCmdSpContActivate;
+ /** Sp administrative response SpContActivate. */
+ cmpRspSpContActivate_t cmpRspSpContActivate;
+ /** Sp administrative command SpContLockBySp. */
+ cmpCmdSpContLockBySp_t cmpCmdSpContLockBySp;
+ /** Sp administrative response SpContLockBySp. */
+ cmpRspSpContLockBySp_t cmpRspSpContLockBySp;
+ /** Sp administrative command SpContUnlockBySp. */
+ cmpCmdSpContUnlockBySp_t cmpCmdSpContUnlockBySp;
+ /** Sp administrative response SpContUnlockBySp. */
+ cmpRspSpContUnlockBySp_t cmpRspSpContUnlockBySp;
+ /** Sp administrative command TltContRegisterActivate. */
+ cmpCmdTltContRegisterActivate_t cmpCmdTltContRegisterActivate;
+ /** Sp administrative response TltContRegisterActivate. */
+ cmpRspTltContRegisterActivate_t cmpRspTltContRegisterActivate;
+ /** Sp administrative command TltContUnregister. */
+ cmpCmdTltContUnregister_t cmpCmdTltContUnregister;
+ /** Sp administrative response TltContUnregister. */
+ cmpRspTltContUnregister_t cmpRspTltContUnregister;
+ /** Sp administrative command TltContRegister. */
+ cmpCmdTltContRegister_t cmpCmdTltContRegister;
+ /** Sp administrative response TltContRegister. */
+ cmpRspTltContRegister_t cmpRspTltContRegister;
+ /** Sp administrative command TltContActivate. */
+ cmpCmdTltContActivate_t cmpCmdTltContActivate;
+ /** Sp administrative response TltContActivate. */
+ cmpRspTltContActivate_t cmpRspTltContActivate;
+ /** Sp administrative command TltContLockBySp. */
+ cmpCmdTltContLockBySp_t cmpCmdTltContLockBySp;
+ /** Sp administrative response TltContLockBySp. */
+ cmpRspTltContLockBySp_t cmpRspTltContLockBySp;
+ /** Sp administrative command TltContUnlockBySp. */
+ cmpCmdTltContUnlockBySp_t cmpCmdTltContUnlockBySp;
+ /** Sp administrative response TltContUnlockBySp. */
+ cmpRspTltContUnlockBySp_t cmpRspTltContUnlockBySp;
+ /** Sp administrative command TltContPersonalize. */
+ cmpCmdTltContPersonalize_t cmpCmdTltContPersonalize;
+ /** Sp administrative response TltContPersonalize. */
+ cmpRspTltContPersonalize_t cmpRspTltContPersonalize;
+} cmpMap_t;
+
+#endif // CMP_MAP_H_
+
+/** @} */
--- /dev/null
+/** @addtogroup CMP
+ * @{
+ * @file
+ * Interface to content management trustlet (TlCm) definitions.
+ *
+ * The TlCm is responsible for implementing content management protocol (CMP)
+ * commands and generating approriate CMP responses in the trustlet control
+ * interface (TCI).
+ *
+ * Copyright © Trustonic Limited 2013.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the Trustonic Limited nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TL_CM_API_H_
+#define TL_CM_API_H_
+
+#include "TlCm/tlCmApiCommon.h"
+#include "TlCm/3.0/cmp.h"
+#include "TlCm/3.0/cmpMap.h"
+
+/** TCI CMP messages. */
+typedef union {
+ /** Command header. */
+ cmpCommandHeaderTci_t commandHeader;
+ /** Response header. */
+ cmpResponseHeaderTci_t responseHeader;
+
+ /** System command GetVersion. */
+ cmpCmdGetVersionTci_t cmpCmdGetVersionTci;
+ /** System response GetVersion. */
+ cmpRspGetVersionTci_t cmpRspGetVersionTci;
+ /** System command GetSuid. */
+ cmpCmdGetSuidTci_t cmpCmdGetSuidTci;
+ /** System response GetSuid. */
+ cmpRspGetSuidTci_t cmpRspGetSuidTci;
+ /** System command GenAuthToken. */
+ cmpCmdGenAuthTokenTci_t cmpCmdGenAuthTokenTci;
+ /** System response GenAuthToken. */
+ cmpRspGenAuthTokenTci_t cmpRspGenAuthTokenTci;
+
+ /** Authentication command BeginSocAuthentication. */
+ cmpCmdBeginSocAuthenticationTci_t cmpCmdBeginSocAuthenticationTci;
+ /** Authentication response BeginSocAuthentication. */
+ cmpRspBeginSocAuthenticationTci_t cmpRspBeginSocAuthenticationTci;
+ /** Authentication command BeginRootAuthentication. */
+ cmpCmdBeginRootAuthenticationTci_t cmpCmdBeginRootAuthenticationTci;
+ /** Authentication response BeginRootAuthentication. */
+ cmpRspBeginRootAuthenticationTci_t cmpRspBeginRootAuthenticationTci;
+ /** Authentication command BeginSpAuthentication. */
+ cmpCmdBeginSpAuthenticationTci_t cmpCmdBeginSpAuthenticationTci;
+ /** Authentication response BeginSpAuthentication. */
+ cmpRspBeginSpAuthenticationTci_t cmpRspBeginSpAuthenticationTci;
+ /** Authentication command Authenticate. */
+ cmpCmdAuthenticateTci_t cmpCmdAuthenticateTci;
+ /** Authentication response Authenticate. */
+ cmpRspAuthenticateTci_t cmpRspAuthenticateTci;
+ /** Authentication command AuthenticateTerminate. */
+ cmpCmdAuthenticateTerminateTci_t cmpCmdAuthenticateTerminateTci;
+ /** Authentication response AuthenticateTerminate. */
+ cmpRspAuthenticateTerminateTci_t cmpRspAuthenticateTerminateTci;
+
+ /** SoC administrative command RootContRegisterActivate. */
+ cmpCmdRootContRegisterActivateTci_t cmpCmdRootContRegisterActivateTci;
+ /** SoC administrative response RootContRegisterActivate. */
+ cmpRspRootContRegisterActivateTci_t cmpRspRootContRegisterActivateTci;
+
+ /** Root administrative command RootContUnregister. */
+ cmpCmdRootContUnregisterTci_t cmpCmdRootContUnregisterTci;
+ /** Root administrative response RootContUnregister. */
+ cmpRspRootContUnregisterTci_t cmpRspRootContUnregisterTci;
+ /** Root administrative command RootContLockByRoot. */
+ cmpCmdRootContLockByRootTci_t cmpCmdRootContLockByRootTci;
+ /** Root administrative response RootContLockByRoot. */
+ cmpRspRootContLockByRootTci_t cmpRspRootContLockByRootTci;
+ /** Root administrative command RootContUnlockByRoot. */
+ cmpCmdRootContUnlockByRootTci_t cmpCmdRootContUnlockByRootTci;
+ /** Root administrative command RootContUnlockByRoot. */
+ cmpRspRootContUnlockByRootTci_t cmpRspRootContUnlockByRootTci;
+ /** Root administrative command SpContRegisterActivate. */
+ cmpCmdSpContRegisterActivateTci_t cmpCmdSpContRegisterActivateTci;
+ /** Root administrative response SpContRegisterActivate. */
+ cmpRspSpContRegisterActivateTci_t cmpRspSpContRegisterActivateTci;
+ /** Root administrative command SpContUnregister. */
+ cmpCmdSpContUnregisterTci_t cmpCmdSpContUnregisterTci;
+ /** Root administrative response SpContUnregister. */
+ cmpRspSpContUnregisterTci_t cmpRspSpContUnregisterTci;
+ /** Root administrative command SpContRegister. */
+ cmpCmdSpContRegisterTci_t cmpCmdSpContRegisterTci;
+ /** Root administrative response SpContRegister. */
+ cmpRspSpContRegisterTci_t cmpRspSpContRegisterTci;
+ /** Root administrative command SpContLockByRoot. */
+ cmpCmdSpContLockByRootTci_t cmpCmdSpContLockByRootTci;
+ /** Root administrative response SpContLockByRoot. */
+ cmpRspSpContLockByRootTci_t cmpRspSpContLockByRootTci;
+ /** Root administrative command SpContUnlockByRoot. */
+ cmpCmdSpContUnlockByRootTci_t cmpCmdSpContUnlockByRootTci;
+ /** Root administrative response SpContUnlockByRoot. */
+ cmpRspSpContUnlockByRootTci_t cmpRspSpContUnlockByRootTci;
+
+ /** Sp administrative command SpContActivate. */
+ cmpCmdSpContActivateTci_t cmpCmdSpContActivateTci;
+ /** Sp administrative response SpContActivate. */
+ cmpRspSpContActivateTci_t cmpRspSpContActivateTci;
+ /** Sp administrative command SpContLockBySp. */
+ cmpCmdSpContLockBySpTci_t cmpCmdSpContLockBySpTci;
+ /** Sp administrative response SpContLockBySp. */
+ cmpRspSpContLockBySpTci_t cmpRspSpContLockBySpTci;
+ /** Sp administrative command SpContUnlockBySp. */
+ cmpCmdSpContUnlockBySpTci_t cmpCmdSpContUnlockBySpTci;
+ /** Sp administrative command SpContUnlockBySp. */
+ cmpRspSpContUnlockBySpTci_t cmpRspSpContUnlockBySpTci;
+ /** Sp administrative command TltContRegisterActivate. */
+ cmpCmdTltContRegisterActivateTci_t cmpCmdTltContRegisterActivateTci;
+ /** Sp administrative response TltContRegisterActivate. */
+ cmpRspTltContRegisterActivateTci_t cmpRspTltContRegisterActivateTci;
+ /** Sp administrative command TltContUnregister. */
+ cmpCmdTltContUnregisterTci_t cmpCmdTltContUnregisterTci;
+ /** Sp administrative response TltContUnregister. */
+ cmpRspTltContUnregisterTci_t cmpRspTltContUnregisterTci;
+ /** Sp administrative command TltContRegister. */
+ cmpCmdTltContRegisterTci_t cmpCmdTltContRegisterTci;
+ /** Sp administrative command TltContRegister. */
+ cmpRspTltContRegisterTci_t cmpRspTltContRegisterTci;
+ /** Sp administrative command TltContActivate. */
+ cmpCmdTltContActivateTci_t cmpCmdTltContActivateTci;
+ /** Sp administrative command TltContActivate. */
+ cmpRspTltContActivateTci_t cmpRspTltContActivateTci;
+ /** Sp administrative command TltContLockBySp. */
+ cmpCmdTltContLockBySpTci_t cmpCmdTltContLockBySpTci;
+ /** Sp administrative response TltContLockBySp. */
+ cmpRspTltContLockBySpTci_t cmpRspTltContLockBySpTci;
+ /** Sp administrative command TltContUnlockBySp. */
+ cmpCmdTltContUnlockBySpTci_t cmpCmdTltContUnlockBySpTci;
+ /** Sp administrative response TltContUnlockBySp. */
+ cmpRspTltContUnlockBySpTci_t cmpRspTltContUnlockBySpTci;
+ /** Sp administrative command TltContPersonalize. */
+ cmpCmdTltContPersonalizeTci_t cmpCmdTltContPersonalizeTci;
+ /** Sp administrative response TltContPersonalize. */
+ cmpRspTltContPersonalizeTci_t cmpRspTltContPersonalizeTci;
+} cmpMessage_t;
+
+/** TCI CMP. */
+typedef struct {
+ /** TCI CMP messages. */
+ cmpMessage_t msg;
+} cmp_t;
+
+#endif // TL_CM_API_H_
+
+/** @} */
--- /dev/null
+/** @addtogroup CMP_COMMON
+ * Common definitions of content management protocols (CMP) supported by the
+ * content management trustlet (TlCm).
+ *
+ * @{
+ *
+ * @file
+ * Common CMP global definitions.
+ * Various components need access to (sub-)structures defined and used by CMP.
+ * These common definitions are made available through this header file.
+ *
+ * Copyright © Trustonic Limited 2013.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the Trustonic Limited nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CMP_COMMON_H_
+#define CMP_COMMON_H_
+
+#include "mcContainer.h"
+#include "mcUuid.h"
+#include "mcVersionInfo.h"
+#include "version.h"
+
+/** Minimum TCI CMP 2.0 size. */
+#define CMP_SIZE 4388
+
+/** Default CMP MAP size. */
+#define CMP_MAP_SIZE 2412
+
+/** CMP version id. */
+typedef uint32_t cmpVersionId_t;
+/** CMP command id. */
+typedef uint32_t cmpCommandId_t;
+/** CMP response id. */
+typedef uint32_t cmpResponseId_t;
+/** CMP return code. */
+typedef uint32_t cmpReturnCode_t;
+
+/** Responses have bit 31 set */
+#define RSP_ID_MASK (1U << 31)
+#define RSP_ID(cmdId) (((uint32_t)(cmdId)) | RSP_ID_MASK)
+#define IS_CMD(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == 0)
+#define IS_RSP(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == RSP_ID_MASK)
+
+/** CMP command header. */
+typedef struct {
+ /** Command id. */
+ cmpCommandId_t commandId;
+} cmpCommandHeader_t;
+
+/** CMP response header. */
+typedef struct {
+ /** Response id (must be command id | RSP_ID_MASK ). */
+ cmpResponseId_t responseId;
+ /** Return code. */
+ cmpReturnCode_t returnCode;
+} cmpResponseHeader_t;
+
+/** Total number of bytes used for HMAC-SHA256 message authentication code. */
+#define CMP_MAC_SIZE 32
+
+/** Message authentication code. */
+typedef struct {
+ /** MAC value. */
+ uint8_t mac[CMP_MAC_SIZE];
+} cmpMac_t;
+
+/** 64-bit random number. */
+typedef struct {
+ /** Random number value. */
+ uint8_t data[8];
+} cmpRnd8_t;
+
+/** 256-bit random number. */
+typedef struct {
+ /** Random number value. */
+ uint8_t data[32];
+} cmpRnd32_t;
+
+/** @defgroup MC_CMP_CMD_GET_VERSION MC_CMP_CMD_GET_VERSION
+ * @{ */
+
+/** Version tags. */
+typedef enum {
+ /** Version tag deprecated. */
+ CMP_VERSION_TAG1 = 0x00000001,
+ /** Version tag. */
+ CMP_VERSION_TAG2 = 0x00000002,
+} cmpVersionTag_t;
+
+/** Version data info for deprecated version tag. */
+typedef struct {
+ /** Version data value. */
+ cmpVersionId_t number;
+} cmpVersionData1_t;
+
+/** Version data info. */
+typedef struct {
+ /** Version data value. */
+ mcVersionInfo_t versionInfo;
+} cmpVersionData2_t;
+
+/** Version data infos. */
+typedef union {
+ /** Version data info deprecated. */
+ cmpVersionData1_t versionData1;
+ /** Version data info. */
+ cmpVersionData2_t versionData2;
+} cmpVersionData_t;
+
+/** @defgroup MC_CMP_CMD_GET_VERSION_CMD Command
+ * @{ */
+
+/** GetVersion command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+} cmpCmdGetVersion_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_GET_VERSION_RSP Response
+ * @{ */
+
+/** GetVersion response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Version tag. */
+ cmpVersionTag_t tag;
+ /** Version data info. */
+ cmpVersionData_t data;
+} cmpRspGetVersion_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_GET_SUID MC_CMP_CMD_GET_SUID
+ * @{ */
+
+/** @defgroup MC_CMP_CMD_GET_SUID_CMD Command
+ * @{ */
+
+/** GetSuid command. */
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+} cmpCmdGetSuid_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_GET_SUID_RSP Response
+ * @{ */
+
+/** GetSuid response. */
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+ /** Suid. */
+ mcSuid_t suid;
+} cmpRspGetSuid_t;
+
+/** @} */
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN MC_CMP_CMD_GENERATE_AUTH_TOKEN
+ * @{ */
+
+/** Block size of the encryption algorithm used for secure messaging. */
+#define CMP_MSG_CRYPTO_BLOCK_SIZE 16
+
+/** Total number of padding bytes required to encrypt data of given size. */
+#define CMP_ED_PADDING(netsize) \
+ (CMP_MSG_CRYPTO_BLOCK_SIZE - (netsize) % CMP_MSG_CRYPTO_BLOCK_SIZE)
+
+/** Total number of bytes used for PSS signature in GENERATE AUTH TOKEN command. */
+#define CMP_GEN_AUTH_TOKEN_PSS_SIZE 256
+
+/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_CMD Command
+ * @{ */
+
+typedef struct {
+ /** Command header. */
+ cmpCommandHeader_t cmdHeader;
+ /** Suid. */
+ mcSuid_t suid;
+ /** Authentication key. */
+ mcSymmetricKey_t kSocAuth;
+ /** Key id. */
+ uint32_t kid;
+} cmpGenAuthTokenCmdSdata_t;
+
+typedef struct {
+ /** Signed data. */
+ cmpGenAuthTokenCmdSdata_t sdata;
+ /** Signature. */
+ uint8_t pssSignature[CMP_GEN_AUTH_TOKEN_PSS_SIZE];
+} cmpGenAuthTokenCmd_t;
+
+/** GenAuthToken command. */
+typedef struct {
+ /** Command. */
+ cmpGenAuthTokenCmd_t cmd;
+} cmpCmdGenAuthToken_t;
+
+/** @} */
+
+/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_RSP Response
+ * @{ */
+
+typedef struct {
+ /** Response header. */
+ cmpResponseHeader_t rspHeader;
+} cmpGenAuthTokenRsp_t;
+
+/** GenAuthToken response. */
+typedef struct {
+ /** Response. */
+ cmpGenAuthTokenRsp_t rsp;
+ /** AuthToken container. */
+ mcSoAuthTokenCont_t soAuthCont;
+} cmpRspGenAuthToken_t;
+
+/** @} */
+
+/** @} */
+
+#endif // CMP_COMMON_H_
+
+/** @} */
--- /dev/null
+/** @addtogroup CMP_COMMON
+ * @{
+ * @file
+ * Common interface definitions to content management trustlet (TlCm).
+ *
+ * The TlCm is responsible for implementing content management protocol (CMP)
+ * commands and generating approriate CMP responses.
+ *
+ * Copyright © Trustonic Limited 2013.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the Trustonic Limited nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TL_CM_API_COMMON_H_
+#define TL_CM_API_COMMON_H_
+
+#include "tlCmError.h"
+
+/** TlCm command ids supported.
+ * @note All command ids must be in range 0 to 0x1D.
+ */
+//lint -esym(756, cmpCommands_t) cmpCommands_t type by itself not used.
+typedef enum cmpCommands_t {
+ MC_CMP_CMD_AUTHENTICATE = 0,
+ MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION = 1,
+ MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION = 2,
+ MC_CMP_CMD_BEGIN_SP_AUTHENTICATION = 3,
+ MC_CMP_CMD_GENERATE_AUTH_TOKEN = 4,
+ MC_CMP_CMD_GET_VERSION = 5,
+ //MC_CMP_CMD_ROOT_CONT_ACTIVATE = 6,
+ MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT = 7,
+ //MC_CMP_CMD_ROOT_CONT_REGISTER = 8,
+ MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE = 9,
+ MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT = 10,
+ MC_CMP_CMD_ROOT_CONT_UNREGISTER = 11,
+ MC_CMP_CMD_SP_CONT_ACTIVATE = 12,
+ MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT = 13,
+ MC_CMP_CMD_SP_CONT_LOCK_BY_SP = 14,
+ MC_CMP_CMD_SP_CONT_REGISTER = 15,
+ MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE = 16,
+ MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT = 17,
+ MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP = 18,
+ MC_CMP_CMD_SP_CONT_UNREGISTER = 19,
+ MC_CMP_CMD_TLT_CONT_ACTIVATE = 20,
+ MC_CMP_CMD_TLT_CONT_LOCK_BY_SP = 21,
+ MC_CMP_CMD_TLT_CONT_PERSONALIZE = 22,
+ MC_CMP_CMD_TLT_CONT_REGISTER = 23,
+ MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE = 24,
+ MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP = 25,
+ MC_CMP_CMD_TLT_CONT_UNREGISTER = 26,
+ MC_CMP_CMD_GET_SUID = 27,
+ MC_CMP_CMD_AUTHENTICATE_TERMINATE = 28,
+ MC_CMP_CMD_LAST_ = MC_CMP_CMD_AUTHENTICATE_TERMINATE,
+} cmpCommands_t;
+
+/** TlCm exit code: TlCm exited with error. */
+#define EXIT_ERROR ((uint32_t)(-1))
+
+#endif // TL_CM_API_COMMON_H_
+
+/** @} */
--- /dev/null
+/** @addtogroup CMP_COMMON
+ * @{
+ *
+ * @file
+ * Content management trustlet (TlCm) error return code definitions.
+ * Definition of all possible TlCm error return codes.
+ *
+ * Copyright © Trustonic Limited 2013.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the Trustonic Limited nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TL_CM_ERROR_H_
+#define TL_CM_ERROR_H_
+
+/** No error. */
+#define SUCCESSFUL 0x00000000
+
+/** Error unknown command. */
+#define RET_ERR_EXT_UNKNOWN_COMMAND 0xE0000000
+/** Error security status not satified. */
+#define RET_ERR_EXT_SECURITY_STATUS_NOT_SATISFIED 0xE0000010
+/** Error secure messaging failed. */
+#define RET_ERR_EXT_SECURE_MESSAGING_FAILED 0xE0000020
+/** Error incorrect parameters. */
+#define RET_ERR_EXT_INCORRECT_PARAMETERS 0xE0000030
+/** Error referenced data invalid. */
+#define RET_ERR_EXT_REFERENCED_DATA_INVALID 0xE0000040
+/** Error referenced data not found. */
+#define RET_ERR_EXT_REFERENCED_DATA_NOT_FOUND 0xE0000050
+/** Error method blocked. */
+#define RET_ERR_EXT_METHOD_BLOCKED 0xE0000060
+/** Error conditions of use not satified. */
+#define RET_ERR_EXT_CONDITIONS_OF_USE_NOT_SATISFIED 0xE0000070
+/** Error container already registred error. */
+#define RET_ERR_EXT_ALREADY_REGISTERED 0xE0000090
+/** Error container already activated. */
+#define RET_ERR_EXT_ALREADY_ACTIVATED 0xE00000A0
+/** Error container not registred. */
+#define RET_ERR_EXT_NOT_REGISTERED 0xE00000B0
+/** Error container not activated. */
+#define RET_ERR_EXT_NOT_ACTIVATED 0xE00000C0
+/** Error container full. */
+#define RET_ERR_EXT_CONTAINER_FULL 0xE00000D0
+/** Error container not locked. */
+#define RET_ERR_EXT_NOT_LOCKED 0xE00000E0
+/** Error container locked. */
+#define RET_ERR_EXT_LOCKED 0xE00000F0
+/** Error container already locked. */
+#define RET_ERR_EXT_ALREADY_LOCKED 0xE0000100
+
+/** Internal error. */
+#define RET_ERR_EXT_INTERNAL_ERROR 0xE0001000
+/** Mapped allocation size error. */
+#define RET_ERR_EXT_SIZE 0xE0002000
+
+/** Unspecified error. */
+#define RET_ERR_EXT_UNSPECIFIED 0xEEEEEEEE
+
+#endif // TL_CM_ERROR_H_
+
+/** @} */
--- /dev/null
+/** @addtogroup CMP_COMMON
+ * @{
+ * @file
+ * Content management trustlet (TlCm) Uuid definition.
+ *
+ * Copyright © Trustonic Limited 2013.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the Trustonic Limited nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TL_CM_UUID_H
+#define TL_CM_UUID_H
+
+/** Uuid of TlCm. */
+#define TL_CM_UUID { { 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
+
+#endif // TL_CM_UUID_H
+
+/** @} */
--- /dev/null
+/** @addtogroup CMP_COMMON
+ * @{
+ * @file
+ * Content management trustlet (TlCm) version definition.
+ *
+ * Copyright © Trustonic Limited 2013.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the Trustonic Limited nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CMP_VERSION_H_
+#define CMP_VERSION_H_
+
+/** Latest supported CMP major version number. */
+#define CMP_VERSION_MAJOR 3
+/** Latest supported CMP minor version number. */
+#define CMP_VERSION_MINOR 0
+
+#endif // CMP_VERSION_H_
+
+/** @} */
--- /dev/null
+/** @addtogroup MC_CONTAINER mcContainer - Containers for MobiCore Content Management.
+ * @ingroup MC_DATA_TYPES
+ * @{
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef MC_CONTAINER_H_
+#define MC_CONTAINER_H_
+
+#include <stdint.h>
+
+#include "mcRootid.h"
+#include "mcSpid.h"
+#include "mcUuid.h"
+#include "mcSo.h"
+#include "mcSuid.h"
+
+/** Support for trustlet container 2.1 */
+#define CONTAINER_FORMAT_TL21 1
+
+#define CONTAINER_VERSION_MAJOR 2
+/** Support for the old format */
+#ifdef CONTAINER_FORMAT_TL21
+#define CONTAINER_VERSION_MINOR 1
+#else
+#define CONTAINER_VERSION_MINOR 0
+#endif
+
+#define MC_CONT_SYMMETRIC_KEY_SIZE 32
+#define MC_CONT_PUBLIC_KEY_SIZE 320
+#define MC_CONT_CHILDREN_COUNT 16
+#define MC_DATA_CONT_MAX_DATA_SIZE 2048
+#define MC_TLT_CODE_HASH_SIZE 32
+
+#define MC_BYTES_TO_WORDS(bytes) ( (bytes) / sizeof(uint32_t) )
+#define MC_ENUM_32BIT_SPACER ((int32_t)-1)
+
+typedef uint32_t mcContVersion_t;
+
+/** Personalization Data ID. */
+typedef struct {
+ uint32_t data;
+} mcPid_t;
+
+typedef struct {
+ uint32_t keydata[MC_BYTES_TO_WORDS(MC_CONT_SYMMETRIC_KEY_SIZE)];
+} mcSymmetricKey_t;
+
+typedef struct {
+ uint32_t keydata[MC_BYTES_TO_WORDS(MC_CONT_PUBLIC_KEY_SIZE)];
+} mcPublicKey_t;
+
+typedef mcSpid_t spChild_t[MC_CONT_CHILDREN_COUNT];
+
+typedef mcUuid_t mcUuidChild_t[MC_CONT_CHILDREN_COUNT];
+
+/** Content management container states. */
+typedef enum {
+ /** Container state unregistered. */
+ MC_CONT_STATE_UNREGISTERED = 0,
+ /** Container is registered. */
+ MC_CONT_STATE_REGISTERED = 1,
+ /** Container is activated. */
+ MC_CONT_STATE_ACTIVATED = 2,
+ /** Container is locked by root. */
+ MC_CONT_STATE_ROOT_LOCKED = 3,
+ /** Container is locked by service provider. */
+ MC_CONT_STATE_SP_LOCKED = 4,
+ /** Container is locked by root and service provider. */
+ MC_CONT_STATE_ROOT_SP_LOCKED = 5,
+ /** Dummy: ensure that enum is 32 bits wide. */
+ MC_CONT_ATTRIB_SPACER = MC_ENUM_32BIT_SPACER
+} mcContainerState_t;
+
+/** Content management container attributes. */
+typedef struct {
+ mcContainerState_t state;
+} mcContainerAttribs_t;
+
+/** Container types. */
+typedef enum {
+ /** SOC container. */
+ CONT_TYPE_SOC = 0,
+ /** Root container. */
+ CONT_TYPE_ROOT,
+ /** Service provider container. */
+ CONT_TYPE_SP,
+ /** Trustlet container. */
+ CONT_TYPE_TLCON,
+ /** Service provider data. */
+ CONT_TYPE_SPDATA,
+ /** Trustlet data. */
+ CONT_TYPE_TLDATA
+} contType_t;
+
+/** SHA256 checksum. */
+typedef struct {
+ uint8_t data[32];
+} mcSha256_t;
+
+/** @defgroup MC_CONTAINER_CRYPTO_OBJECTS Container secrets.
+ * Data that is stored encrypted within the container.
+ * @{ */
+
+/** SoC secret */
+typedef struct {
+ mcSymmetricKey_t kSocAuth;
+} mcCoSocCont_t;
+
+/** */
+typedef struct {
+ mcSymmetricKey_t kRootAuth;
+} mcCoRootCont_t;
+
+/** */
+typedef struct {
+ mcSymmetricKey_t kSpAuth;
+} mcCoSpCont_t;
+
+/** */
+typedef struct {
+ mcSymmetricKey_t kTl;
+} mcCoTltCont_t;
+
+/** */
+typedef struct {
+ uint8_t data[MC_DATA_CONT_MAX_DATA_SIZE];
+} mcCoDataCont_t;
+
+/** */
+typedef union {
+ mcSpid_t spid;
+ mcUuid_t uuid;
+} mcCid_t;
+
+/** @} */
+
+/** @defgroup MC_CONTAINER_CONTAINER_OBJECTS Container definitions.
+ * Container type definitions.
+ * @{ */
+
+/** SoC Container */
+typedef struct {
+ contType_t type;
+ mcContVersion_t version;
+ mcContainerAttribs_t attribs;
+ mcSuid_t suid;
+ // Secrets.
+ mcCoSocCont_t co;
+} mcSocCont_t;
+
+/** */
+typedef struct {
+ contType_t type;
+ mcContVersion_t version;
+ mcContainerAttribs_t attribs;
+ mcSuid_t suid;
+ mcRootid_t rootid;
+ spChild_t children;
+ // Secrets.
+ mcCoRootCont_t co;
+} mcRootCont_t;
+
+/** */
+typedef struct {
+ contType_t type;
+ mcContVersion_t version;
+ mcContainerAttribs_t attribs;
+ mcSpid_t spid;
+ mcUuidChild_t children;
+ // Secrets.
+ mcCoSpCont_t co;
+} mcSpCont_t;
+
+/** */
+typedef struct {
+ contType_t type;
+ mcContVersion_t version;
+ mcContainerAttribs_t attribs;
+ mcSpid_t parent;
+ mcUuid_t uuid;
+ // Secrets.
+ mcCoTltCont_t co;
+} mcTltContCommon_t;
+
+/** */
+typedef struct {
+ mcTltContCommon_t common;
+} mcTltCont_2_0_t;
+
+/** */
+typedef struct {
+ mcTltContCommon_t common;
+ mcSha256_t skSpTltEnc;
+ mcContVersion_t tltVersion;
+} mcTltCont_2_1_t;
+
+/** */
+typedef struct {
+ contType_t type;
+ mcContVersion_t version;
+ mcUuid_t uuid;
+ mcPid_t pid;
+ // Secrets.
+ mcCoDataCont_t co;
+} mcDataCont_t;
+
+/** @} */
+
+/** Helper for finding maximum value */
+#define MC_MAX(x, y) (((x)<(y))?(y):(x))
+
+/** Calculates the total size of the secure object hash and padding for a given
+ * container.
+ * @param contTotalSize Total size of the container (sum of plain and encrypted
+ * parts).
+ * @param contCoSize Size/length of the encrypted container part ("crypto
+ * object").
+ * @return Total size of hash and padding for given container.
+ */
+#define SO_CONT_HASH_AND_PAD_SIZE(contTotalSize, contCoSize) \
+ MC_MAX( MC_SO_SIZE_F21((contTotalSize) - (contCoSize), (contCoSize)) \
+ - sizeof(mcSoHeader_t) - (contTotalSize), \
+ MC_SO_SIZE((contTotalSize) - (contCoSize), (contCoSize)) \
+ - sizeof(mcSoHeader_t) - (contTotalSize) )
+
+/** @defgroup MC_CONTAINER_SECURE_OBJECTS Containers in secure objects.
+ * Secure objects wrapping different containers.
+ * @{ */
+
+/** Authentication token */
+typedef struct {
+ mcSoHeader_t soHeader;
+ mcSocCont_t coSoc;
+ uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcSocCont_t), sizeof(mcCoSocCont_t))];
+} mcSoAuthTokenCont_t;
+
+/** Root container */
+typedef struct {
+ mcSoHeader_t soHeader;
+ mcRootCont_t cont;
+ uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcRootCont_t), sizeof(mcCoRootCont_t))];
+} mcSoRootCont_t;
+
+/** */
+typedef struct {
+ mcSoHeader_t soHeader;
+ mcSpCont_t cont;
+ uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcSpCont_t), sizeof(mcCoSpCont_t))];
+} mcSoSpCont_t;
+
+/** */
+typedef struct {
+ mcSoHeader_t soHeader;
+ mcTltCont_2_0_t cont;
+ uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcTltCont_2_0_t), sizeof(mcCoTltCont_t))];
+} mcSoTltCont_2_0_t;
+
+typedef struct {
+ mcSoHeader_t soHeader;
+ mcTltCont_2_1_t cont;
+ uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcTltCont_2_1_t), sizeof(mcCoTltCont_t))];
+} mcSoTltCont_2_1_t;
+
+#ifdef CONTAINER_FORMAT_TL21
+typedef mcSoTltCont_2_0_t mcSoTltCont_t;
+#else
+typedef mcTltContCommon_t mcTltCont_t;
+
+typedef struct {
+ mcSoHeader_t soHeader;
+ mcTltCont_t cont;
+ uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcTltCont_t), sizeof(mcCoTltCont_t))];
+} mcSoTltCont_t ;
+#endif
+
+/** */
+typedef struct {
+ mcSoHeader_t soHeader;
+ mcDataCont_t cont;
+ uint8_t hashAndPad[SO_CONT_HASH_AND_PAD_SIZE(sizeof(mcDataCont_t), sizeof(mcCoDataCont_t))];
+} mcSoDataCont_t;
+
+/** Trustlet Blob length info */
+typedef struct {
+ uint32_t magic; /**< New blob format magic number*/
+ uint32_t rootContBlobSize; /**< Root container blob size */
+ uint32_t spContBlobSize; /**< SP container blob size */
+ uint32_t tlContBlobSize; /**< Tl container blob size */
+ uint32_t reserved[4]; /**< Reserved for further Use */
+} mcBlobLenInfo_t, *mcBlobLenInfo_ptr;
+
+#define MC_TLBLOBLEN_MAGIC 0x7672746C
+
+/** @} */
+
+#endif // MC_CONTAINER_H_
+
+/** @} */
--- /dev/null
+/**
+ * @file
+ * Driver ID definition.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef RTMDRVID_H_
+#define RTMDRVID_H_
+
+#define MC_DRV_VENDOR_ID_SHIFT (16)
+#define MC_DRV_VENDOR_ID_MASK (0xFFFF << MC_DRV_VENDOR_ID_SHIFT)
+#define MC_DRV_NUMBER_MASK (0x0000FFFF)
+
+/** MobiCore vendor IDs. */
+typedef enum {
+ MC_DRV_VENDOR_ID_GD = 0 << MC_DRV_VENDOR_ID_SHIFT,
+} mcDrvVendorId_t;
+
+/** MobiCore GD driver numbers. */
+typedef enum {
+ MC_DRV_NUMBER_INVALID = 0,
+ MC_DRV_NUMBER_CRYPTO = 1,
+ /** Last GD driver number reserved for pre-installed drivers.
+ * GD driver numbers up to this constant may not be used for loadable drivers. */
+ MC_DRV_NUMBER_LAST_PRE_INSTALLED = 100,
+ TB_DRV_NUMBER_TUI = 0x101,
+ TB_DRV_NUMBER_TPLAY = 0x600,
+} mcDrvNumber_t;
+
+/** MobiCore driver IDs for Trustlets. */
+typedef enum {
+ MC_DRV_ID_INVALID = MC_DRV_VENDOR_ID_GD | MC_DRV_NUMBER_INVALID,
+ MC_DRV_ID_CRYPTO = MC_DRV_VENDOR_ID_GD | MC_DRV_NUMBER_CRYPTO,
+ /** Last GD driver ID reserved for pre-installed drivers.
+ * GD driver IDs up to this constant may not be used for loadable drivers. */
+ MC_DRV_ID_LAST_PRE_INSTALLED = MC_DRV_VENDOR_ID_GD | MC_DRV_NUMBER_LAST_PRE_INSTALLED,
+ TB_DRV_ID_TUI = MC_DRV_VENDOR_ID_GD | TB_DRV_NUMBER_TUI,
+ TB_DRV_ID_TPLAY = MC_DRV_VENDOR_ID_GD | TB_DRV_NUMBER_TPLAY,
+} mcDriverId_t;
+
+#endif /* RTMDRVID_H_ */
--- /dev/null
+/**
+ * @defgroup MCLF MobiCore Load Format
+ *
+ * @defgroup MCLF_VER MCLF Versions
+ * @ingroup MCLF
+ *
+ * @addtogroup MCLF
+ * @{
+ *
+ * MobiCore Load Format declarations.
+ *
+ * Holds the definitions for the layout of MobiCore Trustlet Blob.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+#ifndef MCLOADFORMAT_H_
+#define MCLOADFORMAT_H_
+
+#include "mcUuid.h"
+#include "mcSuid.h"
+#include "mcDriverId.h"
+
+#define MCLF_VERSION_MAJOR 2
+#define MCLF_VERSION_MINOR 4
+#define MCLF_VERSION_MINOR_CURRENT 3
+
+#define MC_SERVICE_HEADER_MAGIC_BE ((uint32_t)('M'|('C'<<8)|('L'<<16)|('F'<<24))) /**< "MCLF" in big endian integer representation */
+#define MC_SERVICE_HEADER_MAGIC_LE ((uint32_t)(('M'<<24)|('C'<<16)|('L'<<8)|'F')) /**< "MCLF" in little endian integer representation */
+#define MC_SERVICE_HEADER_MAGIC_STR "MCLF" /**< "MCLF" as string */
+
+/** @name MCLF flags */
+/*@{*/
+#define MC_SERVICE_HEADER_FLAGS_PERMANENT (1U << 0) /**< Loaded service cannot be unloaded from MobiCore. */
+#define MC_SERVICE_HEADER_FLAGS_NO_CONTROL_INTERFACE (1U << 1) /**< Service has no WSM control interface. */
+#define MC_SERVICE_HEADER_FLAGS_DEBUGGABLE (1U << 2) /**< Service can be debugged. */
+/*@}*/
+
+#if !defined(ADDR_T_DEFINED)
+#define ADDR_T_DEFINED
+typedef void* addr_t; /**< an address, can be physical or virtual */
+#endif // !defined(ADDR_T_DEFINED)
+
+/** Service type.
+ * The service type defines the type of executable.
+ */
+typedef enum {
+ SERVICE_TYPE_ILLEGAL = 0, /**< Service type is invalid. */
+ SERVICE_TYPE_DRIVER = 1, /**< Service is a driver. */
+ SERVICE_TYPE_SP_TRUSTLET = 2, /**< Service is a Trustlet. */
+ SERVICE_TYPE_SYSTEM_TRUSTLET = 3, /**< Service is a system Trustlet. */
+// SERVICE_TYPE_SP_TA = 4, /**< Service is a Trusted Application for t-base 300. */
+} serviceType_t;
+
+/**
+ * Memory types.
+ */
+typedef enum {
+ MCLF_MEM_TYPE_INTERNAL_PREFERRED = 0, /**< If available use internal memory; otherwise external memory. */
+ MCLF_MEM_TYPE_INTERNAL = 1, /**< Internal memory must be used for executing the service. */
+ MCLF_MEM_TYPE_EXTERNAL = 2, /**< External memory must be used for executing the service. */
+} memType_t;
+
+/**
+ * Descriptor for a memory segment.
+ */
+typedef struct {
+ addr_t start; /**< Virtual start address. */
+ uint32_t len; /**< Length of the segment in bytes. */
+} segmentDescriptor_t, *segmentDescriptor_ptr;
+
+/**
+ * MCLF intro for data structure identification.
+ * Must be the first element of a valid MCLF file.
+ */
+typedef struct {
+ uint32_t magic; /**< Header magic value ASCII "MCLF". */
+ uint32_t version; /**< Version of the MCLF header structure. */
+} mclfIntro_t, *mclfIntro_ptr;
+
+/** @} */
+
+
+// Version 2 /////////////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @defgroup MCLF_VER_V2 MCLF Version 32
+ * @ingroup MCLF_VER
+ *
+ * @addtogroup MCLF_VER_V2
+ * @{
+ */
+
+/**
+ * Version 2.1/2.2 MCLF header.
+ */
+typedef struct {
+ mclfIntro_t intro; /**< MCLF header start with the mandatory intro. */
+ uint32_t flags; /**< Service flags. */
+ memType_t memType; /**< Type of memory the service must be executed from. */
+ serviceType_t serviceType; /**< Type of service. */
+
+ uint32_t numInstances; /**< Number of instances which can be run simultaneously. */
+ mcUuid_t uuid; /**< Loadable service unique identifier (UUID). */
+ mcDriverId_t driverId; /**< If the serviceType is SERVICE_TYPE_DRIVER the Driver ID is used. */
+ uint32_t numThreads; /**<
+ * <pre>
+ * <br>Number of threads (N) in a service depending on service type.<br>
+ *
+ * SERVICE_TYPE_SP_TRUSTLET: N = 1
+ * SERVICE_TYPE_SYSTEM_TRUSTLET: N = 1
+ * SERVICE_TYPE_DRIVER: N >= 1
+ * </pre>
+ */
+ segmentDescriptor_t text; /**< Virtual text segment. */
+ segmentDescriptor_t data; /**< Virtual data segment. */
+ uint32_t bssLen; /**< Length of the BSS segment in bytes. MUST be at least 8 byte. */
+ addr_t entry; /**< Virtual start address of service code. */
+ uint32_t serviceVersion; /**< Version of the interface the driver exports. */
+
+// These should be put on next MCLF update:
+// mcSuid_t permittedSuid; /**< Starting 2.3: If nonzero, suid which is allowed to execute binary */
+// uint32_t permittedHwCf; /**< Starting 2.3: If nonzero, hw configuration which is allowed to execute binary */
+
+} mclfHeaderV2_t, *mclfHeaderV2_ptr;
+/** @} */
+
+
+/**
+ * Version 2.3 MCLF header.
+ */
+typedef struct {
+ mclfHeaderV2_t mclfHeaderV2;
+ mcSuid_t permittedSuid; /**< Starting 2.3: If nonzero, suid which is allowed to execute binary */
+ uint32_t permittedHwCfg; /**< Starting 2.3: If nonzero, hw configuration which is allowed to execute binary */
+} mclfHeaderV23_t, *mclfHeaderV23_ptr;
+/** @} */
+
+
+/**
+ * Version 2.4 MCLF header.
+ */
+typedef struct {
+ mclfHeaderV23_t mclfHeaderV2;
+ uint32_t gp_level; /**<Starting 2.4: 0 for legacy MobiCore trustlets and 1 for Potato TAs. */
+ uint32_t attestationOffset; /**<Starting 2.4: Offset of attestation data area. */
+
+} mclfHeaderV24_t, *mclfHeaderV24_ptr;
+/** @} */
+
+
+
+/**
+ * Version 2 MCLF text segment header.
+ * Required to be present in MobiCore 1.2 components at address (0x1080).
+ * This extension is initialized already at trustlet compile time,
+ * but may be modified later by configuration tools and by MobiCore at load time.
+ */
+typedef struct {
+ uint32_t version; /**< Version of the TextHeader structure. */
+ uint32_t textHeaderLen; /**< Size of this structure (fixed at compile time) */
+ uint32_t requiredFeat; /**< Flags to indicate features that Mobicore must understand/interprete when loading.
+ Initial value set at compile time.
+ Required always. */
+ addr_t mcLibEntry; /**< Address for McLib entry.
+ Mobicore sets at load time for trustlets / drivers.
+ Required always. */
+ segmentDescriptor_t mcLibData; /**< Segment for McLib data.
+ Set at compile time.
+ Required always. */
+ addr_t mcLibBase; /**< McLib base address.
+ Mobicore sets at load time for trustlets / drivers.
+ Required always. */
+ uint32_t tlApiVers; /**< TlApi version used when building trustlet.
+ Value set at compile time.
+ Required always. */
+ uint32_t drApiVers; /**< DrApi version used when building trustlet.
+ Value set at compile time for drivers. 0 for trustlets.
+ Required always. */
+ addr_t ta_properties; /**< address of _TA_Properties in the TA. */
+} mclfTextHeader_t, *mclfTextHeader_ptr;
+
+// Version 2 ///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * @addtogroup MCLF
+ * @{
+ */
+
+/** MCLF header */
+typedef union {
+ mclfIntro_t intro; /**< Intro for data structure identification. */
+ mclfHeaderV2_t mclfHeaderV2; /**< Version 2 header */
+} mclfHeader_t, *mclfHeader_ptr;
+
+// Version 2.3 changes header definition
+// Above structure is hard-coded into many places.
+// So new changes are made into separate structure.
+#define MCLF_HEADER_SIZE_V23 (0x080)
+
+// Actual (known) length can be calculated using macro
+#define MCLF_HEADER_SIZE(version) ((version)>0x20002?(MCLF_HEADER_SIZE_V23):sizeof(mclfHeader_t))
+
+// This is only minimum size, so nothing below this makes sense.
+#define MCLF_BINARY_MIN_SIZE(version) (MCLF_HEADER_SIZE_V23+sizeof(mclfTextHeader_t))
+
+#endif /* MCLOADFORMAT_H_ */
+
+/** @} */
--- /dev/null
+/**
+ * @addtogroup MC_ROOTID mcRootid - Root container id.
+ *
+ * Global definition of root ID.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ *
+ * @ingroup MC_DATA_TYPES
+ * @{
+ */
+
+#ifndef MC_ROOTID_H_
+#define MC_ROOTID_H_
+
+/** Root Identifier type. */
+typedef uint32_t mcRootid_t;
+
+/** Reserved root id value 1. */
+static const mcRootid_t MC_ROOTID_RESERVED1 = 0;
+
+/** Reserved root id value 2. */
+static const mcRootid_t MC_ROOTID_RESERVED2 = 0xFFFFFFFF;
+
+/** Root id for system applications. */
+static const mcRootid_t MC_ROOTID_SYSTEM = 0xFFFFFFFE;
+
+#endif // MC_ROOTID_H_
+
+/** @} */
--- /dev/null
+/**
+ * @defgroup MC_DATA_TYPES MobiCore generic data types
+ *
+ * @addtogroup MC_SO mcSo - Secure objects definitions.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ *
+ * @ingroup MC_DATA_TYPES
+ * @{
+ *
+ */
+
+#ifndef MC_SO_H_
+#define MC_SO_H_
+
+#include "mcUuid.h"
+#include "mcSpid.h"
+#include "mcRootid.h"
+
+#define SO_USE_VERSION_22 1
+
+#define SO_VERSION_MAJOR 2
+#define SO_VERSION_MINOR 2
+
+#define MC_ENUM_32BIT_SPACER ((int32_t)-1)
+
+/** Secure object type. */
+typedef enum {
+ /** Regular secure object. */
+ MC_SO_TYPE_REGULAR = 0x00000001,
+ /** Dummy to ensure that enum is 32 bit wide. */
+ MC_SO_TYPE_DUMMY = MC_ENUM_32BIT_SPACER,
+} mcSoType_t;
+
+
+/** Secure object context.
+ * A context defines which key to use to encrypt/decrypt a secure object.
+ */
+typedef enum {
+ /** Trustlet context. */
+ MC_SO_CONTEXT_TLT = 0x00000001,
+ /** Service provider context. */
+ MC_SO_CONTEXT_SP = 0x00000002,
+ /** Device context. */
+ MC_SO_CONTEXT_DEVICE = 0x00000003,
+ /** Dummy to ensure that enum is 32 bit wide. */
+ MC_SO_CONTEXT_DUMMY = MC_ENUM_32BIT_SPACER,
+} mcSoContext_t;
+
+/** Secure object lifetime.
+ * A lifetime defines how long a secure object is valid.
+ */
+typedef enum {
+ /** SO does not expire. */
+ MC_SO_LIFETIME_PERMANENT = 0x00000000,
+ /** SO expires on reboot (coldboot). */
+ MC_SO_LIFETIME_POWERCYCLE = 0x00000001,
+ /** SO expires when Trustlet is closed. */
+ MC_SO_LIFETIME_SESSION = 0x00000002,
+ /** Dummy to ensure that enum is 32 bit wide. */
+ MC_SO_LIFETIME_DUMMY = MC_ENUM_32BIT_SPACER,
+} mcSoLifeTime_t;
+
+/** Service provider Trustlet id.
+ * The combination of service provider id and Trustlet UUID forms a unique
+ * Trustlet identifier.
+ */
+typedef struct {
+ /** Service provider id. */
+ mcSpid_t spid;
+ /** Trustlet UUID. */
+ mcUuid_t uuid;
+} tlApiSpTrustletId_t;
+
+/** Service provider Trustlet id with specific RootId.
+ */
+typedef struct {
+ /** Service provider id. */
+ mcSpid_t spid;
+ /** Trustlet UUID. */
+ mcUuid_t uuid;
+ /** Trustlet RootId. */
+ mcRootid_t rootid;
+} tlApiSpTrustletIdEx_t;
+
+/** Secure object header v2.2.
+ * A secure object header introduces a secure object.
+ * Layout of a secure object:
+ * <pre>
+ * <code>
+ *
+ * +--------+------------------+------------------+--------+--------+
+ * | Header | plain-data | encrypted-data | hash | random |
+ * +--------+------------------+------------------+--------+--------+
+ *
+ * /--------/---- plainLen ----/-- encryptedLen --/-- 32 --/-- 16 --/
+ *
+ * /----------------- toBeHashedLen --------------/
+ *
+ * /-- toBeEncryptedLen --/
+ *
+ * /--------------------------- totalSoSize ------------------------/
+ *
+ * </code>
+ * </pre>
+ */
+
+/** Secure object header v2.1.
+ * A secure object header introduces a secure object.
+ * Layout of a secure object:
+ * <pre>
+ * <code>
+ *
+ * +--------+------------------+------------------+--------+--------+---------+
+ * | Header | plain-data | encrypted-data | hash | random | padding |
+ * +--------+------------------+------------------+--------+--------+---------+
+ *
+ * /--------/---- plainLen ----/-- encryptedLen --/-- 24 --/--- 9 --/- 0..15 -/
+ *
+ * /----------------- toBeHashedLen --------------/
+ *
+ * /-- toBeEncryptedLen --/
+ *
+ * /--------------------------- totalSoSize ----------------------------------/
+ *
+ * </code>
+ * </pre>
+ */
+
+/** Secure object header v2.0.
+ * A secure object header introduces a secure object.
+ * Layout of a secure object:
+ * <pre>
+ * <code>
+ *
+ * +--------+------------------+------------------+--------+---------+
+ * | Header | plain-data | encrypted-data | hash | padding |
+ * +--------+------------------+------------------+--------+---------+
+ *
+ * /--------/---- plainLen ----/-- encryptedLen --/-- 32 --/- 1..16 -/
+ *
+ * /----------------- toBeHashedLen --------------/
+ *
+ * /---------- toBeEncryptedLen ---------/
+ *
+ * /--------------------------- totalSoSize -------------------------/
+ *
+ * </code>
+ * </pre>
+ */
+typedef struct {
+ /** Type of secure object. */
+ uint32_t type;
+ /** Secure object version. */
+ uint32_t version;
+ /** Secure object context. */
+ mcSoContext_t context;
+ /** Secure object lifetime. */
+ mcSoLifeTime_t lifetime;
+ /** Producer Trustlet id. */
+ tlApiSpTrustletId_t producer;
+ /** Length of unencrypted user data (after the header). */
+ uint32_t plainLen;
+ /** Length of encrypted user data (after unencrypted data, excl. checksum
+ * and excl. padding bytes). */
+ uint32_t encryptedLen;
+} mcSoHeader_t;
+
+/** Maximum size of the payload (plain length + encrypted length) of a secure object. */
+#define MC_SO_PAYLOAD_MAX_SIZE 1000000
+
+/** Block size of encryption algorithm used for secure objects. */
+#define MC_SO_ENCRYPT_BLOCK_SIZE 16
+
+/** Maximum number of ISO padding bytes. */
+#define MC_SO_MAX_PADDING_SIZE (MC_SO_ENCRYPT_BLOCK_SIZE)
+
+/** Size of hash used for secure objects v2. */
+#define MC_SO_HASH_SIZE 32
+
+/** Size of hash used for secure object v2.1. */
+#define MC_SO21_HASH_SIZE 24
+/** Size of random used for secure objects v2.1. */
+#define MC_SO21_RND_SIZE 9
+
+/** Size of hash used for secure object v2.2. */
+#define MC_SO22_HASH_SIZE 32
+/** Size of random used for secure objects v2.2. */
+#define MC_SO22_RND_SIZE 16
+
+/** Hash size for current generated wrapping */
+#define MC_SO2X_HASH_SIZE MC_SO22_HASH_SIZE
+/** Random size for current generated wrapping */
+#define MC_SO2X_RND_SIZE MC_SO22_RND_SIZE
+
+#define MC_SO_ENCRYPT_PADDED_SIZE_F21(netsize) ( (netsize) + \
+ MC_SO_MAX_PADDING_SIZE - (netsize) % MC_SO_MAX_PADDING_SIZE )
+
+#if SO_USE_VERSION_22
+ // No encryption padding at all.
+#else
+ /** Calculates gross size of cryptogram within secure object including ISO padding bytes. */
+ #define MC_SO_ENCRYPT_PADDED_SIZE(netsize) MC_SO_ENCRYPT_PADDED_SIZE_F21(netsize)
+#endif
+
+
+/** Calculates the total size of a secure object.
+ * @param plainLen Length of plain text part within secure object.
+ * @param encryptedLen Length of encrypted part within secure object (excl.
+ * hash, padding).
+ * @return Total (gross) size of the secure object or 0 if given parameters are
+ * illegal or would lead to a secure object of invalid size.
+ */
+#define MC_SO_SIZE_F22(plainLen, encryptedLen) ( \
+ ((plainLen) + (encryptedLen) < (encryptedLen) || (plainLen) + (encryptedLen) > MC_SO_PAYLOAD_MAX_SIZE) ? 0 : \
+ sizeof(mcSoHeader_t) + (plainLen) + (encryptedLen) +MC_SO22_HASH_SIZE +MC_SO22_RND_SIZE \
+ )
+#define MC_SO_SIZE_F21(plainLen, encryptedLen) ( \
+ ((plainLen) + (encryptedLen) < (encryptedLen) || (plainLen) + (encryptedLen) > MC_SO_PAYLOAD_MAX_SIZE) ? 0 : \
+ sizeof(mcSoHeader_t) +(plainLen) +MC_SO_ENCRYPT_PADDED_SIZE_F21((encryptedLen) +MC_SO_HASH_SIZE) \
+)
+
+#define MC_SO_SIZE(plainLen, encryptedLen) MC_SO_SIZE_F22(plainLen, encryptedLen)
+
+#endif // MC_SO_H_
+
+/** @} */
--- /dev/null
+/**
+ * @addtogroup MC_SPID mcSpid - service provider ID.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ *
+ * @ingroup MC_DATA_TYPES
+ * @{
+ */
+
+#ifndef MC_SPID_H_
+#define MC_SPID_H_
+
+/** Service provider Identifier type. */
+typedef uint32_t mcSpid_t;
+
+/** SPID value used as free marker in root containers. */
+static const mcSpid_t MC_SPID_FREE = 0xFFFFFFFF;
+
+/** Reserved SPID value. */
+static const mcSpid_t MC_SPID_RESERVED = 0;
+
+/** SPID for system applications. */
+static const mcSpid_t MC_SPID_SYSTEM = 0xFFFFFFFE;
+
+/** SPID reserved for tests only */
+static const mcSpid_t MC_SPID_RESERVED_TEST = 0xFFFFFFFD;
+static const mcSpid_t MC_SPID_TRUSTONIC_TEST = 0x4;
+
+#endif // MC_SPID_H_
+
+/** @} */
--- /dev/null
+/**
+ * @addtogroup MC_SUID mcSuid - SoC unique ID.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ *
+ * @ingroup MC_DATA_TYPES
+ * @{
+ */
+
+#ifndef MC_SUID_H_
+#define MC_SUID_H_
+
+/** Length of SUID. */
+#define MC_SUID_LEN 16
+
+/** Platform specific device identifier (serial number of the chip). */
+typedef struct {
+ uint8_t data[MC_SUID_LEN - sizeof(uint32_t)];
+} suidData_t;
+
+/** Soc unique identifier type. */
+typedef struct {
+ uint32_t sipId; /**< Silicon Provider ID to be set during build. */
+ suidData_t suidData;
+} mcSuid_t;
+
+#endif // MC_SUID_H_
+
+/** @} */
--- /dev/null
+/**
+ * @addtogroup MC_UUID mcUuid - Universally Unique Identifier.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ *
+ * @ingroup MC_DATA_TYPES
+ * @{
+ */
+
+#ifndef MC_UUID_H_
+#define MC_UUID_H_
+
+#define UUID_TYPE
+
+#define UUID_LENGTH 16
+/** Universally Unique Identifier (UUID) according to ISO/IEC 11578. */
+typedef struct {
+ uint8_t value[UUID_LENGTH]; /**< Value of the UUID. */
+} mcUuid_t, *mcUuid_ptr;
+
+/** UUID value used as free marker in service provider containers. */
+#define MC_UUID_FREE_DEFINE \
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
+
+static const mcUuid_t MC_UUID_FREE = {
+ MC_UUID_FREE_DEFINE
+};
+
+/** Reserved UUID. */
+#define MC_UUID_RESERVED_DEFINE \
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+
+static const mcUuid_t MC_UUID_RESERVED = {
+ MC_UUID_RESERVED_DEFINE
+};
+
+/** UUID for system applications. */
+#define MC_UUID_SYSTEM_DEFINE \
+ { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE }
+
+static const mcUuid_t MC_UUID_SYSTEM = {
+ MC_UUID_SYSTEM_DEFINE
+};
+
+#endif // MC_UUID_H_
+
+/** @} */
--- /dev/null
+/** @addtogroup MC_RTM
+ * @{
+ * MobiCore Version Helper Macros
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+#include <stdio.h>
+
+//lint -emacro(*,MC_CHECK_VERSION) Disable all warnings for this macro.
+//lint -emacro(*,MC_MAKE_VERSION) Disable all warnings for this macro.
+//lint -emacro(*,MC_GET_MAJOR_VERSION) Disable all warnings for this macro.
+//lint -emacro(*,MC_GET_MINOR_VERSION) Disable all warnings for this macro.
+//lint -emacro(*,MC_GET_MINOR_VERSION) Disable all warnings for this macro.
+//lint -emacro(*,ASSERT_VERSION_IMPLEMENTATION) Disable all warnings for this macro.
+//lint -esym(*,Actual_*) Disable all warnings for these functions.
+
+/** Create a version number given major and minor numbers. */
+#define MC_MAKE_VERSION(major,minor) \
+ ( (((major) & 0xffff) << 16) |\
+ ((minor) & 0xffff))
+
+/** Get major version number from complete version. */
+#define MC_GET_MAJOR_VERSION(version) ((version) >> 16)
+
+/** Get minor version number from complete version. */
+#define MC_GET_MINOR_VERSION(version) ((version) & 0xffff)
+
+// Asserts expression at compile-time (to be used outside a function body).
+#define ASSERT_VERSION_IMPLEMENTATION(comp, versionpart, requiredV, actualV, expression) \
+ extern int Actual_##comp##_##versionpart##_VERSION_##actualV##_does_not_match_required_version_##requiredV[(expression) ? 0:-1]
+
+#define ASSERT_VERSION_EVALUATOR(comp, versionpart, requiredV, actualV, expression) \
+ ASSERT_VERSION_IMPLEMENTATION(comp, versionpart, requiredV, actualV, expression)
+
+#define ASSERT_VERSION(required, comparator, comp, versionpart) \
+ ASSERT_VERSION_EVALUATOR(comp, versionpart, required, comp ##_VERSION_## versionpart, required comparator comp ##_VERSION_## versionpart)
+
+/** Checks at compile-time that an interface version provided by component
+ * 'comp' is identical to the required version of a component using this interface.
+ * Note! This check is useful for components that IMPLEMENT a particular
+ * interface to be alerted of changes to the interface which are likely to
+ * require adaptations in the implementation. */
+#define MC_CHECK_VERSION_EQUALS(comp, major, minor) \
+ ASSERT_VERSION(major, ==, comp, MAJOR); \
+ ASSERT_VERSION(minor, ==, comp, MINOR);
+
+/** Checks at compile-time that an interface version provided by component 'comp' meets the
+ * required version of a component using this interface. */
+#define MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
+ ASSERT_VERSION(majorRequired, ==, comp, MAJOR); \
+ ASSERT_VERSION(minorRequired, <=, comp, MINOR);
+
+/** Version check helper macro for an interface consumer against an interface
+ * provider.
+ * @param comp Name of Interface to check.
+ * @param majorRequired Required major version of interface provider.
+ * @param minorRequired Required minor version of interface provider.
+ * Performs a compile-time interface version check that comp_VERSION_MAJOR
+ * equals majorRequired and that comp_VERSION_MINOR is at least minorRequired.
+ * On success, compilation goes through.
+ * On error, compilation breaks, telling the component that did not match in the
+ * error message.
+ *
+ * Additionally, a function is created:
+ *
+ * checkVersionOk##component(uint32_t version, char** errmsg)
+ *
+ * Compares version against majorRequired and minorRequired.
+ * Additionally, it creates a message string that can be printed out using printf("%s", errmsg).
+ * It returns either only the actual version, or on mismatch, actual and required version.
+ *
+ * @param version[in] component version as returned by layer-specific getVersion.
+ * @param errmsg[out] a message string that contains a log.
+ *
+ */
+#if !defined(NDEBUG)
+#if !defined(TRUSTLET)
+#define MC_CHECK_VERSION(comp, majorRequired, minorRequired) \
+ MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
+ static uint32_t checkVersionOk##comp(uint32_t version, char** errmsg) { \
+ static char msgBuf[100]; \
+ uint32_t major = MC_GET_MAJOR_VERSION(version); \
+ uint32_t minor = MC_GET_MINOR_VERSION(version); \
+ uint32_t ret = 0; \
+ *errmsg = msgBuf; \
+ if ((major == majorRequired) && (minor >= minorRequired)) { \
+ snprintf(msgBuf, sizeof(msgBuf), \
+ #comp " version is %u.%u", major, minor); \
+ ret = 1; \
+ } else { \
+ snprintf(msgBuf, sizeof(msgBuf), \
+ #comp " version error. Got: %u.%u, want >= %u.%u", major, minor, majorRequired, minorRequired); \
+ } \
+ msgBuf[sizeof(msgBuf) - 1] = '\0'; \
+ return ret; \
+ }
+#else /* TRUSTLET */
+#define MC_CHECK_VERSION(comp, majorRequired, minorRequired) \
+ MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
+ static uint32_t checkVersionOk##comp(uint32_t version, char** errmsg) { \
+ uint32_t major = MC_GET_MAJOR_VERSION(version); \
+ uint32_t minor = MC_GET_MINOR_VERSION(version); \
+ *errmsg = NULL; \
+ if ((major == majorRequired) && (minor >= minorRequired)) { \
+ tlDbgPrintf(#comp " version is %u.%u", major, minor); \
+ return 1; \
+ } else { \
+ tlDbgPrintf( \
+ #comp " version error. Got: %u.%u, want >= %u.%u", major, minor, majorRequired, minorRequired); \
+ } \
+ return 0; \
+ }
+#endif /* TRUSTLET */
+#else
+#define MC_CHECK_VERSION(comp, majorRequired, minorRequired) \
+ MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
+ static uint32_t checkVersionOk##comp(uint32_t version, char** errmsg) { \
+ uint32_t major = MC_GET_MAJOR_VERSION(version); \
+ uint32_t minor = MC_GET_MINOR_VERSION(version); \
+ *errmsg = NULL; \
+ if ((major == majorRequired) && (minor >= minorRequired)) { \
+ return 1; \
+ }; \
+ return 0; \
+ }
+#endif
+
+/** Version check helper macro for version checks of a data object version
+ * against an data object consumer.
+ *
+ * @param comp Name of Interface to check.
+ * @param majorRequired Major data object version supported by component.
+ * @param minorRequired Minor data object version supported by component.
+ * Performs a compile-time interface version check that comp_VERSION_MAJOR
+ * equals majorRequired and that comp_VERSION_MINOR is at least minorRequired.
+ * On success, compilation goes through.
+ * On error, compilation breaks, telling the component that did not match in the
+ * error message.
+ *
+ * Additionally, the following function is created:
+ *
+ * checkVersionOkDataObject##component(uint32_t version, char** errmsg)
+ *
+ * This function checks that the data object version is compatible with the
+ * interface version; that is, the major version of the data object must match
+ * exactly and the minor version of the data object MUST BE LESS OR EQUAL to the
+ * required interface version.
+ * Additionally, it creates a message string that can be printed out using printf("%s", errmsg).
+ * It returns either only the actual version, or on mismatch, actual and
+ * provided version.
+ *
+ * @param version[in] Data object version of data object.
+ * @param errmsg[out] a message string that contains a log.
+ *
+ */
+#if !defined(NDEBUG)
+#if !defined(TRUSTLET)
+#define MC_CHECK_DATA_OBJECT_VERSION(comp, majorRequired, minorRequired) \
+ MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
+ static uint32_t checkVersionOkDataObject##comp(uint32_t version, char** errmsg) { \
+ static char msgBuf[100]; \
+ uint32_t major = MC_GET_MAJOR_VERSION(version); \
+ uint32_t minor = MC_GET_MINOR_VERSION(version); \
+ uint32_t ret = 0; \
+ *errmsg = msgBuf; \
+ if ((major == majorRequired) && (minor <= minorRequired)) { \
+ snprintf(msgBuf, sizeof(msgBuf), \
+ #comp " version is %u.%u", major, minor); \
+ ret = 1; \
+ } else { \
+ snprintf(msgBuf, sizeof(msgBuf), \
+ #comp " version error. Got: %u.%u, want <= %u.%u", major, minor, majorRequired, minorRequired); \
+ } \
+ msgBuf[sizeof(msgBuf) - 1] = '\0'; \
+ return ret; \
+ }
+#else /* TRUSTLET */
+#define MC_CHECK_DATA_OBJECT_VERSION(comp, majorRequired, minorRequired) \
+ MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
+ static uint32_t checkVersionOkDataObject##comp(uint32_t version, char** errmsg) { \
+ uint32_t major = MC_GET_MAJOR_VERSION(version); \
+ uint32_t minor = MC_GET_MINOR_VERSION(version); \
+ *errmsg = NULL; \
+ if ((major == majorRequired) && (minor <= minorRequired)) { \
+ tlDbgPrintf(#comp " version is %u.%u", major, minor); \
+ return 1; \
+ } else { \
+ tlDbgPrintf( \
+ #comp " version error. Got: %u.%u, want <= %u.%u", major, minor, majorRequired, minorRequired); \
+ } \
+ return 0; \
+ }
+#endif /* TRUSTLET */
+#else
+#define MC_CHECK_DATA_OBJECT_VERSION(comp, majorRequired, minorRequired) \
+ MC_CHECK_VERSION_STATIC(comp, majorRequired, minorRequired) \
+ static uint32_t checkVersionOkDataObject##comp(uint32_t version, char** errmsg) { \
+ uint32_t major = MC_GET_MAJOR_VERSION(version); \
+ uint32_t minor = MC_GET_MINOR_VERSION(version); \
+ *errmsg = NULL; \
+ if ((major == majorRequired) && (minor <= minorRequired)) { \
+ return 1; \
+ }; \
+ return 0; \
+ }
+#endif
--- /dev/null
+/** @addtogroup MC_RTM
+ * @{
+ * MobiCore Version Information
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef MCVERSIONINFO_H_
+#define MCVERSIONINFO_H_
+
+/** Length of MobiCore product ID string. */
+#define MC_PRODUCT_ID_LEN 64
+
+/** Global MobiCore Version Information.
+ */
+typedef struct {
+ char productId[MC_PRODUCT_ID_LEN]; /** < Product ID of Mobicore; zero-terminated */
+ uint32_t versionMci; /** < Version of Mobicore Control Interface */
+ uint32_t versionSo; /** < Version of Secure Objects */
+ uint32_t versionMclf; /** < Version of MobiCore Load Format */
+ uint32_t versionContainer; /** < Version of MobiCore Container Format */
+ uint32_t versionMcConfig; /** < Version of MobiCore Configuration Block Format */
+ uint32_t versionTlApi; /** < Version of MobiCore Trustlet API Implementation */
+ uint32_t versionDrApi; /** < Version of MobiCore Driver API Implementation */
+ uint32_t versionCmp; /** < Version of Content Management Protocol */
+} mcVersionInfo_t;
+
+#endif /** MCVERSIONINFO_H_ */
--- /dev/null
+# =============================================================================
+#
+# MobiCore Android build components
+#
+# =============================================================================
+
+LOCAL_PATH := $(call my-dir)
+
+# Client Library
+# =============================================================================
+include $(CLEAR_VARS)
+LOCAL_MODULE := libMcClient
+LOCAL_MODULE_TAGS := debug eng optional
+LOCAL_C_INCLUDES += $(GLOBAL_INCLUDES)
+LOCAL_SHARED_LIBRARIES += $(GLOBAL_LIBRARIES) liblog
+
+LOCAL_CFLAGS := -fvisibility=hidden -fvisibility-inlines-hidden
+LOCAL_CFLAGS += -include buildTag.h
+LOCAL_CFLAGS += -DLOG_TAG=\"McClient\"
+LOCAL_CFLAGS += -DTBASE_API_LEVEL=3
+
+# Add new source files here
+LOCAL_SRC_FILES += \
+ ClientLib/Device.cpp \
+ ClientLib/ClientLib.cpp \
+ ClientLib/Session.cpp \
+ Common/CMutex.cpp \
+ Common/Connection.cpp \
+ ClientLib/GP/tee_client_api.cpp
+
+LOCAL_C_INCLUDES +=\
+ $(LOCAL_PATH)/Common \
+ $(LOCAL_PATH)/ClientLib/public \
+ $(LOCAL_PATH)/ClientLib/public/GP \
+ $(LOCAL_PATH)/../common/LogWrapper \
+ $(COMP_PATH_MobiCore)/inc/McLib
+
+LOCAL_EXPORT_C_INCLUDE_DIRS +=\
+ $(COMP_PATH_MobiCore)/inc \
+ $(LOCAL_PATH)/ClientLib/public
+
+LOCAL_CFLAGS += -DLOG_ANDROID
+
+include $(LOCAL_PATH)/Kernel/Android.mk
+
+include $(BUILD_SHARED_LIBRARY)
+
+# Daemon Application
+# =============================================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := mcDriverDaemon
+LOCAL_MODULE_TAGS := debug eng optional
+LOCAL_CFLAGS += -include buildTag.h
+LOCAL_CFLAGS += -DLOG_TAG=\"McDaemon\"
+LOCAL_CFLAGS += -DTBASE_API_LEVEL=3
+LOCAL_C_INCLUDES += $(GLOBAL_INCLUDES)
+LOCAL_SHARED_LIBRARIES += $(GLOBAL_LIBRARIES) libMcClient liblog
+
+include $(LOCAL_PATH)/Daemon/Android.mk
+
+# Common Source files required for building the daemon
+LOCAL_SRC_FILES += Common/CMutex.cpp \
+ Common/Connection.cpp \
+ Common/NetlinkConnection.cpp \
+ Common/CSemaphore.cpp \
+ Common/CThread.cpp
+
+# Includes required for the Daemon
+LOCAL_C_INCLUDES +=\
+ $(LOCAL_PATH)/ClientLib/public \
+ $(LOCAL_PATH)/Common \
+ $(LOCAL_PATH)/../common/LogWrapper
+
+
+# Private Registry components
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/Registry/Public \
+ $(LOCAL_PATH)/Registry
+LOCAL_SRC_FILES += Registry/PrivateRegistry.cpp
+
+# Common components
+include $(LOCAL_PATH)/Kernel/Android.mk
+
+LOCAL_CFLAGS += -DLOG_ANDROID
+
+include $(BUILD_EXECUTABLE)
+
+# Registry Shared Library
+# =============================================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libMcRegistry
+LOCAL_MODULE_TAGS := debug eng optional
+LOCAL_CFLAGS += -DLOG_TAG=\"McRegistry\"
+LOCAL_C_INCLUDES += $(GLOBAL_INCLUDES)
+LOCAL_SHARED_LIBRARIES += $(GLOBAL_LIBRARIES) liblog
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/Common \
+ $(LOCAL_PATH)/Daemon/public \
+ $(LOCAL_PATH)/ClientLib/public \
+ $(LOCAL_PATH)/../common/LogWrapper
+
+# Common Source files required for building the daemon
+LOCAL_SRC_FILES += Common/CMutex.cpp \
+ Common/Connection.cpp \
+ Common/CSemaphore.cpp \
+# Common/CThread.cpp
+
+#LOCAL_LDLIBS := -lthread_db
+
+include $(LOCAL_PATH)/Registry/Android.mk
+
+LOCAL_CFLAGS += -DLOG_ANDROID
+
+include $(BUILD_SHARED_LIBRARY)
--- /dev/null
+# =============================================================================
+#
+# Main build file defining the project modules and their global variables.
+#
+# =============================================================================
+
+# Don't remove this - mandatory
+APP_PROJECT_PATH := $(abspath $(call my-dir))
+
+# The only STL implementation currently working with exceptions
+APP_STL := stlport_static
+
+# Don't optimize for better debugging
+APP_OPTIM := debug
+
+# Application wide Cflags
+GLOBAL_INCLUDES := \
+ $(COMP_PATH_MobiCoreDriverMod)/Public \
+ $(COMP_PATH_MobiCore)/inc \
+ $(COMP_PATH_TlCm)/Public \
+ $(COMP_PATH_TlCm)/Public/TlCm
+
+# Show all warnings
+APP_CFLAGS += -Wall
+
+APP_PLATFORM := android-9
--- /dev/null
+# Copyright (C) 2007 The Android Open Source Project
+#
+# 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.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/ssltest_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/ssltest_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/ssltest_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/ssltest_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/openssl_intermediates $(PRODUCT_OUT)/obj/EXECUTABLES/ssltest_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libssl_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libcrypto_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libssl_static_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libcrypto_static_intermediates)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/*ssl*_intermediates $(PRODUCT_OUT)/obj/*/libssl_*intermediates $(PRODUCT_OUT)/obj/*/libcrypto_*intermediates)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
--- /dev/null
+# =============================================================================
+#
+# Module: libMcClient.so - Client Lib for TLC's
+#
+# =============================================================================
+
+LOCAL_PATH := $(call my-dir)
--- /dev/null
+/** @addtogroup MCD_IMPL_LIB
+ * @{
+ * @file
+ *
+ * <t-base Driver API.
+ *
+ * Functions for accessing <t-base functionality from the normal world.
+ * Handles sessions and notifications via MCI buffer.
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdint.h>
+#ifndef WIN32
+#include <stdbool.h>
+#include <list>
+#include "assert.h"
+#endif
+
+#include "public/MobiCoreDriverApi.h"
+
+#ifndef WIN32
+#include "mc_linux.h"
+#include "Connection.h"
+#include "CMutex.h"
+#include "Device.h"
+#include "mcVersionHelper.h"
+
+#include "Daemon/public/MobiCoreDriverCmd.h"
+#include "Daemon/public/mcVersion.h"
+
+#include "log.h"
+
+#include "Mci/mcimcp.h"
+
+MC_CHECK_VERSION(DAEMON, 0, 2);
+
+/** Notification data structure. */
+typedef struct {
+ uint32_t sessionId; /**< Session ID. */
+ int32_t payload; /**< Additional notification information. */
+} notification_t;
+
+using namespace std;
+
+static list<Device *> devices;
+
+// Forward declarations.
+uint32_t getDaemonVersion(Connection *devCon, uint32_t *version);
+
+static CMutex devMutex;
+//------------------------------------------------------------------------------
+Device *resolveDeviceId(uint32_t deviceId)
+{
+ for (list<Device *>::iterator iterator = devices.begin();
+ iterator != devices.end();
+ ++iterator) {
+ Device *device = (*iterator);
+
+ if (device->deviceId == deviceId) {
+ return device;
+ }
+ }
+ return NULL;
+}
+
+
+//------------------------------------------------------------------------------
+void addDevice(Device *device)
+{
+ devices.push_back(device);
+}
+
+
+//------------------------------------------------------------------------------
+bool removeDevice(uint32_t deviceId)
+{
+ for (list<Device *>::iterator iterator = devices.begin();
+ iterator != devices.end();
+ ++iterator) {
+ Device *device = (*iterator);
+
+ if (device->deviceId == deviceId) {
+ devices.erase(iterator);
+ delete device;
+ return true;
+ }
+ }
+ return false;
+}
+
+//------------------------------------------------------------------------------
+// Parameter checking functions
+// Note that android-ndk renames __func__ to __PRETTY_FUNCTION__
+// see also /prebuilt/ndk/android-ndk-r4/platforms/android-8/arch-arm/usr/include/sys/cdefs.h
+
+#define CHECK_DEVICE(device) \
+ if (NULL == device) \
+ { \
+ LOG_E("Device has not been found"); \
+ mcResult = MC_DRV_ERR_UNKNOWN_DEVICE; \
+ break; \
+ }
+
+#define CHECK_DEVICE_CLOSED(device, deviceId) \
+ if (NULL == device && MC_DEVICE_ID_DEFAULT == deviceId) \
+ { \
+ LOG_E("Device not open"); \
+ mcResult = MC_DRV_ERR_DAEMON_DEVICE_NOT_OPEN; \
+ break; \
+ } else \
+ CHECK_DEVICE(device);
+
+
+
+#define CHECK_NOT_NULL(X) \
+ if (NULL == X) \
+ { \
+ LOG_E("Parameter \""#X "\" is NULL"); \
+ mcResult = MC_DRV_ERR_NULL_POINTER; \
+ break; \
+ }
+
+#define CHECK_SESSION(S,SID) \
+ if (NULL == S) \
+ { \
+ LOG_E("Session %i not found", SID); \
+ mcResult = MC_DRV_ERR_UNKNOWN_SESSION; \
+ break; \
+ }
+
+//------------------------------------------------------------------------------
+// Socket marshaling and checking functions
+#define SEND_TO_DAEMON(CONNECTION, COMMAND, ...) \
+{ \
+ COMMAND ##_struct x = { \
+ COMMAND, \
+ __VA_ARGS__ \
+ }; \
+ int ret = CONNECTION->writeData(&x, sizeof x); \
+ if(ret < 0) { \
+ LOG_E("sending to Daemon failed."); \
+ mcResult = MC_DRV_ERR_SOCKET_WRITE; \
+ break; \
+ } \
+}
+
+#define RECV_FROM_DAEMON(CONNECTION, RSP_STRUCT) \
+{ \
+ int rlen = CONNECTION->readData( \
+ RSP_STRUCT, \
+ sizeof(*RSP_STRUCT)); \
+ if (rlen <= 0) { \
+ LOG_E("reading from Daemon failed"); \
+ mcResult = MC_DRV_ERR_SOCKET_READ; \
+ break; \
+ } \
+ if (rlen != sizeof(*RSP_STRUCT) && rlen != sizeof(mcDrvResponseHeader_t)) {\
+ LOG_E("wrong buffer length %i received from Daemon", rlen); \
+ mcResult = MC_DRV_ERR_SOCKET_LENGTH; \
+ break; \
+ } \
+}
+#endif /* WIN32 */
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcOpenDevice(uint32_t deviceId)
+{
+ mcResult_t mcResult = MC_DRV_OK;
+#ifndef WIN32
+
+ Connection *devCon = NULL;
+
+ devMutex.lock();
+ LOG_I("===%s(%i)===", __FUNCTION__, deviceId);
+
+ do {
+ Device *device = resolveDeviceId(deviceId);
+ if (device != NULL) {
+ LOG_E("Device %d already opened", deviceId);
+ mcResult = MC_DRV_ERR_DEVICE_ALREADY_OPEN;
+ break;
+ }
+
+ // Handle SIGPIPE inside write()
+ // If Daemon crashes and ClientLib writes to named socket,
+ // a sigpipe is send to ClientLib/TLC and kills it.
+ signal(SIGPIPE, SIG_IGN);
+
+ // Open new connection to device
+ devCon = new Connection();
+ if (!devCon->connect(SOCK_PATH)) {
+ LOG_W(" Could not connect to %s socket", SOCK_PATH);
+ mcResult = MC_DRV_ERR_SOCKET_CONNECT;
+ break;
+ }
+
+ // Runtime check of Daemon version.
+ char *errmsg;
+ uint32_t version = 0;
+ mcResult = getDaemonVersion(devCon, &version);
+ if (mcResult != MC_DRV_OK) {
+ break;
+ }
+ if (!checkVersionOkDAEMON(version, &errmsg)) {
+ LOG_E("%s", errmsg);
+ mcResult = MC_DRV_ERR_DAEMON_VERSION;
+ break;
+ }
+ LOG_I(" %s", errmsg);
+
+ // Forward device open to the daemon and read result
+ SEND_TO_DAEMON(devCon, MC_DRV_CMD_OPEN_DEVICE, deviceId);
+
+ RECV_FROM_DAEMON(devCon, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_W(" %s(): Request at Daemon failed, respId=%x ", __FUNCTION__, mcResult);
+ break;
+ }
+
+ // there is no payload to read
+
+ device = new Device(deviceId, devCon);
+ mcResult = device->open("/dev/" MC_USER_DEVNODE);
+ if (mcResult != MC_DRV_OK) {
+ delete device;
+ // devCon is freed in the Device destructor
+ devCon = NULL;
+ LOG_E("Could not open device file: /dev/%s", MC_USER_DEVNODE);
+ break;
+ }
+
+ addDevice(device);
+
+ } while (false);
+
+ devMutex.unlock();
+ if (mcResult != MC_DRV_OK) {
+ if (devCon != NULL)
+ delete devCon;
+ LOG_I(" Device not opened.");
+ } else {
+ LOG_I(" Successfully opened the device.");
+ }
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcCloseDevice(
+ uint32_t deviceId
+)
+{
+ mcResult_t mcResult = MC_DRV_OK;
+#ifndef WIN32
+
+ devMutex.lock();
+ LOG_I("===%s(%i)===", __FUNCTION__, deviceId);
+ do {
+ Device *device = resolveDeviceId(deviceId);
+ // CHECK_DEVICE(device);
+ CHECK_DEVICE_CLOSED(device, deviceId);
+
+ Connection *devCon = device->connection;
+
+ // Check if daemon is still alive
+ if (!devCon->isConnectionAlive()) {
+ removeDevice(deviceId);
+ LOG_E("Daemon is dead removing device");
+ mcResult = MC_DRV_ERR_DAEMON_UNREACHABLE;
+ break;
+ }
+
+ // Return if not all sessions have been closed
+ // TODO-2012-08-31-haenellu: improve check, if device connection is dead, this makes no more sense.
+ if (device->hasSessions()) {
+ LOG_E("Trying to close device while sessions are still pending.");
+ mcResult = MC_DRV_ERR_SESSION_PENDING;
+ break;
+ }
+
+ SEND_TO_DAEMON(devCon, MC_DRV_CMD_CLOSE_DEVICE);
+
+ RECV_FROM_DAEMON(devCon, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_W(" %s(): Request at Daemon failed, respId=%d ", __FUNCTION__, mcResult);
+ break;
+ }
+
+ removeDevice(deviceId);
+
+ } while (false);
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcOpenSession(
+ mcSessionHandle_t *session,
+ const mcUuid_t *uuid,
+ uint8_t *tci,
+ uint32_t len
+)
+{
+ mcResult_t mcResult = MC_DRV_OK;
+#ifndef WIN32
+
+ devMutex.lock();
+ LOG_I("===%s()===", __FUNCTION__);
+
+ BulkBufferDescriptor *bulkBuf = NULL;
+
+ do {
+ uint32_t handle = 0;
+ CHECK_NOT_NULL(session);
+ CHECK_NOT_NULL(uuid);
+
+ if (len > MC_MAX_TCI_LEN) {
+ LOG_E("TCI length is longer than %d", MC_MAX_TCI_LEN);
+ mcResult = MC_DRV_ERR_TCI_TOO_BIG;
+ break;
+ }
+
+ // Get the device associated with the given session
+ Device *device = resolveDeviceId(session->deviceId);
+ CHECK_DEVICE(device);
+
+ Connection *devCon = device->connection;
+
+ // First assume the TCI is a contiguous buffer
+ // Get the physical address of the given TCI
+ CWsm_ptr pWsm = device->findContiguousWsm(tci);
+ if (pWsm == NULL) {
+ if (tci != NULL && len != 0) {
+ // Then assume it's a normal buffer that needs to be mapped
+ mcResult = device->mapBulkBuf(tci, len, &bulkBuf);
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("Registering buffer failed. ret=%x", mcResult);
+ mcResult = MC_DRV_ERR_WSM_NOT_FOUND;
+ break;
+ }
+ handle = bulkBuf->handle;
+ } else if ( len != 0 ) {
+ LOG_E("mcOpenSession(): length is more than allocated TCI");
+ mcResult = MC_DRV_ERR_TCI_GREATER_THAN_WSM;
+ break;
+ }
+ } else {
+ if (pWsm->len < len) {
+ LOG_E("mcOpenSession(): length is more than allocated TCI");
+ mcResult = MC_DRV_ERR_TCI_GREATER_THAN_WSM;
+ break;
+ }
+ handle = pWsm->handle;
+ }
+
+ SEND_TO_DAEMON(devCon, MC_DRV_CMD_OPEN_SESSION,
+ session->deviceId,
+ *uuid,
+ (uintptr_t)(tci) & 0xFFF,
+ (uint32_t)handle,
+ len);
+
+ // Read command response
+ RECV_FROM_DAEMON(devCon, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ // TODO-2012-09-06-haenellu: Remove this code once tests can handle it
+
+ if (MC_DRV_ERROR_MAJOR(mcResult) != MC_DRV_ERR_MCP_ERROR) {
+ LOG_E("Daemon could not open session, responseId %d.", mcResult);
+ } else {
+ uint32_t mcpResult = MC_DRV_ERROR_MCP(mcResult);
+ LOG_E("<t-base reported failing of MC_MCP_CMD_OPEN_SESSION command, mcpResult %d.", mcpResult);
+
+ // IMPROVEMENT-2012-09-03-haenellu: Remove this switch case and use MCP code in tests.
+ switch (mcpResult) {
+ case MC_MCP_RET_ERR_WRONG_PUBLIC_KEY:
+ mcResult = MC_DRV_ERR_WRONG_PUBLIC_KEY;
+ break;
+ case MC_MCP_RET_ERR_CONTAINER_TYPE_MISMATCH:
+ mcResult = MC_DRV_ERR_CONTAINER_TYPE_MISMATCH;
+ break;
+ case MC_MCP_RET_ERR_CONTAINER_LOCKED:
+ mcResult = MC_DRV_ERR_CONTAINER_LOCKED;
+ break;
+ case MC_MCP_RET_ERR_SP_NO_CHILD:
+ mcResult = MC_DRV_ERR_SP_NO_CHILD;
+ break;
+ case MC_MCP_RET_ERR_TL_NO_CHILD:
+ mcResult = MC_DRV_ERR_TL_NO_CHILD;
+ break;
+ case MC_MCP_RET_ERR_UNWRAP_ROOT_FAILED:
+ mcResult = MC_DRV_ERR_UNWRAP_ROOT_FAILED;
+ break;
+ case MC_MCP_RET_ERR_UNWRAP_SP_FAILED:
+ mcResult = MC_DRV_ERR_UNWRAP_SP_FAILED;
+ break;
+ case MC_MCP_RET_ERR_UNWRAP_TRUSTLET_FAILED:
+ mcResult = MC_DRV_ERR_UNWRAP_TRUSTLET_FAILED;
+ break;
+ default:
+ // TODO-2012-09-06-haenellu: Remove line and adapt codes in tests.
+ mcResult = MC_DRV_ERR_MCP_ERROR;
+ break;
+ }
+ }
+ break; // loading of Trustlet failed, unlock mutex and return
+ }
+
+ // read payload
+ mcDrvRspOpenSessionPayload_t rspOpenSessionPayload;
+ RECV_FROM_DAEMON(devCon, &rspOpenSessionPayload);
+
+ // Register session with handle
+ session->sessionId = rspOpenSessionPayload.sessionId;
+
+ LOG_I(" Service is started. Setting up channel for notifications.");
+
+ // Set up second channel for notifications
+ Connection *sessionConnection = new Connection();
+ if (!sessionConnection->connect(SOCK_PATH)) {
+ LOG_E("Could not connect to %s", SOCK_PATH);
+ delete sessionConnection;
+ // Here we know we couldn't connect to the Daemon.
+ // Maybe we should use existing connection to close Trustlet.
+ mcResult = MC_DRV_ERR_SOCKET_CONNECT;
+ break;
+ }
+
+ do {
+ SEND_TO_DAEMON(sessionConnection, MC_DRV_CMD_NQ_CONNECT,
+ session->deviceId,
+ session->sessionId,
+ rspOpenSessionPayload.deviceSessionId,
+ rspOpenSessionPayload.sessionMagic);
+
+ RECV_FROM_DAEMON(sessionConnection, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("CMD_NQ_CONNECT failed, respId=%d", mcResult);
+ break;
+ }
+
+ } while (0);
+ if (mcResult != MC_DRV_OK) {
+ delete sessionConnection;
+ // Here we know we couldn't communicate well with the Daemon.
+ // Maybe we should use existing connection to close Trustlet.
+ break; // unlock mutex and return
+ }
+
+ // there is no payload.
+
+ // Session has been established, new session object must be created
+ Session *sessionObj = device->createNewSession(session->sessionId, sessionConnection);
+ // If the session tci was a mapped buffer then register it
+ if (bulkBuf)
+ sessionObj->addBulkBuf(bulkBuf);
+
+ LOG_I(" Successfully opened session %d.", session->sessionId);
+
+ } while (false);
+
+ if (mcResult != MC_DRV_OK && bulkBuf) {
+ delete bulkBuf;
+ }
+
+// TODO: enable as soon as there are more error codes
+// if (mcResult == MC_DRV_ERR_SOCKET_WRITE || mcResult == MC_DRV_ERR_SOCKET_READ) {
+// LOG_E("Connection is dead, removing device.");
+// removeDevice(session->deviceId);
+// }
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcOpenTrustlet(
+ mcSessionHandle_t *session,
+ mcSpid_t spid,
+ uint8_t *trustlet,
+ uint32_t tlen,
+ uint8_t *tci,
+ uint32_t len
+)
+{
+ mcResult_t mcResult = MC_DRV_OK;
+#ifndef WIN32
+
+ devMutex.lock();
+ LOG_I("===%s()===", __FUNCTION__);
+
+ BulkBufferDescriptor *bulkBuf = NULL;
+
+ do {
+ uint32_t handle = 0;
+ CHECK_NOT_NULL(session);
+ CHECK_NOT_NULL(trustlet);
+ CHECK_NOT_NULL(tci);
+
+ if (len > MC_MAX_TCI_LEN) {
+ LOG_E("TCI length is longer than %d", MC_MAX_TCI_LEN);
+ mcResult = MC_DRV_ERR_TCI_TOO_BIG;
+ break;
+ }
+
+ // Get the device associated with the given session
+ Device *device = resolveDeviceId(session->deviceId);
+ CHECK_DEVICE(device);
+
+ Connection *devCon = device->connection;
+
+ // First assume the TCI is a contiguous buffer
+ // Get the physical address of the given TCI
+ CWsm_ptr pWsm = device->findContiguousWsm(tci);
+ if (pWsm == NULL) {
+ // Then assume it's a normal buffer that needs to be mapped
+ mcResult = device->mapBulkBuf(tci, len, &bulkBuf);
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("Registering buffer failed. ret=%x", mcResult);
+ mcResult = MC_DRV_ERR_WSM_NOT_FOUND;;
+ break;
+ }
+ handle = bulkBuf->handle;
+ } else {
+ if (pWsm->len < len) {
+ LOG_E("mcOpenSession(): length is more than allocated TCI");
+ mcResult = MC_DRV_ERR_TCI_GREATER_THAN_WSM;
+ break;
+ }
+ handle = pWsm->handle;
+ }
+
+ SEND_TO_DAEMON(devCon, MC_DRV_CMD_OPEN_TRUSTLET,
+ session->deviceId,
+ spid,
+ (uint32_t)tlen,
+ (uintptr_t)(tci) & 0xFFF,
+ (uint32_t)handle,
+ len);
+
+ // Send the full trustlet data
+ int ret = devCon->writeData(trustlet, tlen);
+ if (ret < 0) {
+ LOG_E("sending to Daemon failed.");
+ \
+ mcResult = MC_DRV_ERR_SOCKET_WRITE;
+ \
+ break;
+ }
+
+ // Read command response
+ RECV_FROM_DAEMON(devCon, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ // TODO-2012-09-06-haenellu: Remove this code once tests can handle it
+
+ if (MC_DRV_ERROR_MAJOR(mcResult) != MC_DRV_ERR_MCP_ERROR) {
+ LOG_E("Daemon could not open session, responseId %d.", mcResult);
+ } else {
+ uint32_t mcpResult = MC_DRV_ERROR_MCP(mcResult);
+ LOG_E("<t-base reported failing of MC_MCP_CMD_OPEN_SESSION command, mcpResult %d.", mcpResult);
+
+ // IMPROVEMENT-2012-09-03-haenellu: Remove this switch case and use MCP code in tests.
+ switch (mcpResult) {
+ case MC_MCP_RET_ERR_WRONG_PUBLIC_KEY:
+ mcResult = MC_DRV_ERR_WRONG_PUBLIC_KEY;
+ break;
+ case MC_MCP_RET_ERR_CONTAINER_TYPE_MISMATCH:
+ mcResult = MC_DRV_ERR_CONTAINER_TYPE_MISMATCH;
+ break;
+ case MC_MCP_RET_ERR_CONTAINER_LOCKED:
+ mcResult = MC_DRV_ERR_CONTAINER_LOCKED;
+ break;
+ case MC_MCP_RET_ERR_SP_NO_CHILD:
+ mcResult = MC_DRV_ERR_SP_NO_CHILD;
+ break;
+ case MC_MCP_RET_ERR_TL_NO_CHILD:
+ mcResult = MC_DRV_ERR_TL_NO_CHILD;
+ break;
+ case MC_MCP_RET_ERR_UNWRAP_ROOT_FAILED:
+ mcResult = MC_DRV_ERR_UNWRAP_ROOT_FAILED;
+ break;
+ case MC_MCP_RET_ERR_UNWRAP_SP_FAILED:
+ mcResult = MC_DRV_ERR_UNWRAP_SP_FAILED;
+ break;
+ case MC_MCP_RET_ERR_UNWRAP_TRUSTLET_FAILED:
+ mcResult = MC_DRV_ERR_UNWRAP_TRUSTLET_FAILED;
+ break;
+ default:
+ // TODO-2012-09-06-haenellu: Remove line and adapt codes in tests.
+ mcResult = MC_DRV_ERR_MCP_ERROR;
+ break;
+ }
+ }
+ break; // loading of Trustlet failed, unlock mutex and return
+ }
+
+ // read payload
+ mcDrvRspOpenSessionPayload_t rspOpenSessionPayload;
+ RECV_FROM_DAEMON(devCon, &rspOpenSessionPayload);
+
+ // Register session with handle
+ session->sessionId = rspOpenSessionPayload.sessionId;
+
+ LOG_I(" Service is started. Setting up channel for notifications.");
+
+ // Set up second channel for notifications
+ Connection *sessionConnection = new Connection();
+ if (!sessionConnection->connect(SOCK_PATH)) {
+ LOG_E("Could not connect to %s", SOCK_PATH);
+ delete sessionConnection;
+ // Here we know we couldn't connect to the Daemon.
+ // Maybe we should use existing connection to close Trustlet.
+ mcResult = MC_DRV_ERR_SOCKET_CONNECT;
+ break;
+ }
+
+ do {
+ SEND_TO_DAEMON(sessionConnection, MC_DRV_CMD_NQ_CONNECT,
+ session->deviceId,
+ session->sessionId,
+ rspOpenSessionPayload.deviceSessionId,
+ rspOpenSessionPayload.sessionMagic);
+
+ RECV_FROM_DAEMON(sessionConnection, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("CMD_NQ_CONNECT failed, respId=%d", mcResult);
+ break;
+ }
+
+ } while (0);
+
+ if (mcResult != MC_DRV_OK) {
+ delete sessionConnection;
+ // Here we know we couldn't communicate well with the Daemon.
+ // Maybe we should use existing connection to close Trustlet.
+ break; // unlock mutex and return
+ }
+
+ // there is no payload.
+
+ // Session has been established, new session object must be created
+ Session *sessionObj = device->createNewSession(session->sessionId, sessionConnection);
+ // If the session tci was a mapped buffer then register it
+ if (bulkBuf)
+ sessionObj->addBulkBuf(bulkBuf);
+
+ LOG_I(" Successfully opened session %d.", session->sessionId);
+
+ } while (false);
+
+ if (mcResult != MC_DRV_OK && bulkBuf) {
+ delete bulkBuf;
+ }
+
+// TODO: enable as soon as there are more error codes
+// if (mcResult == MC_DRV_ERR_SOCKET_WRITE || mcResult == MC_DRV_ERR_SOCKET_READ) {
+// LOG_E("Connection is dead, removing device.");
+// removeDevice(session->deviceId);
+// }
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcOpenGPTA(
+ mcSessionHandle_t *session,
+ const mcUuid_t *uuid,
+ uint8_t *tci,
+ uint32_t len
+)
+{
+ mcResult_t mcResult = MC_DRV_OK;
+
+#ifndef WIN32
+ devMutex.lock();
+ LOG_I("===%s()===", __FUNCTION__);
+
+ BulkBufferDescriptor *bulkBuf = NULL;
+
+ do {
+ uint32_t handle = 0;
+ CHECK_NOT_NULL(session);
+ CHECK_NOT_NULL(uuid);
+
+ if (len > MC_MAX_TCI_LEN) {
+ LOG_E("TCI length is longer than %d", MC_MAX_TCI_LEN);
+ mcResult = MC_DRV_ERR_TCI_TOO_BIG;
+ break;
+ }
+
+ // Get the device associated with the given session
+ Device *device = resolveDeviceId(session->deviceId);
+ CHECK_DEVICE(device);
+
+ Connection *devCon = device->connection;
+
+ // First assume the TCI is a contiguous buffer
+ // Get the physical address of the given TCI
+ CWsm_ptr pWsm = device->findContiguousWsm(tci);
+ if (pWsm == NULL) {
+ if (tci != NULL && len != 0) {
+ // Then assume it's a normal buffer that needs to be mapped
+ mcResult = device->mapBulkBuf(tci, len, &bulkBuf);
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("Registering buffer failed. ret=%x", mcResult);
+ mcResult = MC_DRV_ERR_WSM_NOT_FOUND;
+ break;
+ }
+ handle = bulkBuf->handle;
+ } else if ( len != 0 ) {
+ LOG_E("mcOpenSession(): length is more than allocated TCI");
+ mcResult = MC_DRV_ERR_TCI_GREATER_THAN_WSM;
+ break;
+ }
+ } else {
+ if (pWsm->len < len) {
+ LOG_E("mcOpenSession(): length is more than allocated TCI");
+ mcResult = MC_DRV_ERR_TCI_GREATER_THAN_WSM;
+ break;
+ }
+ handle = pWsm->handle;
+ }
+
+ SEND_TO_DAEMON(devCon, MC_DRV_CMD_OPEN_TRUSTED_APP,
+ session->deviceId,
+ *uuid,
+ (uintptr_t)(tci) & 0xFFF,
+ (uint32_t)handle,
+ len);
+
+ // Read command response
+ RECV_FROM_DAEMON(devCon, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ // TODO-2012-09-06-haenellu: Remove this code once tests can handle it
+
+ if (MC_DRV_ERROR_MAJOR(mcResult) != MC_DRV_ERR_MCP_ERROR) {
+ LOG_E("Daemon could not open session, responseId %d.", mcResult);
+ } else {
+ uint32_t mcpResult = MC_DRV_ERROR_MCP(mcResult);
+ LOG_E("<t-base reported failing of MC_MCP_CMD_OPEN_SESSION command, mcpResult %d.", mcpResult);
+
+ // IMPROVEMENT-2012-09-03-haenellu: Remove this switch case and use MCP code in tests.
+ switch (mcpResult) {
+ case MC_MCP_RET_ERR_WRONG_PUBLIC_KEY:
+ mcResult = MC_DRV_ERR_WRONG_PUBLIC_KEY;
+ break;
+ case MC_MCP_RET_ERR_CONTAINER_TYPE_MISMATCH:
+ mcResult = MC_DRV_ERR_CONTAINER_TYPE_MISMATCH;
+ break;
+ case MC_MCP_RET_ERR_CONTAINER_LOCKED:
+ mcResult = MC_DRV_ERR_CONTAINER_LOCKED;
+ break;
+ case MC_MCP_RET_ERR_SP_NO_CHILD:
+ mcResult = MC_DRV_ERR_SP_NO_CHILD;
+ break;
+ case MC_MCP_RET_ERR_TL_NO_CHILD:
+ mcResult = MC_DRV_ERR_TL_NO_CHILD;
+ break;
+ case MC_MCP_RET_ERR_UNWRAP_ROOT_FAILED:
+ mcResult = MC_DRV_ERR_UNWRAP_ROOT_FAILED;
+ break;
+ case MC_MCP_RET_ERR_UNWRAP_SP_FAILED:
+ mcResult = MC_DRV_ERR_UNWRAP_SP_FAILED;
+ break;
+ case MC_MCP_RET_ERR_UNWRAP_TRUSTLET_FAILED:
+ mcResult = MC_DRV_ERR_UNWRAP_TRUSTLET_FAILED;
+ break;
+ default:
+ // TODO-2012-09-06-haenellu: Remove line and adapt codes in tests.
+ mcResult = MC_DRV_ERR_MCP_ERROR;
+ break;
+ }
+ }
+ break; // loading of Trustlet failed, unlock mutex and return
+ }
+
+ // read payload
+ mcDrvRspOpenSessionPayload_t rspOpenSessionPayload;
+ RECV_FROM_DAEMON(devCon, &rspOpenSessionPayload);
+
+ // Register session with handle
+ session->sessionId = rspOpenSessionPayload.sessionId;
+
+ LOG_I(" Service is started. Setting up channel for notifications.");
+
+ // Set up second channel for notifications
+ Connection *sessionConnection = new Connection();
+ if (!sessionConnection->connect(SOCK_PATH)) {
+ LOG_E("Could not connect to %s", SOCK_PATH);
+ delete sessionConnection;
+ // Here we know we couldn't connect to the Daemon.
+ // Maybe we should use existing connection to close Trustlet.
+ mcResult = MC_DRV_ERR_SOCKET_CONNECT;
+ break;
+ }
+
+ do {
+ SEND_TO_DAEMON(sessionConnection, MC_DRV_CMD_NQ_CONNECT,
+ session->deviceId,
+ session->sessionId,
+ rspOpenSessionPayload.deviceSessionId,
+ rspOpenSessionPayload.sessionMagic);
+
+ RECV_FROM_DAEMON(sessionConnection, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("CMD_NQ_CONNECT failed, respId=%d", mcResult);
+ break;
+ }
+
+ } while (0);
+ if (mcResult != MC_DRV_OK) {
+ delete sessionConnection;
+ // Here we know we couldn't communicate well with the Daemon.
+ // Maybe we should use existing connection to close Trustlet.
+ break; // unlock mutex and return
+ }
+
+ // there is no payload.
+
+ // Session has been established, new session object must be created
+ Session *sessionObj = device->createNewSession(session->sessionId, sessionConnection);
+ // If the session tci was a mapped buffer then register it
+ if (bulkBuf)
+ sessionObj->addBulkBuf(bulkBuf);
+
+ LOG_I(" Successfully opened session %d.", session->sessionId);
+
+ } while (false);
+
+ if (mcResult != MC_DRV_OK && bulkBuf) {
+ delete bulkBuf;
+ }
+
+// TODO: enable as soon as there are more error codes
+// if (mcResult == MC_DRV_ERR_SOCKET_WRITE || mcResult == MC_DRV_ERR_SOCKET_READ) {
+// LOG_E("Connection is dead, removing device.");
+// removeDevice(session->deviceId);
+// }
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcCloseSession(mcSessionHandle_t *session)
+{
+ mcResult_t mcResult = MC_DRV_OK;
+#ifndef WIN32
+
+ LOG_I("===%s()===", __FUNCTION__);
+ devMutex.lock();
+ do {
+ CHECK_NOT_NULL(session);
+ LOG_I(" Closing session %d.", session->sessionId);
+
+ Device *device = resolveDeviceId(session->deviceId);
+ CHECK_DEVICE(device);
+
+ Connection *devCon = device->connection;
+
+ Session *nqSession = device->resolveSessionId(session->sessionId);
+
+ CHECK_SESSION(nqSession, session->sessionId);
+
+ SEND_TO_DAEMON(devCon, MC_DRV_CMD_CLOSE_SESSION, session->sessionId);
+
+ RECV_FROM_DAEMON(devCon, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("CMD_CLOSE_SESSION failed, respId=%d", mcResult);
+ // TODO-2012-08-03-haenellu: Remove once tests can handle it.
+ mcResult = MC_DRV_ERR_UNKNOWN_DEVICE;
+ break;
+ }
+
+ bool r = device->removeSession(session->sessionId);
+ if (!r)
+ {
+ LOG_E("removeSession failed");
+ assert(0);
+ }
+
+
+
+ } while (false);
+
+ if (mcResult == MC_DRV_ERR_SOCKET_WRITE || mcResult == MC_DRV_ERR_SOCKET_READ) {
+ LOG_E("Connection is dead, removing device.");
+ removeDevice(session->deviceId);
+ }
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcNotify(
+ mcSessionHandle_t *session
+)
+{
+ mcResult_t mcResult = MC_DRV_OK;
+#ifndef WIN32
+
+ devMutex.lock();
+ LOG_I("===%s()===", __FUNCTION__);
+
+ do {
+ CHECK_NOT_NULL(session);
+ LOG_I(" Notifying session %d.", session->sessionId);
+
+ Device *device = resolveDeviceId(session->deviceId);
+ CHECK_DEVICE(device);
+
+ Connection *devCon = device->connection;
+
+ Session *nqsession = device->resolveSessionId(session->sessionId);
+ CHECK_SESSION(nqsession, session->sessionId);
+
+ SEND_TO_DAEMON(devCon, MC_DRV_CMD_NOTIFY, session->sessionId);
+ // Daemon will not return a response
+ } while (false);
+
+ if (mcResult == MC_DRV_ERR_SOCKET_WRITE) {
+ LOG_E("Connection is dead, removing device.");
+ removeDevice(session->deviceId);
+ }
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcWaitNotification(
+ mcSessionHandle_t *session,
+ int32_t timeout
+)
+{
+ mcResult_t mcResult = MC_DRV_OK;
+#ifndef WIN32
+
+ // TODO-2012-11-02-gurel: devMutex locking and unlocking had to be commented out
+ // below. Otherwise, when there are multiple threads in Nwd TLC side, we endup a
+ // deadlock situation, e.g. one thread waits for notification and another one sends
+ // notification.
+
+ //devMutex.lock();
+ LOG_I("===%s()===", __FUNCTION__);
+
+ do {
+ CHECK_NOT_NULL(session);
+ LOG_I(" Waiting for notification of session %d.", session->sessionId);
+
+ Device *device = resolveDeviceId(session->deviceId);
+ CHECK_DEVICE(device);
+
+ Session *nqSession = device->resolveSessionId(session->sessionId);
+ CHECK_SESSION(nqSession, session->sessionId);
+
+ Connection *nqconnection = nqSession->notificationConnection;
+ uint32_t count = 0;
+
+ // Read notification queue till it's empty
+ for (;;) {
+ notification_t notification;
+ ssize_t numRead = nqconnection->readData(
+ ¬ification,
+ sizeof(notification_t),
+ timeout);
+ //Exit on timeout in first run
+ //Later runs have timeout set to 0. -2 means, there is no more data.
+ if (count == 0 && numRead == -2 ) {
+ LOG_W("Timeout hit at %s", __FUNCTION__);
+ mcResult = MC_DRV_ERR_TIMEOUT;
+ break;
+ }
+ if (count == 0 && numRead == 0 ) {
+ LOG_E("Connection is dead, removing device.");
+ removeDevice(session->deviceId);
+ mcResult = MC_DRV_ERR_NOTIFICATION;
+ break;
+ }
+ // After first notification the queue will be drained, Thus we set
+ // no timeout for the following reads
+ timeout = 0;
+
+ if (numRead != sizeof(notification_t)) {
+ if (count == 0) {
+ //failure in first read, notify it
+ mcResult = MC_DRV_ERR_NOTIFICATION;
+ LOG_E("read notification failed, %i bytes received", (int)numRead);
+ break;
+ } else {
+ // Read of the n-th notification failed/timeout. We don't tell the
+ // caller, as we got valid notifications before.
+ mcResult = MC_DRV_OK;
+ break;
+ }
+ }
+
+ count++;
+ LOG_I(" Received notification %d for session %d, payload=%d",
+ count, notification.sessionId, notification.payload);
+
+ if (notification.payload != 0) {
+ // Session end point died -> store exit code
+ nqSession->setErrorInfo(notification.payload);
+
+ mcResult = MC_DRV_INFO_NOTIFICATION;
+ break;
+ }
+ } // for(;;)
+
+ } while (false);
+
+ //devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcMallocWsm(
+ uint32_t deviceId,
+ uint32_t align __unused,
+ uint32_t len,
+ uint8_t **wsm,
+ uint32_t wsmFlags __unused)
+{
+ mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
+#ifndef WIN32
+
+ LOG_I("===%s(len=%i)===", __FUNCTION__, len);
+
+ devMutex.lock();
+
+ do {
+ Device *device = resolveDeviceId(deviceId);
+
+ // Is the device known
+ // CHECK_DEVICE(device);
+
+ // Is the device opened.
+ CHECK_DEVICE_CLOSED(device, deviceId)
+
+ CHECK_NOT_NULL(wsm);
+
+ CWsm_ptr pWsm;
+ mcResult = device->allocateContiguousWsm(len, &pWsm);
+ if (mcResult != MC_DRV_OK) {
+ LOG_W(" Allocation of WSM failed");
+ break;
+ }
+
+ *wsm = (uint8_t *)pWsm->virtAddr;
+ mcResult = MC_DRV_OK;
+
+ } while (false);
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcFreeWsm(
+ uint32_t deviceId,
+ uint8_t *wsm
+)
+{
+ mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
+#ifndef WIN32
+
+ Device *device;
+
+ devMutex.lock();
+
+ LOG_I("===%s(%p)===", __FUNCTION__, wsm);
+
+ do {
+
+ // Get the device associated wit the given session
+ device = resolveDeviceId(deviceId);
+
+ // Is the device known
+ CHECK_DEVICE(device);
+
+ // Is the device opened.
+ CHECK_DEVICE_CLOSED(device, deviceId)
+
+ // find WSM object
+ CWsm_ptr pWsm = device->findContiguousWsm(wsm);
+ if (pWsm == NULL) {
+ LOG_E("address is unknown to mcFreeWsm");
+ mcResult = MC_DRV_ERR_WSM_NOT_FOUND;
+ break;
+ }
+
+ // Free the given virtual address
+ mcResult = device->freeContiguousWsm(pWsm);
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("Free of virtual address failed");
+ break;
+ }
+ mcResult = MC_DRV_OK;
+
+ } while (false);
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcMap(
+ mcSessionHandle_t *sessionHandle,
+ void *buf,
+ uint32_t bufLen,
+ mcBulkMap_t *mapInfo
+)
+{
+ mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
+#ifndef WIN32
+
+ static CMutex mutex;
+
+ LOG_I("===%s()===", __FUNCTION__);
+
+ devMutex.lock();
+
+ do {
+ CHECK_NOT_NULL(sessionHandle);
+ CHECK_NOT_NULL(mapInfo);
+ CHECK_NOT_NULL(buf);
+
+ // Determine device the session belongs to
+ Device *device = resolveDeviceId(sessionHandle->deviceId);
+ // Is the device known
+ CHECK_DEVICE(device);
+
+ // Is the device opened.
+ CHECK_DEVICE_CLOSED(device, sessionHandle->deviceId)
+
+ Connection *devCon = device->connection;
+
+ // Get session
+ Session *session = device->resolveSessionId(sessionHandle->sessionId);
+ CHECK_SESSION(session, sessionHandle->sessionId);
+
+ LOG_I(" Mapping %p to session %d.", buf, sessionHandle->sessionId);
+
+ // Register mapped bulk buffer to Kernel Module and keep mapped bulk buffer in mind
+ BulkBufferDescriptor *bulkBuf;
+ mcResult = session->addBulkBuf(buf, bufLen, &bulkBuf);
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("Registering buffer failed. ret=%x", mcResult);
+ break;
+ }
+
+ SEND_TO_DAEMON(devCon, MC_DRV_CMD_MAP_BULK_BUF,
+ session->sessionId,
+ (uint32_t)bulkBuf->handle,
+ (uint32_t)0,
+ (uintptr_t)(bulkBuf->virtAddr) & 0xFFF,
+ bulkBuf->len);
+
+ // Read command response
+ RECV_FROM_DAEMON(devCon, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("CMD_MAP_BULK_BUF failed, respId=%d", mcResult);
+ // TODO-2012-09-06-haenellu: Remove once tests can handle it.
+ mcResult = MC_DRV_ERR_DAEMON_UNREACHABLE;
+
+ // Unregister mapped bulk buffer from Kernel Module and remove mapped
+ // bulk buffer from session maintenance
+ if (session->removeBulkBuf(buf) != MC_DRV_OK) {
+ // Removing of bulk buffer not possible
+ LOG_E("Unregistering of bulk memory from Kernel Module failed");
+ }
+ break;
+ }
+
+ mcDrvRspMapBulkMemPayload_t rspMapBulkMemPayload;
+ RECV_FROM_DAEMON(devCon, &rspMapBulkMemPayload);
+
+ // Set mapping info for internal structures
+ bulkBuf->sVirtualAddr = (void *)(uintptr_t)rspMapBulkMemPayload.secureVirtualAdr;
+ // Set mapping info for Trustlet
+ mapInfo->sVirtualAddr = bulkBuf->sVirtualAddr;
+ mapInfo->sVirtualLen = bufLen;
+ mcResult = MC_DRV_OK;
+
+ } while (false);
+
+// // TODO: enable as soon as there are more error codes
+// if (mcResult == MC_DRV_ERR_SOCKET_WRITE || mcResult == MC_DRV_ERR_SOCKET_READ) {
+// LOG_E("Connection is dead, removing device.");
+// removeDevice(sessionHandle->deviceId);
+// }
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcUnmap(
+ mcSessionHandle_t *sessionHandle,
+ void *buf,
+ mcBulkMap_t *mapInfo
+)
+{
+ mcResult_t mcResult = MC_DRV_ERR_UNKNOWN;
+#ifndef WIN32
+
+ static CMutex mutex;
+
+ LOG_I("===%s()===", __FUNCTION__);
+
+ devMutex.lock();
+
+ do {
+ CHECK_NOT_NULL(sessionHandle);
+ CHECK_NOT_NULL(mapInfo);
+ CHECK_NOT_NULL(mapInfo->sVirtualAddr);
+ CHECK_NOT_NULL(buf);
+
+ // Determine device the session belongs to
+ Device *device = resolveDeviceId(sessionHandle->deviceId);
+ // Is the device known
+ CHECK_DEVICE(device);
+
+ // Is the device opened.
+ CHECK_DEVICE_CLOSED(device, sessionHandle->deviceId)
+
+ Connection *devCon = device->connection;
+
+ // Get session
+ Session *session = device->resolveSessionId(sessionHandle->sessionId);
+ CHECK_SESSION(session, sessionHandle->sessionId);
+
+ uint32_t handle = session->getBufHandle(mapInfo->sVirtualAddr, mapInfo->sVirtualLen);
+ if (handle == 0) {
+ LOG_E("Unable to find internal handle for buffer %p.", mapInfo->sVirtualAddr);
+ mcResult = MC_DRV_ERR_BLK_BUFF_NOT_FOUND;
+ break;
+ }
+
+ LOG_I(" Unmapping %p(handle=%u) from session %d.", buf, handle, sessionHandle->sessionId);
+
+ SEND_TO_DAEMON(devCon, MC_DRV_CMD_UNMAP_BULK_BUF,
+ session->sessionId,
+ handle,
+ (uintptr_t)(mapInfo->sVirtualAddr),
+ mapInfo->sVirtualLen);
+
+ RECV_FROM_DAEMON(devCon, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("Daemon reported failing of UNMAP BULK BUF command, responseId %d.", mcResult);
+ // TODO-2012-09-06-haenellu: Remove once tests can handle it.
+ mcResult = MC_DRV_ERR_DAEMON_UNREACHABLE;
+ break;
+ }
+
+ // Unregister mapped bulk buffer from Kernel Module and remove mapped
+ // bulk buffer from session maintenance
+ mcResult = session->removeBulkBuf(buf);
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("Unregistering of bulk memory from Kernel Module failed.");
+ break;
+ }
+
+ mcResult = MC_DRV_OK;
+
+ } while (false);
+
+ if (mcResult == MC_DRV_ERR_SOCKET_WRITE || mcResult == MC_DRV_ERR_SOCKET_READ) {
+ LOG_E("Connection is dead, removing device.");
+ removeDevice(sessionHandle->deviceId);
+ }
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcGetSessionErrorCode(
+ mcSessionHandle_t *session,
+ int32_t *lastErr
+)
+{
+ mcResult_t mcResult = MC_DRV_OK;
+#ifndef WIN32
+
+ devMutex.lock();
+ LOG_I("===%s()===", __FUNCTION__);
+
+ do {
+ CHECK_NOT_NULL(session);
+ CHECK_NOT_NULL(lastErr);
+
+ // Get device
+ Device *device = resolveDeviceId(session->deviceId);
+ // Is the device known
+ CHECK_DEVICE(device);
+
+ // Is the device opened.
+ CHECK_DEVICE_CLOSED(device, session->deviceId)
+
+ // Get session
+ Session *nqsession = device->resolveSessionId(session->sessionId);
+ CHECK_SESSION(nqsession, session->sessionId);
+
+ // get session error code from session
+ *lastErr = nqsession->getLastErr();
+
+ } while (false);
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcDriverCtrl(
+ mcDriverCtrl_t param __unused,
+ uint8_t *data __unused,
+ uint32_t len __unused
+)
+{
+#ifndef WIN32
+
+ LOG_W("mcDriverCtrl(): not implemented");
+
+#endif /* WIN32 */
+ return MC_DRV_ERR_NOT_IMPLEMENTED;
+}
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcGetMobiCoreVersion(
+ uint32_t deviceId,
+ mcVersionInfo_t *versionInfo
+)
+{
+ mcResult_t mcResult = MC_DRV_OK;
+#ifndef WIN32
+
+ devMutex.lock();
+ LOG_I("===%s()===", __FUNCTION__);
+
+ do {
+ Device *device = resolveDeviceId(deviceId);
+
+ // Is the device known
+ CHECK_DEVICE(device);
+
+ // Is the device opened.
+ CHECK_DEVICE_CLOSED(device, deviceId)
+
+ CHECK_NOT_NULL(versionInfo);
+
+ Connection *devCon = device->connection;
+
+ SEND_TO_DAEMON(devCon, MC_DRV_CMD_GET_MOBICORE_VERSION);
+
+ // Read GET MOBICORE VERSION response.
+
+ RECV_FROM_DAEMON(devCon, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("MC_DRV_CMD_GET_MOBICORE_VERSION bad response, respId=%d", mcResult);
+ // TODO-2012-09-06-haenellu: Remove once tests can handle it.
+ mcResult = MC_DRV_ERR_DAEMON_UNREACHABLE;
+ break;
+ }
+
+ // Read payload.
+ mcVersionInfo_t versionInfo_socket;
+ RECV_FROM_DAEMON(devCon, &versionInfo_socket);
+
+ *versionInfo = versionInfo_socket;
+
+ } while (0);
+
+ devMutex.unlock();
+
+#endif /* WIN32 */
+ return mcResult;
+}
+
+#ifndef WIN32
+//------------------------------------------------------------------------------
+// Only called by mcOpenDevice()
+// Must be taken with devMutex locked.
+uint32_t getDaemonVersion(Connection *devCon, uint32_t *version)
+{
+ assert(devCon != NULL);
+ assert(version != NULL);
+ mcResult_t mcResult = MC_DRV_OK;
+ uint32_t v = 0;
+
+ LOG_I("===%s()===", __FUNCTION__);
+
+ do {
+ SEND_TO_DAEMON(devCon, MC_DRV_CMD_GET_VERSION);
+
+ RECV_FROM_DAEMON(devCon, &mcResult);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("MC_DRV_CMD_GET_VERSION bad response, respId=%d", mcResult);
+ // version is still 0, we don't further analyze response here.
+ break;
+ }
+
+ RECV_FROM_DAEMON(devCon, &v);
+
+ } while (0);
+
+ if (mcResult == MC_DRV_OK) {
+ *version = v;
+ }
+
+ return mcResult;
+}
+#endif /* WIN32 */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_IMPL_LIB
+ * @{
+ * @file
+ *
+ * Client library device management.
+ *
+ * Device and Trustlet Session management Funtions.
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdint.h>
+#include <vector>
+
+#include "mc_linux.h"
+#include "Device.h"
+
+#include "log.h"
+#include <assert.h>
+
+
+//------------------------------------------------------------------------------
+Device::Device(uint32_t deviceId, Connection *connection)
+{
+ this->deviceId = deviceId;
+ this->connection = connection;
+
+ pMcKMod = new CMcKMod();
+}
+
+
+//------------------------------------------------------------------------------
+Device::~Device(void)
+{
+ /* Delete all session objects. Usually this should not be needed as closeDevice()
+ * requires that all sessions have been closed before.
+ */
+ sessionIterator_t sessionIterator = sessionList.begin();
+ while (sessionIterator != sessionList.end()) {
+ delete (*sessionIterator);
+ sessionIterator = sessionList.erase(sessionIterator);
+ }
+
+ // Free all allocated WSM descriptors
+ wsmIterator_t wsmIterator = wsmL2List.begin();
+ while (wsmIterator != wsmL2List.end()) {
+ CWsm_ptr pWsm = *wsmIterator;
+
+ // ignore return code
+ pMcKMod->free(pWsm->handle, pWsm->virtAddr, pWsm->len);
+
+ delete (*wsmIterator);
+ wsmIterator = wsmL2List.erase(wsmIterator);
+ }
+ delete connection;
+ delete pMcKMod;
+}
+
+
+//------------------------------------------------------------------------------
+bool Device::open(const char *deviceName)
+{
+ return pMcKMod->open(deviceName);
+}
+
+
+//------------------------------------------------------------------------------
+void Device::close(void)
+{
+ pMcKMod->close();
+}
+
+
+//------------------------------------------------------------------------------
+bool Device::hasSessions(void)
+{
+ return sessionList.size() > 0;
+}
+
+
+//------------------------------------------------------------------------------
+Session *Device::createNewSession(uint32_t sessionId, Connection *connection)
+{
+ Session *session = new Session(sessionId, pMcKMod, connection);
+ sessionList.push_back(session);
+ return session;
+}
+
+
+//------------------------------------------------------------------------------
+bool Device::removeSession(uint32_t sessionId)
+{
+ bool ret = false;
+
+ sessionIterator_t interator = sessionList.begin();
+ while (interator != sessionList.end()) {
+ if ((*interator)->sessionId == sessionId) {
+ delete (*interator);
+ interator = sessionList.erase(interator);
+ ret = true;
+ break;
+ } else {
+ interator++;
+ }
+ }
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+Session *Device::resolveSessionId(uint32_t sessionId)
+{
+ Session *ret = NULL;
+
+ // Get Session for sessionId
+ for ( sessionIterator_t interator = sessionList.begin();
+ interator != sessionList.end();
+ ++interator) {
+ if ((*interator)->sessionId == sessionId) {
+ ret = (*interator);
+ break;
+ }
+ }
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t Device::allocateContiguousWsm(uint32_t len, CWsm **wsm)
+{
+ // Allocate shared memory
+ addr_t virtAddr;
+ uint32_t handle;
+ uint64_t physAddr;
+ mcResult_t ret;
+
+ assert(wsm != NULL);
+
+ if (!len) {
+ return MC_DRV_ERR_INVALID_LENGTH;
+ }
+
+ ret = pMcKMod->mapWsm(len, &handle, &virtAddr, &physAddr);
+ if (ret) {
+ return ret;
+ }
+
+ LOG_I(" mapped handle %d to %p, phys=%#llx ", handle, virtAddr, physAddr);
+
+ // Register (vaddr,paddr) with device
+ *wsm = new CWsm(virtAddr, len, handle, physAddr);
+
+ wsmL2List.push_back(*wsm);
+
+ // Return pointer to the allocated memory
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t Device::freeContiguousWsm(CWsm_ptr pWsm)
+{
+ mcResult_t ret = MC_DRV_ERR_WSM_NOT_FOUND;
+ wsmIterator_t iterator;
+
+ for (iterator = wsmL2List.begin(); iterator != wsmL2List.end(); ++iterator) {
+ if (pWsm == *iterator) {
+ ret = MC_DRV_OK;
+ break;
+ }
+ }
+ // We just looked this up using findContiguousWsm
+ assert(ret == MC_DRV_OK);
+
+ LOG_I(" unmapping handle %d from %p, phys=%#llx",
+ pWsm->handle, pWsm->virtAddr, pWsm->physAddr);
+
+ ret = pMcKMod->free(pWsm->handle, pWsm->virtAddr, pWsm->len);
+ if (ret != MC_DRV_OK) {
+ // developer forgot to free all references of this memory, we do not remove the reference here
+ return ret;
+ }
+
+ iterator = wsmL2List.erase(iterator);
+ delete pWsm;
+
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+CWsm_ptr Device::findContiguousWsm(addr_t virtAddr)
+{
+ CWsm_ptr pWsm = NULL;
+
+ if (virtAddr == NULL) {
+ return pWsm;
+ }
+
+ for ( wsmIterator_t iterator = wsmL2List.begin();
+ iterator != wsmL2List.end();
+ ++iterator) {
+ CWsm_ptr pTmpWsm = *iterator;
+ if (virtAddr == pTmpWsm->virtAddr) {
+ pWsm = pTmpWsm;
+ break;
+ }
+ }
+
+ return pWsm;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t Device::mapBulkBuf(addr_t buf, uint32_t len, BulkBufferDescriptor **blkBuf)
+{
+ uint64_t PhysWsmL2;
+ uint32_t handle;
+
+ *blkBuf = NULL;
+
+ // Prepare the interface structure for memory registration in Kernel Module
+ mcResult_t ret = pMcKMod->registerWsmL2(buf, len, 0, &handle, &PhysWsmL2);
+ if (ret != MC_DRV_OK) {
+ LOG_V(" mcKMod->registerWsmL2() failed with %x", ret);
+ return ret;
+ }
+
+ LOG_V(" addBulkBuf - Handle of L2 Table = %u", handle);
+
+ // Create new descriptor - secure virtual virtual set to 0, unknown!
+ *blkBuf = new BulkBufferDescriptor(buf, 0x0, len, handle);
+
+ return MC_DRV_OK;
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_IMPL_LIB
+ * @{
+ * @file
+ *
+ * Client library device management.
+ *
+ * Device and Trustlet Session management Functions.
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef DEVICE_H_
+#define DEVICE_H_
+
+#include <stdint.h>
+#include <vector>
+
+#include "public/MobiCoreDriverApi.h"
+#include "Session.h"
+#include "CWsm.h"
+
+
+class Device
+{
+
+private:
+ sessionList_t sessionList; /**< MobiCore Trustlet session associated with the device */
+ wsmList_t wsmL2List; /**< WSM L2 Table */
+
+
+public:
+ uint32_t deviceId; /**< Device identifier */
+ Connection *connection; /**< The device connection */
+ CMcKMod_ptr pMcKMod;
+
+ Device(
+ uint32_t deviceId,
+ Connection *connection
+ );
+
+ virtual ~Device(
+ void
+ );
+
+ /**
+ * Open the device.
+ * @param deviceName Name of the kernel modules device file.
+ * @return true if the device has been opened successfully
+ */
+ bool open(
+ const char *deviceName
+ );
+
+ /**
+ * Closes the device.
+ */
+ void close(
+ void
+ );
+
+ /**
+ * Check if the device has open sessions.
+ * @return true if the device has one or more open sessions.
+ */
+ bool hasSessions(
+ void
+ );
+
+ /**
+ * Add a session to the device.
+ * @param sessionId session ID
+ * @param connection session connection
+ * @return Session object created
+ */
+ Session *createNewSession(
+ uint32_t sessionId,
+ Connection *connection
+ );
+
+ /**
+ * Remove the specified session from the device.
+ * The session object will be destroyed and all resources associated with it will be freed.
+ *
+ * @param sessionId Session of the session to remove.
+ * @return true if a session has been found and removed.
+ */
+ bool removeSession(
+ uint32_t sessionId
+ );
+
+ /**
+ * Get as session object for a given session ID.
+ * @param sessionId Identified of a previously opened session.
+ * @return Session object if available or NULL if no session has been found.
+ */
+ Session *resolveSessionId(
+ uint32_t sessionId
+ );
+
+ /**
+ * Allocate a block of contiguous WSM.
+ * @param len The virtual address to be registered.
+ * @param wsm The CWsm object of the allocated memory.
+ * @return MC_DRV_OK if successful.
+ */
+ mcResult_t allocateContiguousWsm(
+ uint32_t len,
+ CWsm **wsm
+ );
+
+ /**
+ * Unregister a vaddr from a device.
+ * @param vaddr The virtual address to be registered.
+ * @param paddr The physical address to be registered.
+ */
+ mcResult_t freeContiguousWsm(
+ CWsm_ptr pWsm
+ );
+
+ /**
+ * Get a WSM object for a given virtual address.
+ * @param vaddr The virtual address which has been allocate with mcMallocWsm() in advance.
+ * @return the WSM object or NULL if no address has been found.
+ */
+ CWsm_ptr findContiguousWsm(
+ addr_t virtAddr
+ );
+
+ /**
+ * Map a buffer from tlc VA to TL(Create L2 table for the buffer
+ * @param buf The virtual address of hte buffer
+ * @param len The length of the buffer
+ * @param blkBuf The buffer object created
+ * @return MC_DRV_OK if successful.
+ */
+ mcResult_t mapBulkBuf(
+ addr_t buf,
+ uint32_t len,
+ BulkBufferDescriptor **blkBuf
+ );
+
+};
+
+#endif /* DEVICE_H_ */
+
+/** @} */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#undef LOG_TAG
+#define LOG_TAG "GpClient"
+#include "tee_client_api.h"
+#include "log.h"
+#include "MobiCoreDriverApi.h"
+#include "Mci/mcinq.h"
+#include <sys/mman.h>
+#include "GpTci.h"
+#include <stdlib.h>
+#include <string.h>
+
+//------------------------------------------------------------------------------
+// Macros
+#define _TEEC_GET_PARAM_TYPE(t, i) (((t) >> (4*i)) & 0xF)
+
+// Max. session number
+#define _TEEC_SESSION_NUMBER 50
+
+//Parameter number
+#define _TEEC_PARAMETER_NUMBER 4
+
+
+//------------------------------------------------------------------------------
+//Local satic functions
+static void _libUuidToArray(
+ const TEEC_UUID *uuid,
+ uint8_t *uuid_str);
+
+
+static TEEC_Result _TEEC_UnwindOperation(
+ _TEEC_TCI *tci,
+ mcSessionHandle_t *handle,
+ TEEC_Operation *operation,
+ bool copyValues,
+ uint32_t *returnOrigin);
+
+static TEEC_Result _TEEC_SetupOperation(
+ _TEEC_TCI *tci,
+ mcSessionHandle_t *handle,
+ TEEC_Operation *operation,
+ uint32_t *returnOrigin);
+
+static TEEC_Result _TEEC_CallTA(
+ TEEC_Session *session,
+ TEEC_Operation *operation,
+ uint32_t *returnOrigin);
+
+//------------------------------------------------------------------------------
+static void _libUuidToArray(
+ const TEEC_UUID *uuid,
+ uint8_t *uuidArr)
+{
+ uint8_t *pIdentifierCursor = (uint8_t *)uuid;
+ /* offsets and syntax constants. See explanations above */
+#ifdef S_BIG_ENDIAN
+ uint32_t offsets = 0;
+#else
+ uint32_t offsets = 0xF1F1DF13;
+#endif
+ uint32_t i;
+
+ for (i = 0; i < sizeof(TEEC_UUID); i++) {
+ /* Two-digit hex number */
+ uint8_t number;
+ int32_t offset = ((int32_t)((offsets & 0xF) << 28)) >> 28;
+ number = pIdentifierCursor[offset];
+ offsets >>= 4;
+ pIdentifierCursor++;
+
+ uuidArr[i] = number;
+ }
+}
+
+//------------------------------------------------------------------------------
+static TEEC_Result _TEEC_SetupOperation(
+ _TEEC_TCI *tci,
+ mcSessionHandle_t *handle,
+ TEEC_Operation *operation,
+ uint32_t *returnOrigin)
+{
+ uint32_t i;
+ _TEEC_ParameterInternal *imp;
+ TEEC_Parameter *ext;
+ mcResult_t mcRet = MC_DRV_OK;
+ TEEC_Result teecResult = TEEC_SUCCESS;
+
+ //operation can be NULL
+ tci->operation.isCancelled = false;
+ if (operation != NULL) {
+ LOG_I(" %s()", __func__);
+
+ tci->operation.paramTypes = operation->paramTypes;
+ operation->started = 1;
+
+ //TODO: This design allows a non-NULL buffer with a size of 0 bytes to allow trivial integration with any
+ //implementations of the C library malloc, in which is valid to allocate a zero byte buffer and receive a non-
+ //NULL pointer which may not be de-referenced in return.
+
+
+ for (i = 0; i < _TEEC_PARAMETER_NUMBER; i++) {
+ imp = &tci->operation.params[i];
+ ext = &operation->params[i];
+
+ switch (_TEEC_GET_PARAM_TYPE(operation->paramTypes, i)) {
+ case TEEC_VALUE_OUTPUT:
+ break;
+ case TEEC_NONE:
+ LOG_I(" cycle %d, TEEC_NONE", i);
+ break;
+ case TEEC_VALUE_INPUT:
+ case TEEC_VALUE_INOUT: {
+ LOG_I(" cycle %d, TEEC_VALUE_IN*", i);
+ imp->value.a = ext->value.a;
+ imp->value.b = ext->value.b;
+ break;
+ }
+ case TEEC_MEMREF_TEMP_INPUT:
+ case TEEC_MEMREF_TEMP_OUTPUT:
+ case TEEC_MEMREF_TEMP_INOUT: {
+ //TODO: A Temporary Memory Reference may be null, which can be used to denote a special case for the
+ //parameter. Output Memory References that are null are typically used to request the required output size.
+ LOG_I(" cycle %d, TEEC_TEMP_IN*", i);
+ imp->memref.mapInfo.sVirtualLen = 0;
+ if ((ext->tmpref.size) && (ext->tmpref.buffer)) {
+ mcRet = mcMap(handle, ext->tmpref.buffer, ext->tmpref.size, &imp->memref.mapInfo);
+ if (mcRet != MC_DRV_OK) {
+ LOG_E("mcMap failed, mcRet=0x%08X", mcRet);
+ *returnOrigin = TEEC_ORIGIN_COMMS;
+ i = _TEEC_PARAMETER_NUMBER;
+ }
+ } else {
+ LOG_I(" cycle %d, TEEC_TEMP_IN* - zero pointer or size", i);
+ }
+ break;
+ }
+ case TEEC_MEMREF_WHOLE: {
+ LOG_I(" cycle %d, TEEC_MEMREF_WHOLE", i);
+ imp->memref.mapInfo.sVirtualLen = 0;
+ if (ext->memref.parent->size) {
+ mcRet = mcMap(handle, ext->memref.parent->buffer, ext->memref.parent->size, &imp->memref.mapInfo);
+ if (mcRet != MC_DRV_OK) {
+ LOG_E("mcMap failed, mcRet=0x%08X", mcRet);
+ *returnOrigin = TEEC_ORIGIN_COMMS;
+ i = _TEEC_PARAMETER_NUMBER;
+ }
+ }
+ break;
+ }
+ case TEEC_MEMREF_PARTIAL_INPUT:
+ case TEEC_MEMREF_PARTIAL_OUTPUT:
+ case TEEC_MEMREF_PARTIAL_INOUT: {
+ LOG_I(" cycle %d, TEEC_PARTIAL_IN*", i);
+ //Check data flow consistency
+ if ((((ext->memref.parent->flags & (TEEC_MEM_INPUT | TEEC_MEM_OUTPUT)) == TEEC_MEM_INPUT) &&
+ (_TEEC_GET_PARAM_TYPE(operation->paramTypes, i) == TEEC_MEMREF_PARTIAL_OUTPUT)) ||
+ (((ext->memref.parent->flags & (TEEC_MEM_INPUT | TEEC_MEM_OUTPUT)) == TEEC_MEM_OUTPUT) &&
+ (_TEEC_GET_PARAM_TYPE(operation->paramTypes, i) == TEEC_MEMREF_PARTIAL_INPUT))) {
+ LOG_E("PARTIAL data flow inconsistency");
+ *returnOrigin = TEEC_ORIGIN_API;
+ teecResult = TEEC_ERROR_BAD_PARAMETERS;
+ i = _TEEC_PARAMETER_NUMBER;
+ break;
+ }
+
+ if (ext->memref.offset + ext->memref.size > ext->memref.parent->size) {
+ LOG_E("PARTIAL offset/size error");
+ *returnOrigin = TEEC_ORIGIN_API;
+ teecResult = TEEC_ERROR_BAD_PARAMETERS;
+ i = _TEEC_PARAMETER_NUMBER;
+ break;
+ }
+ imp->memref.mapInfo.sVirtualLen = 0;
+ if (ext->memref.size) {
+ mcRet = mcMap(handle, (uint8_t *)ext->memref.parent->buffer + ext->memref.offset, ext->memref.size, &imp->memref.mapInfo);
+ if (mcRet != MC_DRV_OK) {
+ LOG_E("mcMap failed, mcRet=0x%08X", mcRet);
+ *returnOrigin = TEEC_ORIGIN_COMMS;
+ i = _TEEC_PARAMETER_NUMBER;
+ }
+ }
+ break;
+ }
+ default:
+ LOG_E("cycle %d, default", i);
+ *returnOrigin = TEEC_ORIGIN_API;
+ teecResult = TEEC_ERROR_BAD_PARAMETERS;
+ i = _TEEC_PARAMETER_NUMBER;
+ break;
+ }
+ }
+
+ if (tci->operation.isCancelled) {
+ LOG_E("the operation has been cancelled in COMMS");
+ *returnOrigin = TEEC_ORIGIN_COMMS;
+ teecResult = TEEC_ERROR_CANCEL;
+ }
+
+ if ((mcRet != MC_DRV_OK) || (teecResult != TEEC_SUCCESS)) {
+ uint32_t retOrigIgnored;
+ _TEEC_UnwindOperation(tci, handle, operation, false, &retOrigIgnored);
+ //Zeroing out tci->operation
+ memset(&tci->operation, 0, sizeof(TEEC_Operation));
+ if (teecResult != TEEC_SUCCESS) return teecResult;
+ return TEEC_ERROR_GENERIC;
+ }
+ }
+
+ //Copy version indicator field
+ strcpy(tci->header, "TCIGP000");
+
+ // Fill in invalid values for secure world to overwrite
+ tci->returnStatus = 0;
+ tci->returnStatus = TEE_ERROR_BAD_STATE;
+
+ // Signal completion of request writing
+ tci->ready = 1;
+
+ return teecResult;
+}
+
+//------------------------------------------------------------------------------
+static TEEC_Result _TEEC_UnwindOperation(
+ _TEEC_TCI *tci,
+ mcSessionHandle_t *handle,
+ TEEC_Operation *operation,
+ bool copyValues,
+ uint32_t *returnOrigin)
+{
+ uint32_t i;
+ _TEEC_ParameterInternal *imp;
+ TEEC_Parameter *ext;
+ //mcResult_t mcRet = MC_DRV_OK;
+ //bool doUnmap = false;
+ uint8_t *buffer;
+
+ //operation can be NULL
+ if (operation == NULL) return TEEC_SUCCESS;
+
+ LOG_I(" %s()", __func__);
+
+ operation->started = 2;
+
+ // Some sanity checks
+ if (tci->returnOrigin == 0 ||
+ ((tci->returnOrigin != TEEC_ORIGIN_TRUSTED_APP) && (tci->returnStatus != TEEC_SUCCESS))) {
+ *returnOrigin = TEEC_ORIGIN_COMMS;
+ return TEEC_ERROR_COMMUNICATION;
+ }
+ *returnOrigin = tci->returnOrigin;
+
+ //Clear sVirtualLen to unMap further
+ for (i = 0; i < _TEEC_PARAMETER_NUMBER; i++) {
+ imp = &tci->operation.params[i];
+ ext = &operation->params[i];
+ buffer = NULL;
+
+ switch (_TEEC_GET_PARAM_TYPE(operation->paramTypes, i)) {
+ case TEEC_VALUE_INPUT:
+ LOG_I(" cycle %d, TEEC_VALUE_INPUT", i);
+ break;
+ case TEEC_NONE:
+ LOG_I(" cycle %d, TEEC_NONE", i);
+ break;
+ case TEEC_VALUE_OUTPUT:
+ case TEEC_VALUE_INOUT: {
+ LOG_I(" cycle %d, TEEC_VALUE_OUT*", i);
+ if (copyValues) {
+ ext->value.a = imp->value.a;
+ ext->value.b = imp->value.b;
+ }
+ break;
+ }
+ case TEEC_MEMREF_TEMP_OUTPUT:
+ case TEEC_MEMREF_TEMP_INPUT:
+ case TEEC_MEMREF_TEMP_INOUT: {
+ LOG_I(" cycle %d, TEEC_TEMP*", i);
+ if ((copyValues) && (_TEEC_GET_PARAM_TYPE(operation->paramTypes, i) != TEEC_MEMREF_TEMP_INPUT)) {
+ ext->tmpref.size = imp->memref.outputSize;
+ }
+ //doUnmap = true;
+ buffer = (uint8_t *)ext->tmpref.buffer;
+ break;
+ }
+ case TEEC_MEMREF_WHOLE: {
+ LOG_I(" cycle %d, TEEC_MEMREF_WHOLE", i);
+ if (copyValues) ext->memref.size = imp->memref.outputSize;
+ //doUnmap = true;
+ buffer = (uint8_t *)ext->memref.parent->buffer;
+ break;
+ }
+
+ case TEEC_MEMREF_PARTIAL_OUTPUT:
+ case TEEC_MEMREF_PARTIAL_INOUT:
+ case TEEC_MEMREF_PARTIAL_INPUT: {
+ LOG_I(" cycle %d, TEEC_MEMREF_PARTIAL*", i);
+ if ((copyValues) && (_TEEC_GET_PARAM_TYPE(operation->paramTypes, i) != TEEC_MEMREF_PARTIAL_INPUT)) {
+ ext->memref.size = imp->memref.outputSize;
+ }
+ buffer = (uint8_t *)ext->memref.parent->buffer + ext->memref.offset;
+ break;
+ }
+ default:
+ LOG_E("cycle %d, bad parameter", i);
+ break;
+ }
+
+ if ((buffer != NULL) && (imp->memref.mapInfo.sVirtualLen != 0)) {
+ // This function assumes that we cannot handle error of mcUnmap
+ mcUnmap(handle, buffer, &imp->memref.mapInfo);
+ }
+ }
+
+ return tci->returnStatus;
+}
+
+//------------------------------------------------------------------------------
+//TEEC_InitializeContext: TEEC_SUCCESS, Another error code from Table 4-2.
+//MC_DRV_OK, MC_DRV_ERR_INVALID_OPERATION, MC_DRV_ERR_DAEMON_UNREACHABLE, MC_DRV_ERR_UNKNOWN_DEVICE, MC_DRV_ERR_INVALID_DEVICE_FILE
+TEEC_Result TEEC_InitializeContext(
+ const char *name __unused,
+ TEEC_Context *context)
+{
+ LOG_I("== %s() ==============", __func__);
+
+ if (context == NULL) return TEEC_ERROR_BAD_PARAMETERS;
+ context->imp.reserved = MC_DEVICE_ID_DEFAULT;
+
+ switch (mcOpenDevice(MC_DEVICE_ID_DEFAULT)) {
+ case MC_DRV_OK:
+ return TEEC_SUCCESS;
+ case MC_DRV_ERR_INVALID_OPERATION:
+ return TEEC_ERROR_BAD_STATE;
+ case MC_DRV_ERR_DAEMON_UNREACHABLE:
+ return TEEC_ERROR_COMMUNICATION;
+ case MC_DRV_ERR_UNKNOWN_DEVICE:
+ return TEEC_ERROR_BAD_PARAMETERS;
+ case MC_DRV_ERR_INVALID_DEVICE_FILE:
+ return TEEC_ERROR_COMMUNICATION;
+ }
+
+ return TEEC_ERROR_GENERIC;
+}
+
+//------------------------------------------------------------------------------
+//mcCloseDevice: MC_DRV_OK, MC_DRV_ERR_UNKNOWN_DEVICE, MC_DRV_ERR_SESSION_PENDING, MC_DRV_ERR_DAEMON_UNREACHABLE
+//TEEC_FinalizeContext: void
+
+//TODO: The implementation of this function MUST NOT be able to fail: after this function returns the Client
+//Application must be able to consider that the Context has been closed.
+
+void TEEC_FinalizeContext(TEEC_Context *context)
+{
+ mcResult_t mcRet;
+
+ LOG_I("== %s() ==============", __func__);
+
+ //The parameter context MUST point to an initialized TEE Context.
+ //Just realized: The function implementation MUST do nothing if context is NULL.
+ if (context == NULL) {
+ LOG_E("context is NULL");
+ return;
+ }
+
+ //The implementation of this function MUST NOT be able to fail: after this function returns the Client
+ //Application must be able to consider that the Context has been closed.
+ mcRet = mcCloseDevice(context->imp.reserved);
+ if (mcRet != MC_DRV_OK) {
+ LOG_E("mcCloseDevice failed (%08x)", mcRet);
+ /* continue even in case of error */;
+ }
+}
+
+//------------------------------------------------------------------------------
+static TEEC_Result _TEEC_CallTA(
+ TEEC_Session *session,
+ TEEC_Operation *operation,
+ uint32_t *returnOrigin)
+{
+ mcResult_t mcRet;
+ TEEC_Result teecRes;
+ TEEC_Result teecError = TEEC_SUCCESS;
+
+ LOG_I(" %s()", __func__);
+
+ // Phase 1: start the operation and wait for the result
+ teecRes = _TEEC_SetupOperation((_TEEC_TCI *)session->imp.tci, &session->imp.handle, operation, returnOrigin);
+ if (teecRes != TEEC_SUCCESS ) {
+ LOG_E("_TEEC_SetupOperation failed (%08x)", teecRes);
+ return teecRes;
+ }
+
+ // Signal the Trusted App
+ mcRet = mcNotify(&session->imp.handle);
+ if (MC_DRV_OK != mcRet) {
+ LOG_E("Notify failed (%08x)", mcRet);
+ teecError = TEEC_ERROR_COMMUNICATION;
+ goto end;
+ }
+
+ // -------------------------------------------------------------
+ // Wait for the Trusted App response
+ mcRet = mcWaitNotification(&session->imp.handle, MC_INFINITE_TIMEOUT);
+ if (mcRet != MC_DRV_OK) {
+ LOG_E("mcWaitNotification failed (%08x)", mcRet);
+ teecError = TEEC_ERROR_COMMUNICATION;
+ if (mcRet == MC_DRV_INFO_NOTIFICATION) {
+ int32_t lastErr;
+ mcGetSessionErrorCode(&session->imp.handle, &lastErr);
+ LOG_E("mcGetSessionErrorCode returned %d", lastErr);
+ if (lastErr == TA_EXIT_CODE_FINISHED) {
+ // We may get here if the TA_OpenSessionEntryPoint returns an error and TA goes fast through DestroyEntryPoint and exits the TA.
+ teecError = TEEC_SUCCESS;
+ } else if (lastErr != ERR_INVALID_SID && lastErr != ERR_SID_NOT_ACTIVE) {
+ LOG_E("Target is DEAD");
+
+ *returnOrigin = TEEC_ORIGIN_TEE;
+ teecError = TEE_ERROR_TARGET_DEAD;
+ }
+ }
+ }
+ // Phase 2: Return values and cleanup
+end:
+ // unmap memory and copy values if no error
+ teecRes = _TEEC_UnwindOperation((_TEEC_TCI *)session->imp.tci, &session->imp.handle, operation,
+ (teecError == TEEC_SUCCESS), returnOrigin);
+ if (teecRes != TEEC_SUCCESS ) {
+ LOG_E("_TEEC_UnwindOperation (%08x)", teecRes);
+ /* continue even in case of error */;
+ }
+
+ // Cleanup
+ if (teecError != TEEC_SUCCESS) {
+ // Previous interactions failed, either TA is dead or communication error
+ mcRet = mcCloseSession(&session->imp.handle);
+ if (mcRet != MC_DRV_OK) {
+ LOG_E("mcCloseSession failed (%08x)", mcRet);
+ /* continue even in case of error */;
+ }
+ session->imp.active = false;
+ if (teecError == TEEC_ERROR_COMMUNICATION) {
+ *returnOrigin = TEEC_ORIGIN_COMMS;
+ }
+ munmap(session->imp.tci, sysconf(_SC_PAGESIZE));
+ session->imp.tci = NULL;
+ }
+ return teecError;
+}
+
+//------------------------------------------------------------------------------
+__MC_CLIENT_LIB_API mcResult_t mcOpenGPTA(
+ mcSessionHandle_t *session,
+ const mcUuid_t *uuid,
+ uint8_t *tci,
+ uint32_t len
+);
+//------------------------------------------------------------------------------
+//TEEC_OpenSession: if the returnOrigin is different from TEEC_ORIGIN_TRUSTED_APP, an error code from Table 4-2
+// If the returnOrigin is equal to TEEC_ORIGIN_TRUSTED_APP, a return code defined by the
+//protocol between the Client Application and the Trusted Application.
+TEEC_Result TEEC_OpenSession (
+ TEEC_Context *context,
+ TEEC_Session *session,
+ const TEEC_UUID *destination,
+ uint32_t connectionMethod,
+ void *connectionData __unused,
+ TEEC_Operation *operation,
+ uint32_t *returnOrigin)
+{
+ mcResult_t mcRet;
+ TEEC_Result teecRes;
+ uint32_t returnOrigin_local;
+ mcUuid_t tauuid;
+
+ LOG_I("== %s() ==============", __func__);
+ // -------------------------------------------------------------
+ //The parameter context MUST point to an initialized TEE Context.
+ if (context == NULL) {
+ LOG_E("context is NULL");
+ if (returnOrigin != NULL) *returnOrigin = TEEC_ORIGIN_API;
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+
+ if (session == NULL) {
+ LOG_E("session is NULL");
+ if (returnOrigin != NULL) *returnOrigin = TEEC_ORIGIN_API;
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+
+ if (connectionMethod != TEEC_LOGIN_PUBLIC) {
+ //JACKET: Client authorization is not supported. The connectionMethod parameter
+ //must be TEEC LOGIN PUBLIC, otherwise return TEEC ERROR NOT IMPLEMENTED.
+ LOG_E("connectionMethod != TEEC_LOGIN_PUBLIC");
+ if (returnOrigin != NULL) *returnOrigin = TEEC_ORIGIN_API;
+ return TEEC_ERROR_NOT_IMPLEMENTED;
+ }
+
+ // -------------------------------------------------------------
+ session->imp.active = false;
+
+ _libUuidToArray((TEEC_UUID *)destination, (uint8_t *)tauuid.value);
+
+ if (operation) operation->imp.session = &session->imp;
+
+ //Allocate a 4kB page with mmap, zero it out, and set session->imp.tci to its address.
+ session->imp.tci = NULL;
+ void *bulkBuf = (void *)mmap(0, sysconf(_SC_PAGESIZE), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (bulkBuf == MAP_FAILED) {
+ LOG_E("mmap filed on tci buffer allocation");
+ if (returnOrigin != NULL) *returnOrigin = TEEC_ORIGIN_API;
+ return TEEC_ERROR_OUT_OF_MEMORY;
+ }
+
+ session->imp.tci = bulkBuf;
+ memset(session->imp.tci, 0, sysconf(_SC_PAGESIZE));
+
+ pthread_mutex_init(&session->imp.mutex_tci, NULL);
+ pthread_mutex_lock(&session->imp.mutex_tci);
+
+ //Fill the TCI buffer session.tci with the destination UUID.
+ memcpy(&(((_TEEC_TCI *)session->imp.tci)->destination), destination, sizeof(TEEC_UUID));
+ // -------------------------------------------------------------
+ memset(&session->imp.handle, 0, sizeof(mcSessionHandle_t));
+ session->imp.handle.deviceId = context->imp.reserved ; // The device ID (default device is used)
+ mcRet = mcOpenGPTA(
+ &session->imp.handle,
+ &tauuid,
+ (uint8_t *)session->imp.tci,
+ sizeof(_TEEC_TCI));
+ if (mcRet != MC_DRV_OK) {
+ LOG_E("mcOpenTrustlet failed (%08x)", mcRet);
+ if (returnOrigin != NULL) *returnOrigin = TEEC_ORIGIN_COMMS;
+ if (mcRet == MC_DRV_ERR_TRUSTED_APPLICATION_NOT_FOUND) {
+ teecRes = TEEC_ERROR_ITEM_NOT_FOUND;
+ } else {
+ //TODO: Improve the error codes
+ teecRes = TEEC_ERROR_GENERIC;
+ }
+ goto error;
+ }
+
+ session->imp.active = true;
+
+ // Let TA go through entry points
+ LOG_I(" let TA go through entry points");
+ ((_TEEC_TCI *)session->imp.tci)->operation.type = _TA_OPERATION_OPEN_SESSION;
+ teecRes = _TEEC_CallTA(session, operation, &returnOrigin_local);
+
+ // Check for error on communication level
+ if (teecRes != TEEC_SUCCESS ) {
+ LOG_E("_TEEC_CallTA failed(%08x)", teecRes);
+ // Nothing to do here because _TEEC_CallTA closes broken sessions
+ if (returnOrigin != NULL) *returnOrigin = returnOrigin_local;
+ goto error;
+ }
+ LOG_I(" no errors in com layer");
+
+ // Check for error from TA
+ if (returnOrigin != NULL) *returnOrigin = ((_TEEC_TCI *)session->imp.tci)->returnOrigin;
+ teecRes = ((_TEEC_TCI *)session->imp.tci)->returnStatus;
+ if (teecRes != TEEC_SUCCESS ) {
+ LOG_E("TA OpenSession EP failed(%08x)", teecRes);
+ goto error;
+ }
+
+ LOG_I(" %s() = TEEC_SUCCESS ", __func__);
+ pthread_mutex_unlock(&session->imp.mutex_tci);
+
+ if (returnOrigin != NULL) *returnOrigin = TEEC_ORIGIN_TRUSTED_APP;
+ return TEEC_SUCCESS;
+
+ // -------------------------------------------------------------
+error:
+ if (session->imp.active) {
+ // After notifying us, TA went to Destry EP, so close session now
+ mcRet = mcCloseSession(&session->imp.handle);
+ if (mcRet != MC_DRV_OK) {
+ LOG_E("mcCloseSession failed (%08x)", mcRet);
+ /* continue even in case of error */;
+ }
+ session->imp.active = false;
+ }
+
+ pthread_mutex_unlock(&session->imp.mutex_tci);
+ pthread_mutex_destroy(&session->imp.mutex_tci);
+ if (session->imp.tci) {
+ munmap(session->imp.tci, sysconf(_SC_PAGESIZE));
+ session->imp.tci = NULL;
+ }
+
+ LOG_I(" %s() = 0x%x", __func__, teecRes);
+ return teecRes;
+}
+
+//------------------------------------------------------------------------------
+TEEC_Result TEEC_InvokeCommand(
+ TEEC_Session *session,
+ uint32_t commandID,
+ TEEC_Operation *operation,
+ uint32_t *returnOrigin)
+{
+ TEEC_Result teecRes;
+ uint32_t returnOrigin_local;
+
+ LOG_I("== %s() ==============", __func__);
+
+ // -------------------------------------------------------------
+ if (session == NULL) {
+ LOG_E("session is NULL");
+ if (returnOrigin != NULL) *returnOrigin = TEEC_ORIGIN_API;
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+
+ if (!session->imp.active) {
+ LOG_E("session is inactive");
+ if (returnOrigin != NULL) *returnOrigin = TEEC_ORIGIN_API;
+ return TEEC_ERROR_BAD_STATE;
+ }
+ // -------------------------------------------------------------
+ if (operation) operation->imp.session = &session->imp;
+
+ pthread_mutex_lock(&session->imp.mutex_tci);
+
+ // Call TA
+ ((_TEEC_TCI *)session->imp.tci)->operation.commandId = commandID;
+ ((_TEEC_TCI *)session->imp.tci)->operation.type = _TA_OPERATION_INVOKE_COMMAND;
+ teecRes = _TEEC_CallTA(session, operation, &returnOrigin_local);
+ if (teecRes != TEEC_SUCCESS ) {
+ LOG_E("_TEEC_CallTA failed(%08x)", teecRes);
+ if (returnOrigin != NULL) *returnOrigin = returnOrigin_local;
+ } else {
+ if (returnOrigin != NULL) *returnOrigin = ((_TEEC_TCI *)session->imp.tci)->returnOrigin;
+ teecRes = ((_TEEC_TCI *)session->imp.tci)->returnStatus;
+ }
+
+ pthread_mutex_unlock(&session->imp.mutex_tci);
+ LOG_I(" %s() = 0x%x", __func__, teecRes);
+ return teecRes;
+}
+
+//------------------------------------------------------------------------------
+void TEEC_CloseSession(TEEC_Session *session)
+{
+ mcResult_t mcRet;
+ TEEC_Result teecRes = TEEC_SUCCESS;
+ uint32_t returnOrigin;
+
+ LOG_I("== %s() ==============", __func__);
+
+ // -------------------------------------------------------------
+ //The Implementation MUST do nothing if the session parameter is NULL.
+ if (session == NULL) {
+ LOG_E("session is NULL");
+ return;
+ }
+
+ // -------------------------------------------------------------
+ if (session->imp.active) {
+ // Let TA go through CloseSession and Destroy entry points
+ LOG_I(" let TA go through close entry points");
+ pthread_mutex_lock(&session->imp.mutex_tci);
+ ((_TEEC_TCI *)session->imp.tci)->operation.type = _TA_OPERATION_CLOSE_SESSION;
+ teecRes = _TEEC_CallTA(session, NULL, &returnOrigin);
+ if (teecRes != TEEC_SUCCESS ) {
+ /* continue even in case of error */;
+ LOG_E("_TEEC_CallTA failed(%08x)", teecRes);
+ }
+
+ if (session->imp.active) {
+ // Close Session
+ mcRet = mcCloseSession(&session->imp.handle);
+ if (mcRet != MC_DRV_OK) {
+ LOG_E("mcCloseSession failed (%08x)", mcRet);
+ /* ignore error and also there shouldn't be one */
+ }
+ }
+ pthread_mutex_unlock(&session->imp.mutex_tci);
+ }
+
+ pthread_mutex_destroy(&session->imp.mutex_tci);
+ if (session->imp.tci) {
+ munmap(session->imp.tci, sysconf(_SC_PAGESIZE));
+ session->imp.tci = NULL;
+ }
+ session->imp.active = false;
+
+ LOG_I(" %s() = 0x%x", __func__, teecRes);
+}
+
+//------------------------------------------------------------------------------
+TEEC_Result TEEC_RegisterSharedMemory(
+ TEEC_Context *context,
+ TEEC_SharedMemory *sharedMem)
+{
+ LOG_I("== %s() ==============", __func__);
+
+ //The parameter context MUST point to an initialized TEE Context.
+ if (context == NULL) {
+ LOG_E("context is NULL");
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+ //The parameter sharedMem MUST point to the Shared Memory structure defining
+ //the memory region to register.
+ if (sharedMem == NULL) {
+ LOG_E("sharedMem is NULL");
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+ //The buffer field MUST point to the memory region to be shared, and MUST not be NULL.
+ if (sharedMem->buffer == NULL) {
+ LOG_E("sharedMem->buffer is NULL");
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+
+ sharedMem->imp.implementation_allocated = false;
+ return TEEC_SUCCESS;
+}
+
+//------------------------------------------------------------------------------
+TEEC_Result TEEC_AllocateSharedMemory(
+ TEEC_Context *context,
+ TEEC_SharedMemory *sharedMem)
+{
+ //No connection to "context"?
+ LOG_I("== %s() ==============", __func__);
+
+ //The parameter context MUST point to an initialized TEE Context.
+ if (context == NULL) {
+ LOG_E("context is NULL");
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+ //The parameter sharedMem MUST point to the Shared Memory structure defining
+ //the memory region to register.
+ if (sharedMem == NULL) {
+ LOG_E("sharedMem is NULL");
+ return TEEC_ERROR_BAD_PARAMETERS;
+ }
+
+ sharedMem->buffer = malloc(sharedMem->size);
+ if (sharedMem->buffer == NULL) {
+ LOG_E("malloc failed");
+ return TEEC_ERROR_OUT_OF_MEMORY;
+ }
+ sharedMem->imp.implementation_allocated = true;
+
+ return TEEC_SUCCESS;
+}
+
+//------------------------------------------------------------------------------
+void TEEC_ReleaseSharedMemory (
+ TEEC_SharedMemory *sharedMem)
+{
+ //No connection to "context"?
+ LOG_I("== %s() ==============", __func__);
+
+ //The Implementation MUST do nothing if the sharedMem parameter is NULL
+ if (sharedMem == NULL) {
+ LOG_E("sharedMem is NULL");
+ return;
+ }
+
+ //For a memory buffer allocated using TEEC_AllocateSharedMemory the Implementation
+ //MUST free the underlying memory
+ if (sharedMem->imp.implementation_allocated) {
+ if (sharedMem->buffer) {
+ free(sharedMem->buffer);
+ sharedMem->buffer = NULL;
+ sharedMem->size = 0;
+ }
+ }
+
+ //TODO: Attempting to release Shared Memory which is used by a pending operation.
+
+}
+
+//------------------------------------------------------------------------------
+void TEEC_RequestCancellation(
+ TEEC_Operation *operation)
+{
+ LOG_I("== %s() ==============", __func__);
+
+ while (operation->started == 0);
+
+ LOG_I("while(operation->started ==0) passed");
+
+ if (operation->started > 1) {
+ LOG_I("The operation has finished");
+ return;
+ }
+
+ TEEC_Session_IMP *session = operation->imp.session;
+ operation->started = 2;
+
+ if (!session->active) {
+ LOG_I("Corresponding session is not active");
+ return;
+ }
+ ((_TEEC_TCI *)session->tci)->operation.isCancelled = true;
+
+ // Step 4.3: signal the Trustlet
+ mcResult_t mcRet = mcNotify(&session->handle);
+ if (MC_DRV_OK != mcRet) {
+ LOG_E("Notify failed (%08x)", mcRet);
+ }
+}
+
+//------------------------------------------------------------------------------
--- /dev/null
+/** @addtogroup MCD_IMPL_LIB
+ * @{
+ * @file
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdint.h>
+#include <vector>
+
+#include "mc_linux.h"
+
+#include "Session.h"
+
+#include "log.h"
+#include <assert.h>
+
+
+//------------------------------------------------------------------------------
+Session::Session(
+ uint32_t sessionId,
+ CMcKMod *mcKMod,
+ Connection *connection)
+{
+ this->sessionId = sessionId;
+ this->mcKMod = mcKMod;
+ this->notificationConnection = connection;
+
+ sessionInfo.lastErr = SESSION_ERR_NO;
+ sessionInfo.state = SESSION_STATE_INITIAL;
+}
+
+
+//------------------------------------------------------------------------------
+Session::~Session(void)
+{
+ BulkBufferDescriptor *pBlkBufDescr;
+
+ // Unmap still mapped buffers
+ for ( bulkBufferDescrIterator_t iterator = bulkBufferDescriptors.begin();
+ iterator != bulkBufferDescriptors.end();
+ ++iterator) {
+ pBlkBufDescr = *iterator;
+
+ LOG_I("removeBulkBuf - handle= %d",
+ pBlkBufDescr->handle);
+
+ // ignore any error, as we cannot do anything in this case.
+ int ret = mcKMod->unregisterWsmL2(pBlkBufDescr->handle);
+ if (ret != 0) {
+ LOG_E("removeBulkBuf(): mcKModUnregisterWsmL2 failed: %d", ret);
+ }
+
+ //iterator = bulkBufferDescriptors.erase(iterator);
+ delete(pBlkBufDescr);
+ }
+
+ // Finally delete notification connection
+ delete notificationConnection;
+
+ unlock();
+}
+
+
+//------------------------------------------------------------------------------
+void Session::setErrorInfo(
+ int32_t err
+)
+{
+ sessionInfo.lastErr = err;
+}
+
+
+//------------------------------------------------------------------------------
+int32_t Session::getLastErr(
+ void
+)
+{
+ return sessionInfo.lastErr;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t Session::addBulkBuf(addr_t buf, uint32_t len, BulkBufferDescriptor **blkBuf)
+{
+ uint64_t pPhysWsmL2;
+ uint32_t handle;
+
+ assert(blkBuf != NULL);
+
+ // Search bulk buffer descriptors for existing vAddr
+ // At the moment a virtual address can only be added one time
+ for ( bulkBufferDescrIterator_t iterator = bulkBufferDescriptors.begin();
+ iterator != bulkBufferDescriptors.end();
+ ++iterator) {
+ if ((*iterator)->virtAddr == buf) {
+ LOG_E("Cannot map a buffer to multiple locations in one Trustlet.");
+ return MC_DRV_ERR_BUFFER_ALREADY_MAPPED;
+ }
+ }
+
+ // Prepare the interface structure for memory registration in Kernel Module
+ mcResult_t ret = mcKMod->registerWsmL2(buf, len, 0, &handle, &pPhysWsmL2);
+
+ if (ret != MC_DRV_OK) {
+ LOG_V(" mcKMod->registerWsmL2() failed with %x", ret);
+ return ret;
+ }
+
+ LOG_V(" addBulkBuf - Handle of L2 Table = %u", handle);
+
+ // Create new descriptor - secure virtual virtual set to 0, unknown!
+ *blkBuf = new BulkBufferDescriptor(buf, 0x0, len, handle);
+
+ // Add to vector of descriptors
+ bulkBufferDescriptors.push_back(*blkBuf);
+
+ return MC_DRV_OK;
+}
+
+//------------------------------------------------------------------------------
+void Session::addBulkBuf(BulkBufferDescriptor *blkBuf)
+{
+ if (blkBuf)
+ // Add to vector of descriptors
+ bulkBufferDescriptors.push_back(blkBuf);
+}
+
+//------------------------------------------------------------------------------
+uint32_t Session::getBufHandle(addr_t sVirtAddr, uint32_t sVirtualLen)
+{
+ LOG_V("getBufHandle(): Secure Virtual Address = 0x%X", (unsigned int) sVirtAddr);
+
+ // Search and remove bulk buffer descriptor
+ for ( bulkBufferDescrIterator_t iterator = bulkBufferDescriptors.begin();
+ iterator != bulkBufferDescriptors.end();
+ ++iterator ) {
+ if (((*iterator)->sVirtualAddr == sVirtAddr) && ((*iterator)->len == sVirtualLen)) {
+ return (*iterator)->handle;
+ }
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t Session::removeBulkBuf(addr_t virtAddr)
+{
+ BulkBufferDescriptor *pBlkBufDescr = NULL;
+
+ LOG_V("removeBulkBuf(): Virtual Address = 0x%X", (unsigned int) virtAddr);
+
+ // Search and remove bulk buffer descriptor
+ for ( bulkBufferDescrIterator_t iterator = bulkBufferDescriptors.begin();
+ iterator != bulkBufferDescriptors.end();
+ ++iterator
+ ) {
+
+ if ((*iterator)->virtAddr == virtAddr) {
+ pBlkBufDescr = *iterator;
+ iterator = bulkBufferDescriptors.erase(iterator);
+ break;
+ }
+ }
+
+ if (pBlkBufDescr == NULL) {
+ LOG_E("%p not registered in session %d.", virtAddr, sessionId);
+ return MC_DRV_ERR_BLK_BUFF_NOT_FOUND;
+ }
+ LOG_V("removeBulkBuf():handle=%u", pBlkBufDescr->handle);
+
+ // ignore any error, as we cannot do anything
+ mcResult_t ret = mcKMod->unregisterWsmL2(pBlkBufDescr->handle);
+ if (ret != MC_DRV_OK) {
+ LOG_E("mcKMod->unregisterWsmL2 failed: %x", ret);
+ return ret;
+ }
+
+ delete (pBlkBufDescr);
+
+ return MC_DRV_OK;
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_IMPL_LIB
+ * @{
+ * @file
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef SESSION_H_
+#define SESSION_H_
+
+#include <stdint.h>
+#include <list>
+
+#include "mc_linux.h"
+#include "Connection.h"
+#include "CMcKMod.h"
+#include "CMutex.h"
+
+
+class BulkBufferDescriptor
+{
+public:
+ addr_t virtAddr; /**< The virtual address of the Bulk buffer*/
+ addr_t sVirtualAddr; /**< The secure virtual address of the Bulk buffer*/
+ uint32_t len; /**< Length of the Bulk buffer*/
+ uint32_t handle;
+
+ BulkBufferDescriptor(
+ addr_t virtAddr,
+ addr_t sVirtAddr,
+ uint32_t len,
+ uint32_t handle
+ ) :
+ virtAddr(virtAddr),
+ sVirtualAddr(sVirtAddr),
+ len(len),
+ handle(handle)
+ {};
+
+};
+
+typedef std::list<BulkBufferDescriptor *> bulkBufferDescrList_t;
+typedef bulkBufferDescrList_t::iterator bulkBufferDescrIterator_t;
+
+
+/** Session states.
+ * At the moment not used !!.
+ */
+typedef enum {
+ SESSION_STATE_INITIAL,
+ SESSION_STATE_OPEN,
+ SESSION_STATE_TRUSTLET_DEAD
+} sessionState_t;
+
+#define SESSION_ERR_NO 0 /**< No session error */
+
+/** Session information structure.
+ * The information structure is used to hold the state of the session, which will limit further actions for the session.
+ * Also the last error code will be stored till it's read.
+ */
+typedef struct {
+ sessionState_t state; /**< Session state */
+ int32_t lastErr; /**< Last error of session */
+} sessionInformation_t;
+
+
+class Session
+{
+private:
+ CMcKMod *mcKMod;
+ CMutex workLock;
+ bulkBufferDescrList_t bulkBufferDescriptors; /**< Descriptors of additional bulk buffer of a session */
+ sessionInformation_t sessionInfo; /**< Informations about session */
+public:
+ uint32_t sessionId;
+ Connection *notificationConnection;
+
+ Session(uint32_t sessionId, CMcKMod *mcKMod, Connection *connection);
+
+ virtual ~Session(void);
+
+ /**
+ * Add address information of additional bulk buffer memory to session and
+ * register virtual memory in kernel module.
+ *
+ * @attention The virtual address can only be added one time. If the virtual address already exist, MC_DRV_ERR_BUFFER_ALREADY_MAPPED is returned.
+ *
+ * @param buf The virtual address of bulk buffer.
+ * @param len Length of bulk buffer.
+ * @param blkBuf pointer of the actual Bulk buffer descriptor with all address information.
+ *
+ * @return MC_DRV_OK on success
+ * @return MC_DRV_ERR_BUFFER_ALREADY_MAPPED
+ */
+ mcResult_t addBulkBuf(addr_t buf, uint32_t len, BulkBufferDescriptor **blkBuf);
+
+ /**
+ * Just register the buffer previously created to the session
+ *
+ * @attention The virtual address can only be added one time. If the virtual address already exist, MC_DRV_ERR_BUFFER_ALREADY_MAPPED is returned.
+ *
+ * @param blkBuf pointer of the actual Bulk buffer descriptor with all address information.
+ *
+ */
+ void addBulkBuf(BulkBufferDescriptor *blkBuf);
+
+ /**
+ * Remove address information of additional bulk buffer memory from session and
+ * unregister virtual memory in kernel module
+ *
+ * @param buf The virtual address of the bulk buffer.
+ *
+ * @return true on success.
+ */
+ mcResult_t removeBulkBuf(addr_t buf);
+
+ /**
+ * Return the Kmod handle of the bulk buff
+ *
+ * @param buf The secure virtual address of the bulk buffer.
+ *
+ * @return the Handle or 0 for failure
+ */
+ uint32_t getBufHandle(addr_t sVirtAddr, uint32_t sVirtualLen);
+
+ /**
+ * Set additional error information of the last error that occured.
+ *
+ * @param errorCode The actual error.
+ */
+ void setErrorInfo(int32_t err);
+
+ /**
+ * Get additional error information of the last error that occured.
+ *
+ * @attention After request the information is set to SESSION_ERR_NO.
+ *
+ * @return Last stored error code or SESSION_ERR_NO.
+ */
+ int32_t getLastErr(void);
+
+ /**
+ * Lock session for operation
+ */
+ void lock() {
+ workLock.lock();
+ }
+
+ /**
+ * Unlock session for operation
+ */
+ void unlock() {
+ workLock.unlock();
+ }
+};
+
+typedef std::list<Session *> sessionList_t;
+typedef sessionList_t::iterator sessionIterator_t;
+
+#endif /* SESSION_H_ */
+
+/** @} */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This header file corresponds to V1.0 of the GlobalPlatform
+ * TEE Client API Specification
+ */
+#ifndef __TEE_CLIENT_API_H__
+#define __TEE_CLIENT_API_H__
+
+#include "tee_type.h"
+#include "tee_error.h"
+
+#if TBASE_API_LEVEL >= 3
+
+#if (!defined(TEEC_EXPORT)) && __cplusplus
+#define TEEC_EXPORT extern "C"
+#else
+#define TEEC_EXPORT
+#endif // __cplusplus
+
+
+
+/* The header tee_client_api_imp.h must define implementation-dependent
+ types, constants and macros.
+
+ The implementation-dependent types are:
+ - TEEC_Context_IMP
+ - TEEC_Session_IMP
+ - TEEC_SharedMemory_IMP
+ - TEEC_Operation_IMP
+
+ The implementation-dependent constants are:
+ - TEEC_CONFIG_SHAREDMEM_MAX_SIZE
+ The implementation-dependent macros are:
+ - TEEC_PARAM_TYPES
+*/
+
+typedef struct {
+ uint32_t a;
+ uint32_t b;
+} TEEC_Value;
+
+
+#include "tee_client_api_imp.h"
+
+/* Type definitions */
+typedef struct TEEC_Context {
+ TEEC_Context_IMP imp;
+} TEEC_Context;
+
+typedef struct TEEC_Session {
+ TEEC_Session_IMP imp;
+} TEEC_Session;
+
+typedef struct TEEC_SharedMemory {
+ void *buffer;
+ size_t size;
+ uint32_t flags;
+ TEEC_SharedMemory_IMP imp;
+} TEEC_SharedMemory;
+
+typedef struct {
+ void *buffer;
+ size_t size;
+} TEEC_TempMemoryReference;
+
+typedef struct {
+ TEEC_SharedMemory *parent;
+ size_t size;
+ size_t offset;
+} TEEC_RegisteredMemoryReference;
+
+
+
+typedef union {
+ TEEC_TempMemoryReference tmpref;
+ TEEC_RegisteredMemoryReference memref;
+ TEEC_Value value;
+} TEEC_Parameter;
+
+typedef struct TEEC_Operation {
+ volatile uint32_t started;
+ uint32_t paramTypes;
+ TEEC_Parameter params[4];
+ TEEC_Operation_IMP imp;
+} TEEC_Operation;
+
+
+#define TEEC_ORIGIN_API 0x00000001
+#define TEEC_ORIGIN_COMMS 0x00000002
+#define TEEC_ORIGIN_TEE 0x00000003
+#define TEEC_ORIGIN_TRUSTED_APP 0x00000004
+
+#define TEEC_MEM_INPUT 0x00000001
+#define TEEC_MEM_OUTPUT 0x00000002
+
+#define TEEC_NONE 0x0
+#define TEEC_VALUE_INPUT 0x1
+#define TEEC_VALUE_OUTPUT 0x2
+#define TEEC_VALUE_INOUT 0x3
+#define TEEC_MEMREF_TEMP_INPUT 0x5
+#define TEEC_MEMREF_TEMP_OUTPUT 0x6
+#define TEEC_MEMREF_TEMP_INOUT 0x7
+#define TEEC_MEMREF_WHOLE 0xC
+#define TEEC_MEMREF_PARTIAL_INPUT 0xD
+#define TEEC_MEMREF_PARTIAL_OUTPUT 0xE
+#define TEEC_MEMREF_PARTIAL_INOUT 0xF
+
+#define TEEC_LOGIN_PUBLIC 0x00000000
+#define TEEC_LOGIN_USER 0x00000001
+#define TEEC_LOGIN_GROUP 0x00000002
+#define TEEC_LOGIN_APPLICATION 0x00000004
+#define TEEC_LOGIN_USER_APPLICATION 0x00000005
+#define TEEC_LOGIN_GROUP_APPLICATION 0x00000006
+
+#pragma GCC visibility push(default)
+
+TEEC_EXPORT TEEC_Result TEEC_InitializeContext(
+ const char *name,
+ TEEC_Context *context);
+
+TEEC_EXPORT void TEEC_FinalizeContext(
+ TEEC_Context *context);
+
+TEEC_EXPORT TEEC_Result TEEC_RegisterSharedMemory(
+ TEEC_Context *context,
+ TEEC_SharedMemory *sharedMem);
+
+TEEC_EXPORT TEEC_Result TEEC_AllocateSharedMemory(
+ TEEC_Context *context,
+ TEEC_SharedMemory *sharedMem);
+
+TEEC_EXPORT void TEEC_ReleaseSharedMemory (
+ TEEC_SharedMemory *sharedMem);
+
+TEEC_EXPORT TEEC_Result TEEC_OpenSession (
+ TEEC_Context *context,
+ TEEC_Session *session,
+ const TEEC_UUID *destination,
+ uint32_t connectionMethod,
+ void *connectionData,
+ TEEC_Operation *operation,
+ uint32_t *returnOrigin);
+
+TEEC_EXPORT void TEEC_CloseSession (
+ TEEC_Session *session);
+
+TEEC_EXPORT TEEC_Result TEEC_InvokeCommand(
+ TEEC_Session *session,
+ uint32_t commandID,
+ TEEC_Operation *operation,
+ uint32_t *returnOrigin);
+
+TEEC_EXPORT void TEEC_RequestCancellation(
+ TEEC_Operation *operation);
+
+#pragma GCC visibility pop
+
+#endif /* TBASE_API_LEVEL */
+
+#endif /* __TEE_CLIENT_API_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This header file defines the implementation-dependent types,
+ * constants and macros for all the Trusted Foundations implementations
+ * of the TEE Client API
+ */
+#ifndef __TEE_CLIENT_API_IMP_H__
+#define __TEE_CLIENT_API_IMP_H__
+
+#if TBASE_API_LEVEL >= 3
+
+#include <pthread.h>
+
+#include "tee_type.h"
+#include "tee_error.h"
+#include "MobiCoreDriverApi.h"
+
+
+typedef struct {
+ uint32_t reserved;
+}
+TEEC_Context_IMP;
+
+
+typedef struct {
+ mcSessionHandle_t handle;
+ void *tci;
+ bool active;
+ pthread_mutex_t mutex_tci; //mutex to serialize CA requests
+}
+TEEC_Session_IMP;
+
+typedef struct {
+ bool implementation_allocated;
+}
+TEEC_SharedMemory_IMP;
+
+typedef struct {
+ TEEC_Session_IMP *session;
+}
+TEEC_Operation_IMP;
+
+/* There is no natural, compile-time limit on the shared memory, but a specific
+ implementation may introduce a limit (in particular on TrustZone) */
+#define TEEC_CONFIG_SHAREDMEM_MAX_SIZE ((size_t)0xFFFFFFFF)
+
+#define TEEC_PARAM_TYPES(entry0Type, entry1Type, entry2Type, entry3Type) \
+ ((entry0Type) | ((entry1Type) << 4) | ((entry2Type) << 8) | ((entry3Type) << 12))
+
+#endif /* TBASE_API_LEVEL */
+
+#endif /* __TEE_CLIENT_API_IMP_H__ */
--- /dev/null
+/**
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __TEE_ERROR_H__
+#define __TEE_ERROR_H__
+
+#define TEE_SUCCESS ((TEE_Result)0x00000000)
+#define TEEC_SUCCESS TEE_SUCCESS
+
+#define TEE_ERROR_CORRUPT_OBJECT ((TEE_Result)0xF0100001)
+#define TEE_ERROR_CORRUPT_OBJECT_2 ((TEE_Result)0xF0100002)
+
+/**
+ * Generic error code : Generic error
+ **/
+#define TEE_ERROR_GENERIC ((TEE_Result)0xFFFF0000)
+#define TEEC_ERROR_GENERIC TEE_ERROR_GENERIC
+
+/**
+ * Generic error code : The underlying security system denies the access to the
+ * object
+ **/
+#define TEE_ERROR_ACCESS_DENIED ((TEE_Result)0xFFFF0001)
+#define TEEC_ERROR_ACCESS_DENIED TEE_ERROR_ACCESS_DENIED
+
+/**
+ * Generic error code : The pending operation is cancelled.
+ **/
+#define TEE_ERROR_CANCEL ((TEE_Result)0xFFFF0002)
+#define TEEC_ERROR_CANCEL TEE_ERROR_CANCEL
+
+/**
+ * Generic error code : The underlying system detects a conflict
+ **/
+#define TEE_ERROR_ACCESS_CONFLICT ((TEE_Result)0xFFFF0003)
+#define TEEC_ERROR_ACCESS_CONFLICT TEE_ERROR_ACCESS_CONFLICT
+
+/**
+ * Generic error code : Too much data for the operation or some data remain
+ * unprocessed by the operation.
+ **/
+#define TEE_ERROR_EXCESS_DATA ((TEE_Result)0xFFFF0004)
+#define TEEC_ERROR_EXCESS_DATA TEE_ERROR_EXCESS_DATA
+
+/**
+ * Generic error code : Error of data format
+ **/
+#define TEE_ERROR_BAD_FORMAT ((TEE_Result)0xFFFF0005)
+#define TEEC_ERROR_BAD_FORMAT TEE_ERROR_BAD_FORMAT
+
+/**
+ * Generic error code : The specified parameters are invalid
+ **/
+#define TEE_ERROR_BAD_PARAMETERS ((TEE_Result)0xFFFF0006)
+#define TEEC_ERROR_BAD_PARAMETERS TEE_ERROR_BAD_PARAMETERS
+
+
+/**
+ * Generic error code : Illegal state for the operation.
+ **/
+#define TEE_ERROR_BAD_STATE ((TEE_Result)0xFFFF0007)
+#define TEEC_ERROR_BAD_STATE TEE_ERROR_BAD_STATE
+
+/**
+ * Generic error code : The item is not found
+ **/
+#define TEE_ERROR_ITEM_NOT_FOUND ((TEE_Result)0xFFFF0008)
+#define TEEC_ERROR_ITEM_NOT_FOUND TEE_ERROR_ITEM_NOT_FOUND
+
+/**
+ * Generic error code : The specified operation is not implemented
+ **/
+#define TEE_ERROR_NOT_IMPLEMENTED ((TEE_Result)0xFFFF0009)
+#define TEEC_ERROR_NOT_IMPLEMENTED TEE_ERROR_NOT_IMPLEMENTED
+
+/**
+ * Generic error code : The specified operation is not supported
+ **/
+#define TEE_ERROR_NOT_SUPPORTED ((TEE_Result)0xFFFF000A)
+#define TEEC_ERROR_NOT_SUPPORTED TEE_ERROR_NOT_SUPPORTED
+
+/**
+ * Generic error code : Insufficient data is available for the operation.
+ **/
+#define TEE_ERROR_NO_DATA ((TEE_Result)0xFFFF000B)
+#define TEEC_ERROR_NO_DATA TEE_ERROR_NO_DATA
+
+/**
+ * Generic error code : Not enough memory to perform the operation
+ **/
+#define TEE_ERROR_OUT_OF_MEMORY ((TEE_Result)0xFFFF000C)
+#define TEEC_ERROR_OUT_OF_MEMORY TEE_ERROR_OUT_OF_MEMORY
+
+/**
+ * Generic error code : The service is currently unable to handle the request;
+ * try later
+ **/
+#define TEE_ERROR_BUSY ((TEE_Result)0xFFFF000D)
+#define TEEC_ERROR_BUSY TEE_ERROR_BUSY
+
+/**
+ * Generic communication error
+ **/
+#define TEE_ERROR_COMMUNICATION ((TEE_Result)0xFFFF000E)
+#define TEEC_ERROR_COMMUNICATION TEE_ERROR_COMMUNICATION
+
+/**
+ * Generic error code : security violation
+ **/
+#define TEE_ERROR_SECURITY ((TEE_Result)0xFFFF000F)
+#define TEEC_ERROR_SECURITY TEE_ERROR_SECURITY
+
+/**
+ * Generic error code : the buffer is too short
+ **/
+#define TEE_ERROR_SHORT_BUFFER ((TEE_Result)0xFFFF0010)
+#define TEEC_ERROR_SHORT_BUFFER TEE_ERROR_SHORT_BUFFER
+
+/**
+ * Generic error code : The pending operation is cancelled.
+ */
+#define TEE_ERROR_EXTERNAL_CANCEL ((TEE_Result)0xFFFF0011)
+
+/**
+ * Generic error code : the operation is not terminated
+ **/
+#define TEE_PENDING ((TEE_Result)0xFFFF2000)
+
+/**
+ * Generic error code : A timeout occurred
+ **/
+#define TEE_ERROR_TIMEOUT ((TEE_Result)0xFFFF3001)
+
+/**
+ * Generic error code : Overflow
+ **/
+#define TEE_ERROR_OVERFLOW ((TEE_Result)0xFFFF300F)
+
+/**
+ * Error of communication: The target of the connection is dead
+ **/
+#define TEE_ERROR_TARGET_DEAD ((TEE_Result)0xFFFF3024)
+#define TEEC_ERROR_TARGET_DEAD TEE_ERROR_TARGET_DEAD
+
+/*------------------------------------------------------------------------------
+ Storage Error Codes
+------------------------------------------------------------------------------*/
+
+/** File system error code: not enough space to complete the operation. */
+#define TEE_ERROR_STORAGE_NO_SPACE ((TEE_Result)0xFFFF3041)
+
+/*------------------------------------------------------------------------------
+ Crypto error codes
+------------------------------------------------------------------------------*/
+
+#define TEE_ERROR_MAC_INVALID ((TEE_Result)0xFFFF3071)
+
+#define TEE_ERROR_SIGNATURE_INVALID ((TEE_Result)0xFFFF3072)
+
+/*------------------------------------------------------------------------------
+ Date error codes
+------------------------------------------------------------------------------*/
+
+#define TEE_ERROR_TIME_NOT_SET ((TEE_Result)0xFFFF5000)
+
+#define TEE_ERROR_TIME_NEEDS_RESET ((TEE_Result)0xFFFF5001)
+
+#endif /* __TEE_ERROR_H__ */
+
--- /dev/null
+/**
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __TEE_INTERNAL_API_IMPL_H__
+#define __TEE_INTERNAL_API_IMPL_H__
+
+#if TBASE_API_LEVEL >= 3
+
+/*------------------------------------------------------------------------------
+ Constants
+------------------------------------------------------------------------------*/
+// Property type constants
+#define TEE_PROPERTY_TYPE_NONE 0
+#define TEE_PROPERTY_TYPE_BOOLEAN 1
+#define TEE_PROPERTY_TYPE_UINT32 2
+#define TEE_PROPERTY_TYPE_BINARY 3
+#define TEE_PROPERTY_TYPE_STRING 4
+#define TEE_PROPERTY_TYPE_UUID 5
+
+// Predefined offsets to properties
+#define TEE_PROPERTY_GPUUID_VALUE_OFFSET 20
+#define TEE_PROPERTY_DATASIZE_VALUE_OFFSET 152
+#define TEE_PROPERTY_STACKSIZE_VALUE_OFFSET 180
+
+#endif /* TBASE_API_LEVEL */
+
+#endif /* __TEE_INTERNAL_API_IMPL_H__ */
--- /dev/null
+/**
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+/**
+ * Definition of the machine-specific integer types
+ **/
+#ifndef __TEE_TYPE_H__
+#define __TEE_TYPE_H__
+
+/* C99 integer types */
+#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) &&(!defined(ANDROID))
+
+#include <limits.h>
+
+/* Figure out if a 64-bit integer types is available */
+#if \
+ defined(_MSC_VER) || \
+ defined(__SYMBIAN32__) || \
+ defined(_WIN32_WCE) || \
+ (defined(ULLONG_MAX) && ULLONG_MAX == 0xFFFFFFFFFFFFFFFFULL) || \
+ (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 0xFFFFFFFFFFFFFFFFULL)
+typedef unsigned long long uint64_t;
+typedef long long int64_t;
+#else
+#define __S_TYPE_INT64_UNDEFINED
+#endif
+
+#if UINT_MAX == 0xFFFFFFFF
+typedef unsigned int uint32_t;
+typedef int int32_t;
+#elif ULONG_MAX == 0xFFFFFFFF
+typedef unsigned long uint32_t;
+typedef long int32_t;
+#else
+#error This compiler is not supported.
+#endif
+
+#if USHRT_MAX == 0xFFFF
+typedef unsigned short uint16_t;
+typedef short int16_t;
+#else
+#error This compiler is not supported.
+#endif
+
+#if UCHAR_MAX == 0xFF
+typedef unsigned char uint8_t;
+typedef signed char int8_t;
+#else
+#error This compiler is not supported.
+#endif
+
+#if !defined(__cplusplus)
+typedef unsigned char bool;
+#define false ( (bool)0 )
+#define true ( (bool)1 )
+#endif
+
+#else /* !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L */
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#endif /* !(!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) */
+
+#include <stddef.h>
+
+#ifndef NULL
+# ifdef __cplusplus
+# define NULL 0
+# else
+# define NULL ((void *)0)
+# endif
+#endif
+
+#define IN
+#define OUT
+
+/*
+ * Definition of other common types
+ */
+
+// to delete when all completed
+typedef uint32_t TEE_Result;
+typedef TEE_Result TEEC_Result;
+
+typedef uint32_t TEE_HANDLE;
+
+/** Definition of an UUID (from RFC 4122 http://www.ietf.org/rfc/rfc4122.txt) */
+typedef struct TEE_UUID {
+ uint32_t timeLow;
+ uint16_t timeMid;
+ uint16_t timeHiAndVersion;
+ uint8_t clockSeqAndNode[8];
+} TEE_UUID;
+typedef TEE_UUID TEEC_UUID;
+
+/** Type definition for a TEE Identity */
+typedef struct TEE_Identity {
+ uint32_t login;
+ TEE_UUID uuid;
+} TEE_Identity;
+
+typedef struct __TEE_PropSetHandle {
+ unsigned char reserved;
+} __TEE_PropSetHandle;
+
+typedef struct __TEE_PropSetHandle* TEE_PropSetHandle;
+
+/* Property Sets Pseudo Handles */
+#define TEE_PROPSET_CURRENT_TA (TEE_PropSetHandle)0xFFFFFFFF
+#define TEE_PROPSET_CURRENT_CLIENT (TEE_PropSetHandle)0xFFFFFFFE
+#define TEE_PROPSET_TEE_IMPLEMENTATION (TEE_PropSetHandle)0xFFFFFFFD
+
+
+/* DLL Import/Export directives */
+
+#if defined(WIN32) || defined(__ARMCC_VERSION) || defined(__WINSCW__) || defined(_WIN32_WCE)
+# define S_DLL_EXPORT __declspec(dllexport)
+# define S_DLL_IMPORT __declspec(dllimport)
+# define S_NO_RETURN __declspec(noreturn)
+#elif defined(__GNUC__)
+# define S_DLL_EXPORT __attribute__ ((visibility ("default")))
+# define S_DLL_IMPORT __attribute__ ((visibility ("default")))
+# define S_NO_RETURN __attribute__ ((noreturn))
+#else
+# define S_DLL_EXPORT
+# define S_DLL_IMPORT
+# define S_NO_RETURN
+#endif
+
+#if defined(_MSC_VER)
+#define __func__ __FUNCTION__
+#endif
+
+#endif /* __TEE_TYPE_H__ */
--- /dev/null
+/**
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+#ifndef __TEE_UUID_ATTESTATION_H__
+#define __TEE_UUID_ATTESTATION_H__
+
+#include "tee_type.h"
+
+// Sizes of the fields of attestation structure
+#define AT_MAGIC_SIZE 8
+#define AT_SIZE_SIZE sizeof(uint32_t)
+#define AT_VERSION_SIZE sizeof(uint32_t)
+#define AT_UUID_SIZE sizeof(TEE_UUID)
+
+// Sizes of the fields used to generate signature
+#define AT_TAG_SIZE 20
+#define AT_SHA1_HASH_SIZE 20
+
+// Max size of RSA modulus supported
+#define AT_MODULUS_MAX_SIZE 256
+// Max size of RSA public exponent supported
+#define AT_PUBLIC_EXPO_MAX_SIZE 4
+
+// Attestation version
+#define AT_VERSION 1
+
+// Name space ID (the UUID of the RSA OID)
+const uint8_t RSA_OID_UUID[AT_UUID_SIZE] = {0x6b, 0x8e, 0x02, 0x6b, 0x63, 0xc1, 0x5d, 0x58, 0xb0, 0x64, 0x00, 0xd3, 0x51, 0x89, 0xce, 0x65};
+// Magic word
+const char MAGIC[AT_MAGIC_SIZE] = "TAUUID\0";
+
+// Tag for signature generation
+const char TAG[AT_TAG_SIZE]="Trusted Application";
+
+// Public key structure
+typedef struct uuid_public_key {
+ uint32_t type; // TEE TYPE RSA KEYPAIR: 0xa0000030
+ uint16_t modulus_bytes; // Length of the modulus in bytes
+ uint16_t exponent_bytes; // Length of the exponent in bytes
+ uint8_t data[]; // Key material
+} uuid_public_key;
+
+// Attestation structure
+typedef struct uuid_attestation {
+ uint8_t magic[AT_MAGIC_SIZE]; // Magic word: "TAUUID\0\0"
+ uint32_t size; // Attestation size (4 bytes)
+ uint32_t version; // Version number: 1 (4 bytes)
+ uint8_t uuid[AT_UUID_SIZE]; // UUID
+ uuid_public_key key; // Public key
+} uuid_attestation;
+
+#endif /* __TEE_UUID_ATTESTATION_H__ */
--- /dev/null
+/**
+ * @defgroup MCD_API MobiCore Driver API
+ * @addtogroup MCD_API
+ * @{
+ *
+ * @if DOXYGEN_MCDRV_API
+ * @mainpage MobiCore Driver API.
+ * @endif
+ *
+ * MobiCore Driver API.
+ *
+ * The MobiCore (MC) Driver API provides access functions to the t-base trusted execution environment and the contained Trusted Applications.
+ *
+ * @image html DoxyOverviewDrvApi500x.png
+ * @image latex DoxyOverviewDrvApi500x.png "t-base Overview" width=12cm
+ */
+/* <!-- Copyright Trustonic 2013-2014 -->
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef MCDRIVER_H_
+#define MCDRIVER_H_
+
+#if (!defined(__MC_CLIENT_LIB_API)) && __cplusplus
+#define __MC_CLIENT_LIB_API extern "C"
+#else
+#define __MC_CLIENT_LIB_API
+#endif // __cplusplus
+
+
+#include <stdint.h>
+#ifndef WIN32
+#include <stdbool.h>
+#endif
+
+#include "mcUuid.h"
+#include "mcSpid.h"
+#include "mcVersionInfo.h"
+
+/*
+ * MobiCore driver API error codes.
+ * MAJOR part of error code is stable.
+ * MCP part contains MCP result code. See MCI/mcimcp.h
+ * DETAIL part may be used in testing for specific error code.
+ *
+ * Detail error codes may change in different releases
+ * Please do not test DETAIL part when comparing error codes.
+ */
+#define MC_DRV_ERROR_MAJOR(ecode) ((ecode) & 0xFF) /**< Get MAJOR part of error code. */
+#define MC_DRV_ERROR_MCP(ecode) (((ecode)>>8) & 0xFF) /**< Get MCP part of error code. */
+#define MC_DRV_ERROR_DETAIL(ecode) (((ecode)>>16) & 0x0FFF) /**< Get detail part of error code. */
+
+typedef uint32_t mcResult_t;
+/**
+ * Return values of MobiCore driver functions.
+ */
+#define MC_DRV_OK 0x00000000 /**< Function call succeeded. */
+#define MC_DRV_NO_NOTIFICATION 0x00000001 /**< No notification available. */
+#define MC_DRV_ERR_NOTIFICATION 0x00000002 /**< Error during notification on communication level. */
+#define MC_DRV_ERR_NOT_IMPLEMENTED 0x00000003 /**< Function not implemented. */
+#define MC_DRV_ERR_OUT_OF_RESOURCES 0x00000004 /**< No more resources available. */
+#define MC_DRV_ERR_INIT 0x00000005 /**< Driver initialization failed. */
+#define MC_DRV_ERR_UNKNOWN 0x00000006 /**< Unknown error. */
+#define MC_DRV_ERR_UNKNOWN_DEVICE 0x00000007 /**< The specified device is unknown. */
+#define MC_DRV_ERR_UNKNOWN_SESSION 0x00000008 /**< The specified session is unknown. */
+#define MC_DRV_ERR_INVALID_OPERATION 0x00000009 /**< The specified operation is not allowed. */
+#define MC_DRV_ERR_INVALID_RESPONSE 0x0000000a /**< The response header from the MC is invalid. */
+#define MC_DRV_ERR_TIMEOUT 0x0000000b /**< Function call timed out. */
+#define MC_DRV_ERR_NO_FREE_MEMORY 0x0000000c /**< Can not allocate additional memory. */
+#define MC_DRV_ERR_FREE_MEMORY_FAILED 0x0000000d /**< Free memory failed. */
+#define MC_DRV_ERR_SESSION_PENDING 0x0000000e /**< Still some open sessions pending. */
+#define MC_DRV_ERR_DAEMON_UNREACHABLE 0x0000000f /**< MC daemon not reachable */
+#define MC_DRV_ERR_INVALID_DEVICE_FILE 0x00000010 /**< The device file of the kernel module could not be opened. */
+#define MC_DRV_ERR_INVALID_PARAMETER 0x00000011 /**< Invalid parameter. */
+#define MC_DRV_ERR_KERNEL_MODULE 0x00000012 /**< Error from Kernel Module, see DETAIL for errno. */
+#define MC_DRV_ERR_BULK_MAPPING 0x00000013 /**< Error during mapping of additional bulk memory to session. */
+#define MC_DRV_ERR_BULK_UNMAPPING 0x00000014 /**< Error during unmapping of additional bulk memory to session. */
+#define MC_DRV_INFO_NOTIFICATION 0x00000015 /**< Notification received, exit code available. */
+#define MC_DRV_ERR_NQ_FAILED 0x00000016 /**< Set up of NWd connection failed. */
+
+#define MC_DRV_ERR_DAEMON_VERSION 0x00000017 /**< Wrong daemon version. */
+#define MC_DRV_ERR_CONTAINER_VERSION 0x00000018 /**< Wrong container version. */
+
+// those should become MCP or even detail codes on top of MC_DRV_ERR_MCP_ERROR
+#define MC_DRV_ERR_WRONG_PUBLIC_KEY 0x00000019 /**< System Trustlet public key is wrong. */
+#define MC_DRV_ERR_CONTAINER_TYPE_MISMATCH 0x0000001a /**< Wrong container type(s). */
+#define MC_DRV_ERR_CONTAINER_LOCKED 0x0000001b /**< Container is locked (or not activated). */
+#define MC_DRV_ERR_SP_NO_CHILD 0x0000001c /**< SPID is not registered with root container. */
+#define MC_DRV_ERR_TL_NO_CHILD 0x0000001d /**< UUID is not registered with sp container. */
+#define MC_DRV_ERR_UNWRAP_ROOT_FAILED 0x0000001e /**< Unwrapping of root container failed. */
+#define MC_DRV_ERR_UNWRAP_SP_FAILED 0x0000001f /**< Unwrapping of service provider container failed. */
+#define MC_DRV_ERR_UNWRAP_TRUSTLET_FAILED 0x00000020 /**< Unwrapping of Trustlet container failed. */
+
+// use separate numbers for those in the future
+#define MC_DRV_ERR_DEVICE_ALREADY_OPEN MC_DRV_ERR_INVALID_OPERATION /** < Device is already open. */
+#define MC_DRV_ERR_SOCKET_CONNECT MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket not reachable. */
+#define MC_DRV_ERR_SOCKET_WRITE MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket write error. */
+#define MC_DRV_ERR_SOCKET_READ MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket read error. */
+#define MC_DRV_ERR_SOCKET_LENGTH MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon socket read error. */
+#define MC_DRV_ERR_DAEMON_SOCKET MC_DRV_ERR_DAEMON_UNREACHABLE /**< MC daemon had problems with socket. */
+#define MC_DRV_ERR_DEVICE_FILE_OPEN MC_DRV_ERR_INVALID_DEVICE_FILE /**< The device file of the kernel module could not be opened. */
+#define MC_DRV_ERR_NULL_POINTER MC_DRV_ERR_INVALID_PARAMETER /**< Null pointer passed as parameter. */
+#define MC_DRV_ERR_TCI_TOO_BIG MC_DRV_ERR_INVALID_PARAMETER /**< Requested TCI length is too high. */
+#define MC_DRV_ERR_WSM_NOT_FOUND MC_DRV_ERR_INVALID_PARAMETER /**< Requested TCI was not allocated with mallocWsm(). */
+#define MC_DRV_ERR_TCI_GREATER_THAN_WSM MC_DRV_ERR_INVALID_PARAMETER /**< Requested TCI length is bigger than allocated WSM. */
+#define MC_DRV_ERR_TRUSTLET_NOT_FOUND MC_DRV_ERR_INVALID_DEVICE_FILE /** < Trustlet could not be found in mcRegistry. */
+#define MC_DRV_ERR_TRUSTED_APPLICATION_NOT_FOUND MC_DRV_ERR_TRUSTLET_NOT_FOUND /** < Trusted Application could not be found in mcRegistry. */
+#define MC_DRV_ERR_DAEMON_KMOD_ERROR MC_DRV_ERR_DAEMON_UNREACHABLE /**< Daemon cannot use Kernel module as expected. */
+#define MC_DRV_ERR_DAEMON_MCI_ERROR MC_DRV_ERR_DAEMON_UNREACHABLE /**< Daemon cannot use MCI as expected. */
+#define MC_DRV_ERR_MCP_ERROR MC_DRV_ERR_DAEMON_UNREACHABLE /**< MobiCore Control Protocol error. See MC_DRV_ERROR_MCP(). */
+#define MC_DRV_ERR_INVALID_LENGTH MC_DRV_ERR_NO_FREE_MEMORY /**< Invalid length. */
+#define MC_DRV_ERR_KMOD_NOT_OPEN MC_DRV_ERR_NO_FREE_MEMORY /**< Device not open. */
+#define MC_DRV_ERR_BUFFER_ALREADY_MAPPED MC_DRV_ERR_BULK_MAPPING /**< Buffer is already mapped to this Trusted Application. */
+#define MC_DRV_ERR_BLK_BUFF_NOT_FOUND MC_DRV_ERR_BULK_UNMAPPING /**< Unable to find internal handle for buffer. */
+
+#define MC_DRV_ERR_DAEMON_DEVICE_NOT_OPEN 0x00000021 /**< No device associated with connection. */
+#define MC_DRV_ERR_DAEMON_WSM_HANDLE_NOT_FOUND MC_DRV_ERR_WSM_NOT_FOUND /**< Daemon could not find WSM handle. */
+#define MC_DRV_ERR_DAEMON_UNKNOWN_SESSION MC_DRV_ERR_UNKNOWN_SESSION /**< The specified session is unknown to Daemon. */
+
+#if TBASE_API_LEVEL >= 3
+// Installation errors
+#define MC_DRV_ERR_TA_HEADER_ERROR 0x00000021 /**< TA blob header is incorrect. */
+#define MC_DRV_ERR_TA_ATTESTATION_ERROR 0x00000022 /**< TA blob attestation is incorrect. */
+#endif /* TBASE_API_LEVEL */
+
+#define MAKE_MC_DRV_MCP_ERROR(mcpCode) (MC_DRV_ERR_MCP_ERROR | ((mcpCode&0x000FFFFF)<<8))
+#define MAKE_MC_DRV_KMOD_WITH_ERRNO(theErrno) (MC_DRV_ERR_KERNEL_MODULE| (((theErrno)&0x0000FFFF)<<16))
+
+/**
+ * Driver control command.
+ */
+typedef enum {
+ MC_CTRL_DUMMY = 1 /**< Dummy. */
+} mcDriverCtrl_t;
+
+
+/** Structure of Session Handle, includes the Session ID and the Device ID the Session belongs to.
+ * The session handle will be used for session-based t-base communication.
+ * It will be passed to calls which address a communication end point in the t-base environment.
+ */
+typedef struct {
+ uint32_t sessionId; /**< t-base session ID */
+ uint32_t deviceId; /**< Device ID the session belongs to */
+} mcSessionHandle_t;
+
+/** Information structure about additional mapped Bulk buffer between the Client Application (NWd) and
+ * the Trusted Application (SWd). This structure is initialized from a Client Application by calling mcMap().
+ * In order to use the memory within a Trusted Application the Client Application has to inform the Trusted Application with
+ * the content of this structure via the TCI.
+ */
+typedef struct {
+ void *sVirtualAddr; /**< The virtual address of the Bulk buffer regarding the address space of the Trusted Application, already includes a possible offset! */
+ uint32_t sVirtualLen; /**< Length of the mapped Bulk buffer */
+} mcBulkMap_t;
+
+
+#define MC_DEVICE_ID_DEFAULT 0 /**< The default device ID */
+#define MC_INFINITE_TIMEOUT ((int32_t)(-1)) /**< Wait infinite for a response of the MC. */
+#define MC_NO_TIMEOUT 0 /**< Do not wait for a response of the MC. */
+#define MC_MAX_TCI_LEN 0x100000 /**< TCI/DCI must not exceed 1MiB */
+
+#ifndef WIN32
+/* Mark only the following functions for export */
+#pragma GCC visibility push(default)
+#endif
+
+/** Open a new connection to a t-base device.
+ *
+ * mcOpenDevice() initializes all device specific resources required to communicate
+ * with an t-base instance located on the specified device in the system. If the device
+ * does not exist the function will return MC_DRV_ERR_UNKNOWN_DEVICE.
+ *
+ * @param [in] deviceId Identifier for the t-base device to be used. MC_DEVICE_ID_DEFAULT refers to the default device.
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_ERR_INVALID_OPERATION if device already opened.
+ * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when deviceId is unknown.
+ * @return MC_DRV_ERR_INVALID_DEVICE_FILE if kernel module under /dev/mobicore cannot be opened
+ *
+ * Uses a Mutex.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcOpenDevice(
+ uint32_t deviceId
+);
+
+/** Close the connection to a t-base device.
+ * When closing a device, active sessions have to be closed beforehand.
+ * Resources associated with the device will be released.
+ * The device may be opened again after it has been closed.
+ *
+ * @param [in] deviceId Identifier for the t-base device. MC_DEVICE_ID_DEFAULT refers to the default device.
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
+ * @return MC_DRV_ERR_SESSION_PENDING when a session is still open.
+ * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
+ *
+ * Uses a Mutex.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcCloseDevice(
+ uint32_t deviceId
+);
+
+/** Open a new session to a Trusted Application. The Trusted Application with the given UUID has to be available in the flash filesystem.
+ *
+ * Write MCP open message to buffer and notify t-base about the availability of a new command.
+ * Waits till t-base responds with the new session ID (stored in the MCP buffer).
+ *
+ * @param [in,out] session On success, the session data will be returned. Note that session.deviceId has to be the device id of an opened device.
+ * @param [in] uuid UUID of the Trusted Application to be opened.
+ * @param [in] tci TCI buffer for communicating with the Trusted Application.
+ * @param [in] tciLen Length of the TCI buffer. Maximum allowed value is MC_MAX_TCI_LEN.
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_INVALID_PARAMETER if session parameter is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
+ * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon socket occur.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when daemon returns an error.
+ * @return MC_DRV_ERR_TRUSTED_APPLICATION_NOT_FOUND when Trusted Application or driver cannot be loaded.
+ *
+ * Uses a Mutex.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcOpenSession(
+ mcSessionHandle_t *session,
+ const mcUuid_t *uuid,
+ uint8_t *tci,
+ uint32_t tciLen
+);
+
+/** Open a new session to a Trusted Application(Trustlet). The Trusted Application will be loaded from the memory buffer.
+ *
+ * Write MCP open message to buffer and notify t-base about the availability of a new command.
+ * Waits till t-base responds with the new session ID (stored in the MCP buffer).
+ *
+ * @param [in,out] session On success, the session data will be returned. Note that session.deviceId has to be the device id of an opened device.
+ * @param [in] spid Service Provider ID(for Service provider trustlets otherwise ignored)
+ * @param [in] trustedapp memory buffer containing the Trusted Application binary
+ * @param [in] tlen length of the memory buffer containing the Trusted Application
+ * @param [in] tci TCI buffer for communicating with the Trusted Application.
+ * @param [in] tciLen Length of the TCI buffer. Maximum allowed value is MC_MAX_TCI_LEN.
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_INVALID_PARAMETER if session parameter is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
+ * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon socket occur.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when daemon returns an error.
+ * @return MC_DRV_ERR_TRUSTED_APPLICATION_NOT_FOUND when Trusted Application cannot be loaded.
+ *
+ * Uses a Mutex.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcOpenTrustlet(
+ mcSessionHandle_t *session,
+ mcSpid_t spid,
+ uint8_t *trustedapp,
+ uint32_t tLen,
+ uint8_t *tci,
+ uint32_t tciLen
+);
+
+
+/** Close a Trusted Application session.
+ *
+ * Closes the specified t-base session. The call will block until the session has been closed.
+ *
+ * @pre Device deviceId has to be opened in advance.
+ *
+ * @param [in] session Session to be closed.
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_INVALID_PARAMETER if session parameter is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
+ * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
+ * @return MC_DRV_ERR_INVALID_DEVICE_FILE when daemon cannot open trustlet file.
+ *
+ * Uses a Mutex.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcCloseSession(
+ mcSessionHandle_t *session
+);
+
+/** Notify a session.
+ * Notifies the session end point about available message data.
+ * If the session parameter is correct, notify will always succeed.
+ * Corresponding errors can only be received by mcWaitNotification().
+ * @pre A session has to be opened in advance.
+ *
+ * @param session The session to be notified.
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_INVALID_PARAMETER if session parameter is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcNotify(
+ mcSessionHandle_t *session
+);
+
+/** Wait for a notification.
+ *
+ * Wait for a notification issued by t-base for a specific session.
+ * The timeout parameter specifies the number of milliseconds the call will wait for a notification.
+ * If the caller passes 0 as timeout value the call will immediately return. If timeout value is below 0 the call will block
+ * until a notification for the session has been received.
+ *
+ * @attention if timeout is below 0, call will block:
+ * Caller has to trust the other side to send a notification to wake him up again.
+ *
+ * @param [in] session The session the notification should correspond to.
+ * @param [in] timeout Time in milliseconds to wait (MC_NO_TIMEOUT : direct return, > 0 : milliseconds, MC_INFINITE_TIMEOUT : wait infinitely)
+ *
+ * @return MC_DRV_OK if notification is available.
+ * @return MC_DRV_ERR_TIMEOUT if no notification arrived in time.
+ * @return MC_DRV_INFO_NOTIFICATION if a problem with the session was encountered. Get more details with mcGetSessionErrorCode().
+ * @return MC_DRV_ERR_NOTIFICATION if a problem with the socket occurred.
+ * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcWaitNotification(
+ mcSessionHandle_t *session,
+ int32_t timeout
+);
+
+/**
+ * Allocate a block of world shared memory (WSM).
+ * The MC driver allocates a contiguous block of memory which can be used as WSM.
+ * This implicates that the allocated memory is aligned according to the alignment parameter.
+ * Always returns a buffer of size WSM_SIZE aligned to 4K.
+ *
+ * @param [in] deviceId The ID of an opened device to retrieve the WSM from.
+ * @param [in] align The alignment (number of pages) of the memory block (e.g. 0x00000001 for 4kB).
+ * @param [in] len Length of the block in bytes.
+ * @param [out] wsm Virtual address of the world shared memory block.
+ * @param [in] wsmFlags Platform specific flags describing the memory to be allocated.
+ *
+ * @attention: align and wsmFlags are currently ignored
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
+ * @return MC_DRV_ERR_NO_FREE_MEMORY if no more contiguous memory is available in this size or for this process.
+ *
+ * Uses a Mutex.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcMallocWsm(
+ uint32_t deviceId,
+ uint32_t align,
+ uint32_t len,
+ uint8_t **wsm,
+ uint32_t wsmFlags
+);
+
+/**
+ * Free a block of world shared memory (WSM).
+ * The MC driver will free a block of world shared memory (WSM) previously allocated with
+ * mcMallocWsm(). The caller has to assure that the address handed over to the driver
+ * is a valid WSM address.
+ *
+ * @param [in] deviceId The ID to which the given address belongs.
+ * @param [in] wsm Address of WSM block to be freed.
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id is invalid.
+ * @return MC_DRV_ERR_FREE_MEMORY_FAILED on failures.
+ *
+ * Uses a Mutex.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcFreeWsm(
+ uint32_t deviceId,
+ uint8_t *wsm
+);
+
+/**
+ * Map additional bulk buffer between a Client Application (CA) and the Trusted Application (TA) for a session.
+ * Memory allocated in user space of the CA can be mapped as additional communication channel
+ * (besides TCI) to the Trusted Application. Limitation of the Trusted Application memory structure apply: only 6 chunks can be mapped
+ * with a maximum chunk size of 1 MiB each.
+ *
+ * @attention It is up to the application layer (CA) to inform the Trusted Application about the additional mapped bulk memory.
+ *
+ * @param [in] session Session handle with information of the deviceId and the sessionId. The
+ * given buffer is mapped to the session specified in the sessionHandle.
+ * @param [in] buf Virtual address of a memory portion (relative to CA) to be shared with the Trusted Application, already includes a possible offset!
+ * @param [in] len length of buffer block in bytes.
+ * @param [out] mapInfo Information structure about the mapped Bulk buffer between the CA (NWd) and
+ * the TA (SWd).
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
+ * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
+ * @return MC_DRV_ERR_BULK_MAPPING when buf is already uses as bulk buffer or when registering the buffer failed.
+ *
+ * Uses a Mutex.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcMap(
+ mcSessionHandle_t *session,
+ void *buf,
+ uint32_t len,
+ mcBulkMap_t *mapInfo
+);
+
+/**
+ * Remove additional mapped bulk buffer between Client Application (CA) and the Trusted Application (TA) for a session.
+ *
+ * @attention The bulk buffer will immediately be unmapped from the session context.
+ * @attention The application layer (CA) must inform the TA about unmapping of the additional bulk memory before calling mcUnmap!
+ *
+ * @param [in] session Session handle with information of the deviceId and the sessionId. The
+ * given buffer is unmapped from the session specified in the sessionHandle.
+ * @param [in] buf Virtual address of a memory portion (relative to CA) shared with the TA, already includes a possible offset!
+ * @param [in] mapInfo Information structure about the mapped Bulk buffer between the CA (NWd) and
+ * the TA (SWd).
+ * @attention The clientlib currently ignores the len field in mapInfo.
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
+ * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
+ * @return MC_DRV_ERR_BULK_UNMAPPING when buf was not registered earlier or when unregistering failed.
+ *
+ * Uses a Mutex.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcUnmap(
+ mcSessionHandle_t *session,
+ void *buf,
+ mcBulkMap_t *mapInfo
+);
+
+
+/**
+ * @attention: Not implemented.
+ * Execute driver specific command.
+ * mcDriverCtrl() can be used to execute driver specific commands.
+ * Besides the control command MC_CTRL_GET_VERSION commands are implementation specific.
+ * Please refer to the corresponding specification of the driver manufacturer.
+ *
+ * @param [in] param Command ID of the command to be executed.
+ * @param [in, out] data Command data and response depending on command.
+ * @param [in] len Length of the data block.
+ *
+ * @return MC_DRV_ERR_NOT_IMPLEMENTED.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcDriverCtrl(
+ mcDriverCtrl_t param,
+ uint8_t *data,
+ uint32_t len
+);
+
+/**
+ * Get additional error information of the last error that occurred on a session.
+ * After the request the stored error code will be deleted.
+ *
+ * @param [in] session Session handle with information of the deviceId and the sessionId.
+ * @param [out] lastErr >0 Trusted Application has terminated itself with this value, <0 Trusted Application is dead because of an error within t-base (e.g. Kernel exception).
+ * See also notificationPayload_t enum in MCI definition at "mcinq.h".
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_SESSION when session id is invalid.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device id of session is invalid.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcGetSessionErrorCode(
+ mcSessionHandle_t *session,
+ int32_t *lastErr
+);
+
+/**
+ * Get t-base version information of a device.
+ *
+ * @param [in] deviceId of an open device.
+ * @param [out] versionInfo t-base version info.
+ *
+ * @return MC_DRV_OK if operation has been successfully completed.
+ * @return MC_DRV_ERR_UNKNOWN_DEVICE when device is not open.
+ * @return MC_DRV_INVALID_PARAMETER if a parameter is invalid.
+ * @return MC_DRV_ERR_DAEMON_UNREACHABLE when problems with daemon occur.
+ */
+__MC_CLIENT_LIB_API mcResult_t mcGetMobiCoreVersion(
+ uint32_t deviceId,
+ mcVersionInfo_t *versionInfo
+);
+#ifndef WIN32
+#pragma GCC visibility pop
+#endif
+#endif /** MCDRIVER_H_ */
+
+/** @} */
--- /dev/null
+; ------------------------------------------------------------------------
+; Copyright (c) 2013 TRUSTONIC LIMITED
+; All rights reserved
+;
+; The present software is the confidential and proprietary information of
+; TRUSTONIC LIMITED. You shall not disclose the present software and shall
+; use it only in accordance with the terms of the license agreement you
+; entered into with TRUSTONIC LIMITED. This software may be subject to
+; export or import laws in certain countries.
+; ------------------------------------------------------------------------
+EXPORTS
+ mcOpenDevice
+ mcCloseDevice
+ mcOpenSession
+ mcOpenTrustlet
+ mcCloseSession
+ mcNotify
+ mcWaitNotification
+ mcMallocWsm
+ mcFreeWsm
+ mcMap
+ mcUnmap
+ mcGetSessionErrorCode
+ mcGetMobiCoreVersion
+
--- /dev/null
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Express 2012 for Windows Desktop
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t-base_client_api", "t-base_client_api.vcxproj", "{AA0349EE-7BCF-4CFF-ABB0-62EC1810DE67}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AA0349EE-7BCF-4CFF-ABB0-62EC1810DE67}.Release|Win32.ActiveCfg = Release|Win32
+ {AA0349EE-7BCF-4CFF-ABB0-62EC1810DE67}.Release|Win32.Build.0 = Release|Win32
+ {AA0349EE-7BCF-4CFF-ABB0-62EC1810DE67}.Release|x64.ActiveCfg = Release|x64
+ {AA0349EE-7BCF-4CFF-ABB0-62EC1810DE67}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\ClientLib.cpp" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{AA0349EE-7BCF-4CFF-ABB0-62EC1810DE67}</ProjectGuid>
+ <RootNamespace>t-base_client_api</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>
+ </CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet />
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\..\..\Out\Bin\Windows\$(Platform)\Release\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\..\..\Out\_build\Windows\$(Platform)\Release\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <OutDir>..\..\..\..\Out\Bin\Windows\$(Platform)\Release\</OutDir>
+ <IntDir>..\..\..\..\Out\_build\Windows\$(Platform)\Release\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\Common;$(COMP_PATH_TlSdk)\Public\MobiCore\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32</PreprocessorDefinitions>
+ <WarningLevel>
+ </WarningLevel>
+ <RuntimeLibrary>
+ </RuntimeLibrary>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>
+ </PreprocessorDefinitions>
+ <Culture>
+ </Culture>
+ <AdditionalIncludeDirectories>
+ </AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalDependencies>
+ </AdditionalDependencies>
+ </Lib>
+ <Link>
+ <ImportLibrary>
+ </ImportLibrary>
+ <ModuleDefinitionFile>$(TargetName).def</ModuleDefinitionFile>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\Common;$(COMP_PATH_TlSdk)\Public\MobiCore\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32</PreprocessorDefinitions>
+ <WarningLevel>
+ </WarningLevel>
+ <RuntimeLibrary>
+ </RuntimeLibrary>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>
+ </PreprocessorDefinitions>
+ <Culture>
+ </Culture>
+ <AdditionalIncludeDirectories>
+ </AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Lib>
+ <AdditionalDependencies>
+ </AdditionalDependencies>
+ </Lib>
+ <Link>
+ <ImportLibrary>
+ </ImportLibrary>
+ <ModuleDefinitionFile>$(TargetName).def</ModuleDefinitionFile>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
--- /dev/null
+# =============================================================================
+#
+# Module: libCommon.a - classes shared by various modules
+#
+# =============================================================================
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := Common
+
+# Add new source files here
+#LOCAL_SRC_FILES +=\
+# CMutex.cpp\
+# Connection.cpp\
+# NetlinkConnection.cpp\
+# CSemaphore.cpp\
+# CThread.cpp
+
+# Header files required by components including this module
+LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)
+
+# Enable logging
+# LOCAL_SHARED_LIBRARIES += liblog
+#
+# LOCAL_CFLAGS += -DLOG_ANDROID
+#
+# LOCAL_C_INCLUDES += $(LOCAL_PATH)/../common/LogWrapper
+
+include $(BUILD_STATIC_LIBRARY)
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Mutex implementation (pthread wrapper).
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "CMutex.h"
+#include "log.h"
+
+
+//------------------------------------------------------------------------------
+CMutex::CMutex(
+ void
+)
+{
+ pthread_mutex_init(&m_mutex, NULL);
+ pthread_cond_init(&m_cond, NULL);
+}
+
+
+//------------------------------------------------------------------------------
+CMutex::~CMutex(
+ void
+)
+{
+ pthread_mutex_destroy(&m_mutex);
+ pthread_cond_destroy(&m_cond);
+}
+
+
+//------------------------------------------------------------------------------
+int32_t CMutex::lock(
+ void
+)
+{
+ return pthread_mutex_lock(&m_mutex);
+}
+
+
+//------------------------------------------------------------------------------
+int32_t CMutex::trylock(
+ void
+)
+{
+ return pthread_mutex_trylock(&m_mutex);
+}
+
+
+//------------------------------------------------------------------------------
+int32_t CMutex::unlock(
+ void
+)
+{
+ return pthread_mutex_unlock(&m_mutex);
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Mutex implementation (pthread wrapper).
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef CMUTEX_H_
+#define CMUTEX_H_
+
+#include <inttypes.h>
+#include "pthread.h"
+
+
+class CMutex
+{
+
+public:
+
+ CMutex(void);
+
+ ~CMutex(void);
+
+ int32_t lock(void);
+
+ int32_t trylock(void);
+
+ int32_t unlock(void);
+
+private:
+
+ pthread_mutex_t m_mutex;
+ pthread_cond_t m_cond;
+
+};
+
+#endif /* CMUTEX_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Semaphore implementation (pthread wrapper).
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <time.h>
+#include <limits.h>
+#include "CSemaphore.h"
+#include <stdio.h>
+
+//------------------------------------------------------------------------------
+CSemaphore::CSemaphore(int size) : m_waiters_count(0), m_count(size)
+{
+ pthread_mutex_init(&m_mutex, NULL);
+ pthread_cond_init(&m_cond, NULL);
+}
+
+
+//------------------------------------------------------------------------------
+CSemaphore::~CSemaphore()
+{
+ pthread_mutex_destroy(&m_mutex);
+ pthread_cond_destroy(&m_cond);
+}
+
+
+//------------------------------------------------------------------------------
+void CSemaphore::wait()
+{
+ pthread_mutex_lock(&m_mutex);
+ m_waiters_count ++;
+ while ( m_count == 0 )
+ pthread_cond_wait(&m_cond, &m_mutex);
+ m_waiters_count --;
+ m_count --;
+ pthread_mutex_unlock(&m_mutex);
+}
+
+//------------------------------------------------------------------------------
+bool CSemaphore::wait(int sec)
+{
+ int rc = 0;
+ struct timespec tm;
+ if (sec < 0)
+ sec = LONG_MAX;
+ clock_gettime(CLOCK_REALTIME, &tm);
+ tm.tv_sec += sec;
+
+ pthread_mutex_lock(&m_mutex);
+ m_waiters_count ++;
+ if ( m_count == 0 ) {
+ rc = pthread_cond_timedwait(&m_cond, &m_mutex, &tm);
+ }
+ m_waiters_count --;
+ // Decrement only if waiting actually succeeded, otherwise we
+ // just timed out
+ if (!rc)
+ m_count --;
+ pthread_mutex_unlock(&m_mutex);
+ return (rc == 0);
+}
+
+
+//------------------------------------------------------------------------------
+bool CSemaphore::wouldWait()
+{
+ bool ret = false;
+ pthread_mutex_lock(&m_mutex);
+ if ( m_count == 0 )
+ ret = true;
+ pthread_mutex_unlock(&m_mutex);
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+void CSemaphore::signal()
+{
+ pthread_mutex_lock(&m_mutex);
+ if ( m_waiters_count > 0 )
+ pthread_cond_signal(&m_cond);
+ m_count ++;
+ pthread_mutex_unlock(&m_mutex);
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Semaphore implementation (pthread wrapper).
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef CSEMAPHORE_H_
+#define CSEMAPHORE_H_
+
+#include "pthread.h"
+
+/**
+ * Could inherit from CMutex, or use CMutex internally.
+ * Semaphore is a mutex with a counter. Constructor and destructor
+ * code is the same.
+ */
+
+class CSemaphore
+{
+
+public:
+
+ CSemaphore(int size = 0);
+
+ ~CSemaphore(void);
+
+ void wait(void);
+ bool wait(int sec);
+
+ bool wouldWait(void);
+
+ void signal(void);
+
+private:
+
+ pthread_mutex_t m_mutex;
+ pthread_cond_t m_cond;
+ int m_waiters_count;
+ int m_count;
+
+};
+
+#endif /*CSEMAPHORE_H_*/
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Thread implementation (pthread abstraction).
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "CThread.h"
+
+#include "log.h"
+
+
+//------------------------------------------------------------------------------
+CThread::CThread(void) :
+ m_terminate(false), m_isExiting(false)
+{
+ m_sem = new CSemaphore();
+ m_thread=0;
+}
+
+//------------------------------------------------------------------------------
+CThread::~CThread(
+ void
+)
+{
+ delete m_sem;
+}
+
+
+//------------------------------------------------------------------------------
+void CThread::terminate(
+ void
+)
+{
+ m_terminate = true;
+}
+
+
+//------------------------------------------------------------------------------
+bool CThread::isExiting(
+ void
+)
+{
+ return m_isExiting;
+}
+
+
+//------------------------------------------------------------------------------
+void CThread::setExiting(
+ void
+)
+{
+ m_isExiting = true;
+}
+
+
+//------------------------------------------------------------------------------
+void CThread::exit(
+ int32_t exitcode
+)
+{
+ setExiting();
+ pthread_exit((void *)(uintptr_t)exitcode);
+}
+
+
+//------------------------------------------------------------------------------
+bool CThread::shouldTerminate(
+ void
+)
+{
+ return m_terminate;
+}
+
+
+//------------------------------------------------------------------------------
+void CThread::start(
+ void
+)
+{
+ int ret;
+ ret = pthread_create(&m_thread, NULL, CThreadStartup, this);
+ if (0 != ret)
+ LOG_E("pthread_create failed with error code %d", ret);
+}
+
+//------------------------------------------------------------------------------
+void CThread::start(
+ const char* name
+)
+{
+ start();
+ int ret = pthread_setname_np(m_thread, name);
+ if (0 != ret)
+ LOG_E("pthread_setname_np failed with error code %d %s", ret, name);
+}
+
+//------------------------------------------------------------------------------
+void CThread::join(
+ void
+)
+{
+ int ret;
+ ret = pthread_join(m_thread, NULL);
+ if (0 != ret)
+ LOG_E("pthread_join failed with error code %d", ret);
+}
+
+
+//------------------------------------------------------------------------------
+void CThread::sleep(
+ void
+)
+{
+ m_sem->wait();
+}
+
+
+//------------------------------------------------------------------------------
+void CThread::wakeup(
+ void
+)
+{
+ m_sem->signal();
+}
+
+
+//------------------------------------------------------------------------------
+void *CThreadStartup(
+ void *_tgtObject
+)
+{
+ CThread *tgtObject = (CThread *) _tgtObject;
+ tgtObject->run();
+ return NULL;
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Thread implementation (pthread abstraction).
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef CTHREAD_H_
+#define CTHREAD_H_
+
+#include <inttypes.h>
+#include "CSemaphore.h"
+#include "pthread.h"
+
+using namespace std;
+
+
+class CThread
+{
+
+public:
+
+ CThread(void);
+
+ virtual ~CThread(void);
+
+ virtual void run(void) = 0;
+
+ void start(void);
+
+ void start(const char* name);
+
+ void join(void);
+
+ void sleep(void);
+
+ void wakeup(void);
+
+ void terminate(void);
+
+ bool isExiting(void);
+
+ void setExiting(void);
+
+protected:
+
+ bool shouldTerminate(void);
+
+ void exit(int32_t exitcode);
+
+private:
+
+ CSemaphore *m_sem;
+ pthread_t m_thread;
+ bool m_terminate;
+ bool m_isExiting;
+
+};
+
+extern "C" void *CThreadStartup(void *);
+
+#endif /*CTHREAD_H_*/
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * World shared memory definitions.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef CWSM_H_
+#define CWSM_H_
+
+#include <stdint.h>
+#include <list>
+#include "McTypes.h"
+
+
+class CWsm
+{
+public:
+ addr_t virtAddr;
+ uint32_t len;
+ uint32_t handle;
+ uint64_t physAddr;
+
+ CWsm(addr_t virtAddr,
+ uint32_t len,
+ uint32_t handle,
+ // this may be unknown, so is can be omitted.
+ uint64_t physAddr = 0) :
+ virtAddr(virtAddr),
+ len(len),
+ handle(handle),
+ physAddr(physAddr)
+ { };
+
+};
+
+typedef CWsm *CWsm_ptr;
+typedef std::list<CWsm_ptr> wsmList_t;
+typedef wsmList_t::iterator wsmIterator_t;
+
+#endif /* CWSM_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Connection data.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <unistd.h>
+#include <assert.h>
+#include <cstring>
+#include <errno.h>
+
+#include "Connection.h"
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <poll.h>
+
+//#define LOG_VERBOSE
+#include "log.h"
+
+
+//------------------------------------------------------------------------------
+Connection::Connection(void)
+{
+ connectionData = NULL;
+ // Set invalid socketDescriptor
+ socketDescriptor = -1;
+
+ detached = false;
+
+ remote.sun_family = AF_UNIX;
+ memset(remote.sun_path, 0, sizeof(remote.sun_path));
+}
+
+
+//------------------------------------------------------------------------------
+Connection::Connection(int socketDescriptor, sockaddr_un *remote)
+{
+ assert(NULL != remote);
+ assert(-1 != socketDescriptor);
+
+ this->socketDescriptor = socketDescriptor;
+ this->remote = *remote;
+ connectionData = NULL;
+}
+
+
+//------------------------------------------------------------------------------
+Connection::~Connection(void)
+{
+ LOG_V(" closing Connection... fd=%i", socketDescriptor);
+ if (socketDescriptor != -1) {
+ int ret = close(socketDescriptor);
+ if(ret) {
+ LOG_ERRNO("close");
+ }
+ }
+ LOG_I(" Socket connection closed.");
+}
+
+
+//------------------------------------------------------------------------------
+bool Connection::connect(const char *dest)
+{
+ int32_t len;
+
+ assert(NULL != dest);
+ if (sizeof(remote.sun_path) - 1 < strlen(dest)) {
+ LOG_E("Invalid destination socket %s", dest);
+ return false;
+ }
+ LOG_I(" Connecting to %s socket", dest);
+ remote.sun_family = AF_UNIX;
+ memset(remote.sun_path, 0, sizeof(remote.sun_path));
+ strncpy(remote.sun_path, dest, strlen(dest));
+ if ((socketDescriptor = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
+ LOG_ERRNO("Can't open stream socket.");
+ return false;
+ }
+ len = strlen(remote.sun_path) + sizeof(remote.sun_family);
+ // The Daemon socket is in the Abstract Domain(LINUX ONLY!)
+ remote.sun_path[0] = 0;
+ if (::connect(socketDescriptor, (struct sockaddr *) &remote, len) < 0) {
+ LOG_ERRNO("connect()");
+ return false;
+ }
+
+ return true;
+}
+
+
+//------------------------------------------------------------------------------
+size_t Connection::readData(void *buffer, uint32_t len)
+{
+ return readData(buffer, len, -1);
+}
+
+
+//------------------------------------------------------------------------------
+size_t Connection::readData(void *buffer, uint32_t len, int32_t timeout)
+{
+ size_t ret = 0;
+ struct timeval tv;
+ struct timeval *ptv = NULL;
+ fd_set readfds;
+
+ assert(NULL != buffer);
+ assert(socketDescriptor != -1);
+
+ if (timeout >= 0) {
+ // Calculate timeout value
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
+ ptv = &tv;
+ }
+
+ FD_ZERO(&readfds);
+ FD_SET(socketDescriptor, &readfds);
+ ret = select(socketDescriptor + 1, &readfds, NULL, NULL, ptv);
+
+ // check for read error
+ if ((int)ret == -1) {
+ LOG_ERRNO("select");
+ return -1;
+ }
+
+ // Handle case of no descriptor ready
+ if (ret == 0) {
+ LOG_W(" Timeout during select() / No more notifications.");
+ return -2;
+ }
+
+ // one or more descriptors are ready
+
+ // finally check if fd has been selected -> must socketDescriptor
+ if (!FD_ISSET(socketDescriptor, &readfds)) {
+ LOG_ERRNO("no fd is set, select");
+ return ret;
+ }
+
+ ret = recv(socketDescriptor, buffer, len, MSG_DONTWAIT);
+ if (ret == 0) {
+ LOG_V(" readData(): peer orderly closed connection.");
+ }
+
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+size_t Connection::writeData(void *buffer, uint32_t len)
+{
+ assert(buffer != NULL);
+ assert(socketDescriptor != -1);
+
+ size_t ret = send(socketDescriptor, buffer, len, 0);
+ if (ret != len) {
+ LOG_ERRNO("could not send all data, because send");
+ LOG_E("ret = %d", ret);
+ ret = -1;
+ }
+
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+int Connection::waitData(int32_t timeout)
+{
+ size_t ret;
+ struct timeval tv;
+ struct timeval *ptv = NULL;
+ fd_set readfds;
+
+ assert(socketDescriptor != -1);
+
+ if (timeout >= 0) {
+ // Calculate timeout value
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
+ ptv = &tv;
+ }
+
+ FD_ZERO(&readfds);
+ FD_SET(socketDescriptor, &readfds);
+ ret = select(socketDescriptor + 1, &readfds, NULL, NULL, ptv);
+
+ // check for read error
+ if ((int)ret == -1) {
+ LOG_ERRNO("select");
+ return ret;
+ } else if (ret == 0) {
+ LOG_E("select() timed out");
+ return -1;
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+bool Connection::isConnectionAlive(void)
+{
+ assert(socketDescriptor != -1);
+ int retval;
+ struct pollfd ufds[1];
+ ufds[0].fd = socketDescriptor;
+ ufds[0].events = POLLRDHUP;
+
+ retval = poll(ufds, 1, 10);
+ if (retval < 0 || retval > 0) {
+ LOG_ERRNO("poll");
+ return false;
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool Connection::getPeerCredentials(struct ucred &cr)
+{
+ struct ucred cred;
+ socklen_t len = sizeof (cred);
+ assert(socketDescriptor != -1);
+ int ret = getsockopt(socketDescriptor, SOL_SOCKET, SO_PEERCRED, &cred,
+ &len);
+ if (ret != 0) {
+ LOG_ERRNO("getsockopt");
+ return false;
+ }
+ if (len == sizeof(cred)) {
+ cr = cred;
+ return true;
+ }
+ return false;
+}
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Connection data.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef CONNECTION_H_
+#define CONNECTION_H_
+
+#include <list>
+#include <exception>
+
+#include <inttypes.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+
+class Connection
+{
+public:
+ struct sockaddr_un remote; /**< Remote address */
+ int32_t socketDescriptor; /**< Local socket descriptor */
+ void *connectionData; /**< reference to data related with the connection */
+ bool detached; /**< Connection state */
+
+ Connection(void);
+
+ Connection(int socketDescriptor, sockaddr_un *remote);
+
+ virtual ~Connection(void);
+
+ /**
+ * Connect to destination.
+ *
+ * @param Destination pointer.
+ * @return true on success.
+ */
+ virtual bool connect(const char *dest);
+
+ /**
+ * Read bytes from the connection.
+ *
+ * @param buffer Pointer to destination buffer.
+ * @param len Number of bytes to read.
+ * @param timeout Timeout in milliseconds
+ * @return Number of bytes read.
+ * @return -1 if select() failed (returned -1)
+ * @return -2 if no data available, i.e. timeout
+ */
+ virtual size_t readData(void *buffer, uint32_t len, int32_t timeout);
+
+ /**
+ * Read bytes from the connection.
+ *
+ * @param buffer Pointer to destination buffer.
+ * @param len Number of bytes to read.
+ * @return Number of bytes read.
+ */
+ virtual size_t readData(void *buffer, uint32_t len);
+
+ /**
+ * Write bytes to the connection.
+ *
+ * @param buffer Pointer to source buffer.
+ * @param len Number of bytes to read.
+ * @return Number of bytes written.
+ * @return -1 if written bytes not equal to len.
+ */
+ virtual size_t writeData(void *buffer, uint32_t len);
+
+ /**
+ * Wait for data to be available.
+ *
+ * @param timeout Timeout in milliseconds
+ * @return 0 if data is available
+ * @return error code if otherwise
+ */
+ virtual int waitData(int32_t timeout);
+
+ /*
+ * Checks if the socket is still connected to the daemon
+ *
+ * @return true if connection is still alive.
+ */
+ virtual bool isConnectionAlive(void);
+
+ /*
+ * Retrieve the peer's credentials(uid, pid, gid)
+ *
+ * @return true if connection peers could be retrieved
+ */
+ virtual bool getPeerCredentials(struct ucred &cr);
+
+};
+
+typedef std::list<Connection *> connectionList_t;
+typedef connectionList_t::iterator connectionIterator_t;
+
+
+#endif /* CONNECTION_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * MobiCore types redefinition.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef MCTYPES_H_
+#define MCTYPES_H_
+
+typedef void *addr_t;
+
+#endif /* MCTYPES_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Connection data.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdlib.h>
+#include <unistd.h>
+#include <assert.h>
+#include <cstring>
+#include <errno.h>
+#include <stdio.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+
+#include "NetlinkConnection.h"
+
+#include "log.h"
+
+
+uint64_t hashConnection(
+ pid_t pid,
+ uint32_t seq
+)
+{
+ return (((uint64_t)seq) << 32) | (uint64_t)pid;
+}
+
+
+//------------------------------------------------------------------------------
+NetlinkConnection::NetlinkConnection(
+ void
+) : Connection(),
+ dataLeft(0),
+ manager(NULL)
+{
+ detached = false;
+ dataMsg = NULL;
+ dataStart = NULL;
+ dataLen = 0;
+
+
+ selfPid = getpid();
+ peerPid = 0;
+ sequenceMagic = 0;
+ hash = hashConnection(peerPid, sequenceMagic);
+}
+
+
+//------------------------------------------------------------------------------
+NetlinkConnection::NetlinkConnection(
+ NetlinkConnectionManager *manager,
+ int socketDescriptor,
+ uint32_t pid,
+ uint32_t seq
+): Connection(),
+ dataLeft(0),
+ manager(manager)
+{
+ detached = false;
+ dataMsg = NULL;
+ dataStart = NULL;
+ dataLen = 0;
+
+ this->socketDescriptor = socketDescriptor;
+ selfPid = getpid();
+ peerPid = pid;
+ sequenceMagic = seq;
+ hash = hashConnection(pid, seq);
+}
+
+
+//------------------------------------------------------------------------------
+NetlinkConnection::~NetlinkConnection(
+ void
+)
+{
+ LOG_I("%s: destroy connection for PID 0x%X", __FUNCTION__, peerPid);
+ socketDescriptor = -1;
+ free(dataMsg);
+
+ if (manager) {
+ manager->removeConnection(hash);
+ }
+}
+
+
+//------------------------------------------------------------------------------
+bool NetlinkConnection::connect(
+ const char *dest __unused
+)
+{
+ struct sockaddr_nl addr;
+ bool ret = false;
+
+ assert(NULL != dest);
+
+ LOG_I("%s: Connecting to SEQ 0x%X", __FUNCTION__, MC_DAEMON_PID);
+ do {
+ if ((socketDescriptor = socket(PF_NETLINK, SOCK_DGRAM, MC_DAEMON_NETLINK)) < 0) {
+ LOG_E("%s: Can't open netlink socket - errno: %d(%s)",
+ __FUNCTION__, errno, strerror(errno));
+ break;
+ }
+ memset(&addr, 0, sizeof(addr));
+ addr.nl_family = AF_NETLINK;
+ addr.nl_pid = selfPid; /* self pid */
+ addr.nl_groups = 0; /* not in mcast groups */
+
+ if (bind(socketDescriptor, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ LOG_E("%s: bind() failed - errno: %d(%s)", __FUNCTION__, errno, strerror(errno));
+ close(socketDescriptor);
+
+ // Set invalid socketDescriptor
+ socketDescriptor = -1;
+ break;
+ }
+ ret = true;
+
+
+ } while (false);
+
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+void NetlinkConnection::handleMessage(
+ struct nlmsghdr *nlh
+)
+{
+ dataMutex.lock();
+ /* Takeover the buffer */
+ dataMsg = nlh;
+ dataLen = NLMSG_PAYLOAD(dataMsg, 0);
+ dataStart = static_cast<uint8_t *>(NLMSG_DATA(dataMsg));
+ dataMutex.unlock();
+ dataLeft.signal();
+}
+
+//------------------------------------------------------------------------------
+size_t NetlinkConnection::readData(
+ void *buffer,
+ uint32_t len
+)
+{
+ return readData(buffer, len, -1);
+}
+
+
+//------------------------------------------------------------------------------
+size_t NetlinkConnection::readData(
+ void *buffer,
+ uint32_t len,
+ int32_t timeout
+)
+{
+ size_t ret = -1;
+ assert(NULL != buffer);
+
+ if (!dataLeft.wait(timeout)) {
+ return -2;
+ }
+ dataMutex.lock();
+ // No data left?? Could we get this far?
+ if (dataLen <= 0) {
+ dataMutex.unlock();
+ return -2;
+ }
+
+ //LOG_I("%s: reading connection data %u, connection data left %u",
+ // __FUNCTION__, len, dataLen);
+
+ assert(dataStart != NULL);
+
+ // trying to read more than the left data
+ if (len > dataLen) {
+ ret = dataLen;
+ memcpy(buffer, dataStart, dataLen);
+ dataLen = 0;
+ } else {
+ ret = len;
+ memcpy(buffer, dataStart, len);
+ dataLen -= len;
+ dataStart += len;
+ }
+
+ if (dataLen == 0) {
+ dataStart = NULL;
+ free(dataMsg);
+ dataMsg = NULL;
+ } else {
+ // Still some data left
+ dataLeft.signal();
+ }
+ dataMutex.unlock();
+
+ //LOG_I("%s: read %u", __FUNCTION__, ret);
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+size_t NetlinkConnection::writeData(
+ void *buffer,
+ uint32_t len
+)
+{
+ size_t ret;
+ struct sockaddr_nl dest_addr;
+ struct nlmsghdr *nlh = NULL;
+ struct iovec iov;
+ struct msghdr msg;
+
+ assert(NULL != buffer);
+ assert(-1 != socketDescriptor);
+
+ //LOG_I("%s: send data %u to PID %u", __FUNCTION__, len, sequenceMagic);
+
+ memset(&dest_addr, 0, sizeof(dest_addr));
+ memset(&msg, 0, sizeof(msghdr));
+ dest_addr.nl_family = AF_NETLINK;
+ dest_addr.nl_pid = peerPid;
+ dest_addr.nl_groups = 0; /* unicast */
+
+ nlh = (struct nlmsghdr *)malloc(
+ NLMSG_SPACE(len));
+ if (nlh == NULL) {
+ LOG_E("Allocation failure");
+ return -1;
+ }
+
+ /* Fill the netlink message header */
+ nlh->nlmsg_len = NLMSG_SPACE(len);
+ nlh->nlmsg_pid = selfPid;
+ nlh->nlmsg_flags = NLM_F_REQUEST;
+ nlh->nlmsg_seq = sequenceMagic;
+
+ /* Fill in the netlink message payload */
+ memcpy(NLMSG_DATA(nlh), buffer, len);
+
+ iov.iov_base = (void *)nlh;
+ iov.iov_len = nlh->nlmsg_len;
+ msg.msg_name = (void *)&dest_addr;
+ msg.msg_namelen = sizeof(dest_addr);
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+ msg.msg_control = NULL;
+ msg.msg_controllen = 0;
+
+ ret = sendmsg(socketDescriptor, &msg, 0);
+ if (ret != NLMSG_SPACE(len)) {
+ LOG_E( "%s: could no send all data, ret=%d, errno: %d(%s)",
+ __FUNCTION__, ret, errno, strerror(errno));
+ ret = -1;
+ } else {
+ /* The whole message sent also includes the header, so make sure to
+ * return only the number of payload data sent, not everything */
+ ret = len;
+ }
+
+ free(nlh);
+
+ return ret;
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Connection data.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef NETLINKCONNECTION_H_
+#define NETLINKCONNECTION_H_
+
+#include <unistd.h>
+#include <map>
+#include <exception>
+#include <inttypes.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include "Connection.h"
+#include "CMutex.h"
+#include "CSemaphore.h"
+
+/** PID(address) of MC daemon. */
+#define MC_DAEMON_PID 0xFFFFFFFF
+/** Maximum Netlink payload size
+ * TODO: figure out the best value for this */
+#define MAX_PAYLOAD 1024
+
+#define MC_DAEMON_NETLINK 17
+
+
+class NetlinkConnection;
+
+/**
+ * Hash function for unique ID of a connection.
+ *
+ * @param pid Connection PID
+ * @param seq Connection sequenceMagic
+ *
+ * @return Unique identifier of the connection
+ */
+uint64_t hashConnection(pid_t pid, uint32_t seq);
+
+/** Netlink connection manager interface.
+ * This inteface has to be implemented by the handling server
+ * to ensure connection will be removed from accounting when destroied. */
+class NetlinkConnectionManager
+{
+public:
+ virtual ~NetlinkConnectionManager() {};
+ /**
+ * Retreive connection based on a unique hash.
+ * Search the peer connections hashmap for a hash and return
+ * the associated Connection object
+ *
+ * @param hash The hash to search
+ * @return The NetlinkConnection object if found or NULL if not found
+ */
+ virtual NetlinkConnection *findConnection(
+ uint64_t hash
+ ) = 0;
+
+ /**
+ * Insert a connection in connection lisst
+ * Insert a new connection in the peer connections list. If there
+ * is already such a connection
+ * it will be overriden!
+ *
+ * @param hash The hash to use
+ * @param connection The connection object to insert
+ */
+ virtual void insertConnection(
+ uint64_t hash,
+ NetlinkConnection *connection
+ ) = 0;
+
+ /**
+ * Remove a connection from the peer connections
+ * Remove the connection associated with seq from the peer list.
+ * This doesn't actually free the connection object!
+ * If the hash is invalid nothing happens.
+ *
+ * @param hash The hash hash use
+ */
+ virtual void removeConnection(
+ uint64_t hash
+ ) = 0;
+};
+
+class NetlinkConnection: public Connection
+{
+public:
+ pid_t selfPid; /**< Which PID to use to identify when writing data */
+ pid_t peerPid; /**< Destination PID for sending data */
+ uint32_t sequenceMagic; /**< Random? magic to match requests/answers */
+ uint64_t hash; /**< Unique connection ID, see hashConnection */
+
+ NetlinkConnection(
+ void
+ );
+
+ /**
+ * Connection main constructor
+ *
+ * @param manager Connection manager pointer.
+ * @param socketDescriptor Socket descriptor to use for writing
+ * @param pid Connection PID
+ * @param seq Connection sequence magic number
+ */
+ NetlinkConnection(
+ NetlinkConnectionManager *manager,
+ int socketDescriptor,
+ uint32_t pid,
+ uint32_t seq
+ );
+
+ virtual ~NetlinkConnection(
+ void
+ );
+
+ /**
+ * Connect to destination.
+ *
+ * @param Destination pointer.
+ * @return true on success.
+ */
+ virtual bool connect(
+ const char *dest
+ );
+
+ /**
+ * Read bytes from the connection(compatiblity method).
+ *
+ * @param buffer Pointer to destination buffer.
+ * @param len Number of bytes to read.
+ * @param timeout Timeout in milliseconds(ignored)
+ * @return Number of bytes read.
+ * @return -1 if select() failed (returned -1)
+ * @return -2 if no data available, i.e. timeout
+ */
+ virtual size_t readData(
+ void *buffer,
+ uint32_t len,
+ int32_t timeout
+ );
+
+ /**
+ * Read bytes from the connection.
+ *
+ * @param buffer Pointer to destination buffer.
+ * @param len Number of bytes to read.
+ * @return Number of bytes read.
+ */
+ virtual size_t readData(
+ void *buffer,
+ uint32_t len
+ );
+
+ /**
+ * Write bytes to the connection.
+ *
+ * @param buffer Pointer to source buffer.
+ * @param len Number of bytes to read.
+ * @return Number of bytes written.
+ */
+ virtual size_t writeData(
+ void *buffer,
+ uint32_t len
+ );
+
+ /**
+ * Set the internal data connection.
+ * This method is called by the
+ *
+ * @param nlh Netlink structure pointing to data.
+ */
+ void handleMessage(
+ struct nlmsghdr *nlh
+ );
+
+private:
+ CMutex dataMutex;
+ CSemaphore dataLeft;
+ struct nlmsghdr *dataMsg; /**< Last message received */
+ uint32_t dataLen; /**< How much connection data is left */
+ uint8_t *dataStart; /**< Start pointer of remaining data */
+ NetlinkConnectionManager *manager; /**< Netlink connection manager(eg. NetlinkServer) */
+};
+
+typedef std::map<uint64_t, NetlinkConnection *> connectionMap_t;
+
+#endif /* NETLINKCONNECTION_H_ */
+
+/** @} */
--- /dev/null
+# =============================================================================
+#
+# Module: mcDriverDaemon
+#
+# =============================================================================
+
+# Add new source files here
+LOCAL_SRC_FILES += Daemon/MobiCoreDriverDaemon.cpp
+
+# Includes required for the Daemon
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/Daemon/public
+
+# Ignore non-reproducible date/time expansions
+LOCAL_CFLAGS += -Wno-date-time
+
+# Internal components
+include $(LOCAL_PATH)/Daemon/Device/Android.mk
+include $(LOCAL_PATH)/Daemon/Server/Android.mk
+include $(LOCAL_PATH)/Daemon/FSD/Android.mk
--- /dev/null
+# =============================================================================
+#
+# MC driver device files
+#
+# =============================================================================
+
+# This is not a separate module.
+# Only for inclusion by other modules.
+# All paths are relative to APP_PROJECT_PATH
+
+DEVICE_PATH := Daemon/Device
+include $(LOCAL_PATH)/$(DEVICE_PATH)/Platforms/Android.mk
+
+# Add new folders with header files here
+# Include paths are absolute paths
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(DEVICE_PATH) \
+ $(LOCAL_PATH)/$(DEVICE_PATH)/public
+
+# Add new source files here
+LOCAL_SRC_FILES += $(DEVICE_PATH)/DeviceIrqHandler.cpp \
+ $(DEVICE_PATH)/DeviceScheduler.cpp \
+ $(DEVICE_PATH)/TAExitHandler.cpp \
+ $(DEVICE_PATH)/MobiCoreDevice.cpp \
+ $(DEVICE_PATH)/NotificationQueue.cpp \
+ $(DEVICE_PATH)/TrustletSession.cpp
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "DeviceIrqHandler.h"
+#include "log.h"
+
+//------------------------------------------------------------------------------
+void DeviceIrqHandler::run(
+ void
+)
+{
+ handleIrq();
+ this->exit(-1);
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ * IRQ handler thread.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DEVICEIRQHANDLER_H_
+#define DEVICEIRQHANDLER_H_
+
+#include "CThread.h"
+
+
+class DeviceIrqHandler: public CThread
+{
+
+public:
+
+ virtual void handleIrq() = 0;
+
+ void run();
+};
+
+#endif /* DEVICEIRQHANDLER_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "DeviceScheduler.h"
+
+
+//------------------------------------------------------------------------------
+void DeviceScheduler::run(
+ void
+)
+{
+ schedule();
+ exit(-1);
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ * Scheduler thread
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DEVICESCHEDULER_H_
+#define DEVICESCHEDULER_H_
+
+#include "CThread.h"
+
+
+class DeviceScheduler: public CThread
+{
+
+public:
+
+ virtual void schedule() = 0;
+
+ void run();
+
+};
+
+#endif /* DEVICESCHEDULER_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ */
+
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <cstdlib>
+#include <pthread.h>
+#include <assert.h>
+#include "McTypes.h"
+
+#include "DeviceScheduler.h"
+#include "DeviceIrqHandler.h"
+#include "ExcDevice.h"
+#include "Connection.h"
+#include "TrustletSession.h"
+
+#include "MobiCoreDevice.h"
+#include "Mci/mci.h"
+#include "mcLoadFormat.h"
+
+
+#include "log.h"
+#include "public/MobiCoreDevice.h"
+
+
+
+//------------------------------------------------------------------------------
+MobiCoreDevice::MobiCoreDevice()
+{
+ nq = NULL;
+ mcFlags = NULL;
+ mcVersionInfo = NULL;
+ mcFault = false;
+ mciReused = false;
+ mcpMessage = NULL;
+}
+
+//------------------------------------------------------------------------------
+MobiCoreDevice::~MobiCoreDevice()
+{
+ mciReused = false;
+ mcFault = false;
+ delete mcVersionInfo;
+ mcVersionInfo = NULL;
+ mcFlags = NULL;
+ nq = NULL;
+}
+
+//------------------------------------------------------------------------------
+TrustletSession *MobiCoreDevice::getTrustletSession(
+ uint32_t sessionId
+) {
+ for (trustletSessionIterator_t iterator = trustletSessions.begin();
+ iterator != trustletSessions.end();
+ ++iterator)
+ {
+ TrustletSession *session = *iterator;
+ if (session->sessionId == sessionId) {
+ return session;
+ }
+ }
+ return NULL;
+}
+
+
+//------------------------------------------------------------------------------
+Connection *MobiCoreDevice::getSessionConnection(
+ uint32_t sessionId,
+ notification_t *notification
+) {
+ Connection *con = NULL;
+
+ TrustletSession *session = getTrustletSession(sessionId);
+ if (session != NULL)
+ {
+ con = session->notificationConnection;
+ if (con == NULL)
+ {
+ session->queueNotification(notification);
+ }
+ }
+
+ return con;
+}
+
+
+//------------------------------------------------------------------------------
+TrustletSession* MobiCoreDevice::findSession(
+ Connection *deviceConnection,
+ uint32_t sessionId
+) {
+ TrustletSession *session = getTrustletSession(sessionId);
+ if (session == NULL)
+ {
+ LOG_E("no session found with id=%d", sessionId);
+ }
+ else
+ {
+ // check is connection own this session
+ if (session->deviceConnection != deviceConnection)
+ {
+ LOG_E("connection does not own session id=%d", sessionId);
+ session = NULL;
+ }
+ }
+ return session;
+}
+
+
+//------------------------------------------------------------------------------
+bool MobiCoreDevice::open(
+ Connection *connection
+) {
+ // Link this device to the connection
+ connection->connectionData = this;
+ return true;
+}
+
+//------------------------------------------------------------------------------
+// send a close session message. Used in three cases:
+// 1) during init to tell SWd to invalidate this session, if it is still open
+// from a prev Daemon instance
+// 2) normal session close
+// 3) close all session when Daemon terminates
+mcResult_t MobiCoreDevice::sendSessionCloseCmd(
+ uint32_t sessionId
+) {
+ // Write MCP close message to buffer
+ mcpMessage->cmdClose.cmdHeader.cmdId = MC_MCP_CMD_CLOSE_SESSION;
+ mcpMessage->cmdClose.sessionId = sessionId;
+
+ mcResult_t mcRet = mshNotifyAndWait();
+ if (mcRet != MC_MCP_RET_OK)
+ {
+ LOG_E("mshNotifyAndWait failed for CLOSE_SESSION, code %d.", mcRet);
+ return mcRet;
+ }
+
+ // Check if the command response ID is correct
+ if ((MC_MCP_CMD_CLOSE_SESSION | FLAG_RESPONSE) != mcpMessage->rspHeader.rspId) {
+ LOG_E("invalid MCP response for CLOSE_SESSION");
+ return MC_DRV_ERR_DAEMON_MCI_ERROR;
+ }
+
+ // Read MC answer from MCP buffer
+ mcRet = mcpMessage->rspOpen.rspHeader.result;
+
+ return mcRet;
+}
+
+//------------------------------------------------------------------------------
+// internal API to close a session
+mcResult_t MobiCoreDevice::closeSessionInternal(
+ TrustletSession *session
+) {
+ LOG_I("closing session with id=%d", session->sessionId);
+
+ mcResult_t mcRet = sendSessionCloseCmd(session->sessionId);
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_E("sendSessionCloseCmd error %d", mcRet);
+ return MAKE_MC_DRV_MCP_ERROR(mcRet);
+ }
+
+// // clean session WSM
+// LOG_I("unlocking session buffers!");
+// CWsm_ptr pWsm = session->popBulkBuff();
+// while (pWsm)
+// {
+// unlockWsmL2(pWsm->handle);
+// delete pWsm;
+// pWsm = session->popBulkBuff();
+// }
+
+ return MC_DRV_OK;
+}
+
+//------------------------------------------------------------------------------
+/**
+ * Close device.
+ *
+ * Removes all sessions to a connection. Though, clientLib rejects the closeDevice()
+ * command if still sessions connected to the device, this is needed to clean up all
+ * sessions if client dies.
+ */
+void MobiCoreDevice::close(
+ Connection *connection
+) {
+ // static mutex is the the same for each thread. So this serializes
+ // multiple connections failing at the same time.
+ static CMutex mutex;
+ // Enter critical section
+ mutex.lock();
+
+ // 1. Iterate through device session to find connection
+ // 2. Decide what to do with open Trustlet sessions
+ // 3. Remove & delete deviceSession from vector
+
+ // iterating over the list in reverse order, as the LIFO approach may
+ // avoid some quirks. The assumption is that a driver is opened before a
+ // TA, so we want to terminate the TA first and then the driver. This may
+ // make this a bit easier for everbody.
+
+ trustletSessionList_t::reverse_iterator revIt = trustletSessions.rbegin();
+ while (revIt != trustletSessions.rend())
+ {
+ TrustletSession *session = *revIt;
+
+ // wiredness of reverse iterators
+ // * is is incremented to get the next lowe element
+ // * to delete something from the list, we need the "normal" iterator.
+ // This is simpy "one off" the current revIt. So we can savely use
+ // the increment below in both cases.
+ revIt++;
+
+ if (session->deviceConnection == connection)
+ {
+ // close session, log any error but ignore it.
+ //mcResult_t mcRet = closeSessionInternal(session);
+ mcResult_t mcRet = closeSession(connection, session->sessionId);
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_I("device closeSession failed with %d", mcRet);
+ }
+
+ // removing an element from the list it tricky. Convert the revIt
+ // to a "normal" iterator. Remember here that the revIt is one off,
+ // but we have done an increment above, so we are fine here. So
+ // after we have the normal iterator, ude it to delete and then
+ // convert the returned iterator back to a reverse iterator, which
+ // we will use for the loop.
+ //trustletSessionIterator_t it = revIt.base();
+ //it = trustletSessions.erase(it); // delete
+ //revIt = trustletSessionList_t::reverse_iterator(it);
+
+ // free object
+ //delete session;
+ }
+ }
+
+ // Leave critical section
+ mutex.unlock();
+
+ // After the trustlet is done make sure to tell the driver to cleanup
+ // all the orphaned drivers
+ cleanupWsmL2();
+
+
+
+ connection->connectionData = NULL;
+
+ // Leave critical section
+ mutex.unlock();
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDevice::start(void)
+{
+ LOG_I("Starting DeviceIrqHandler...");
+ // Start the irq handling thread
+ DeviceIrqHandler::start("DevIrqHandler");
+
+ if (schedulerAvailable())
+ {
+ LOG_I("Starting DeviceScheduler...");
+ // Start the scheduling handling thread
+ DeviceScheduler::start();
+ }
+ else
+ {
+ LOG_I("No DeviceScheduler available.");
+ }
+
+ LOG_I("Starting TAExitHandler...");
+ TAExitHandler::start("TAExitHandler");
+
+ if (mciReused)
+ {
+ // remove all pending sessions. 20 is as good a any other number, we-
+ // actually should ass a MCP message that tells SWd to invalidate all-
+ // session that are there besides the MSH session.
+ for (int sessionId = 2; sessionId<20; sessionId++) {
+ LOG_I("invalidating session %d",sessionId);
+ mcResult_t mcRet = sendSessionCloseCmd(sessionId);
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_I("sendSessionCloseCmd error %d", mcRet);
+ }
+ }
+ }
+
+ return;
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDevice::signalMcpNotification(void)
+{
+ mcpSessionNotification.signal();
+}
+
+
+//------------------------------------------------------------------------------
+bool MobiCoreDevice::waitMcpNotification(void)
+{
+ int counter = 5; // retry 5 times
+ while (1)
+ {
+ // In case of fault just return, nothing to do here
+ if (mcFault)
+ {
+ return false;
+ }
+ // Wait 10 seconds for notification
+ if ( mcpSessionNotification.wait(10) )
+ {
+ break; // seem we got one.
+ }
+ // No MCP answer received and mobicore halted, dump mobicore status
+ // then throw exception
+ LOG_I("No MCP answer received in 2 seconds.");
+ if (getMobicoreStatus() == MC_STATUS_HALT)
+ {
+ dumpMobicoreStatus();
+ mcFault = true;
+ return false;
+ }
+
+ counter--;
+ if (counter < 1)
+ {
+ mcFault = true;
+ return false;
+ }
+ } // while(1)
+
+ // Check healthiness state of the device
+ if (DeviceIrqHandler::isExiting()) {
+ LOG_I("waitMcpNotification(): IrqHandler thread died! Joining");
+ DeviceIrqHandler::join();
+ LOG_I("waitMcpNotification(): Joined");
+ LOG_E("IrqHandler thread died!");
+ return false;
+ }
+
+ if (DeviceScheduler::isExiting()) {
+ LOG_I("waitMcpNotification(): Scheduler thread died! Joining");
+ DeviceScheduler::join();
+ LOG_I("waitMcpNotification(): Joined");
+ LOG_E("Scheduler thread died!");
+ return false;
+ }
+
+ if (TAExitHandler::isExiting()) {
+ LOG_I("waitMcpNotification(): TAExitHandler thread died! Joining");
+ TAExitHandler::join();
+ LOG_I("waitMcpNotification(): Joined");
+ LOG_E("TAExitHandler thread died!");
+ return false;
+ }
+ return true;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t MobiCoreDevice::mshNotifyAndWait()
+{
+ // Notify MC about the availability of a new command inside the MCP buffer
+ notify(SID_MCP);
+
+ // Wait till response from MSH is available
+ if (!waitMcpNotification())
+ {
+ LOG_E("waiting for MCP notification failed");
+ return MC_DRV_ERR_DAEMON_MCI_ERROR;
+ }
+
+ return MC_DRV_OK;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t MobiCoreDevice::openSession(
+ Connection *deviceConnection,
+ loadDataOpenSession_ptr pLoadDataOpenSession,
+ uint32_t tciHandle,
+ uint32_t tciLen,
+ uint32_t tciOffset,
+ mcDrvRspOpenSessionPayload_ptr pRspOpenSessionPayload)
+{
+ do {
+ uint64_t tci = 0;
+ uint32_t len = 0;
+
+ if (tciHandle != 0 && tciLen != 0) {
+ // Check if we have a cont WSM or normal one
+ if (findContiguousWsm(tciHandle,
+ deviceConnection->socketDescriptor, &tci, &len)) {
+ mcpMessage->cmdOpen.wsmTypeTci = WSM_CONTIGUOUS;
+ mcpMessage->cmdOpen.adrTciBuffer = tci;
+ mcpMessage->cmdOpen.ofsTciBuffer = 0;
+ } else if ((tci = findWsmL2(tciHandle, deviceConnection->socketDescriptor))) {
+ // We don't actually care about the len as the L2 table mapping is done
+ // // and the TL will segfault if it's trying to access non-allocated memory
+ len = tciLen;
+ mcpMessage->cmdOpen.wsmTypeTci = WSM_L2;
+ mcpMessage->cmdOpen.adrTciBuffer = tci;
+ mcpMessage->cmdOpen.ofsTciBuffer = tciOffset;
+ } else {
+ LOG_E("Failed to find contiguous WSM %u", tciHandle);
+ return MC_DRV_ERR_DAEMON_WSM_HANDLE_NOT_FOUND;
+ }
+
+ if (!lockWsmL2(tciHandle)) {
+ LOG_E("Failed to lock contiguous WSM %u", tciHandle);
+ return MC_DRV_ERR_DAEMON_WSM_HANDLE_NOT_FOUND;
+ }
+ } else if (tciHandle == 0 && tciLen == 0) {
+ mcpMessage->cmdOpen.wsmTypeTci = WSM_INVALID;
+ mcpMessage->cmdOpen.adrTciBuffer = (uint32_t)(tci);
+ mcpMessage->cmdOpen.ofsTciBuffer = tciOffset;
+ }
+
+ if ((tciHandle != 0 && tciLen == 0) || tciLen > len) {
+ LOG_E("Invalid TCI len from client - %u, tciHandle %d, Wsm len found %u",
+ tciLen, tciHandle, len);
+ return MC_DRV_ERR_TCI_GREATER_THAN_WSM;
+ }
+
+ // Write MCP open message to buffer
+ mcpMessage->cmdOpen.cmdHeader.cmdId = MC_MCP_CMD_OPEN_SESSION;
+ mcpMessage->cmdOpen.uuid = pLoadDataOpenSession->tlHeader->mclfHeaderV2.uuid;
+ mcpMessage->cmdOpen.lenTciBuffer = tciLen;
+ LOG_I(" Using phys=%#llx, len=%d as TCI buffer", (uint64_t)tci, tciLen);
+
+ // check if load data is provided
+ mcpMessage->cmdOpen.wsmTypeLoadData = WSM_L2;
+ mcpMessage->cmdOpen.adrLoadData = pLoadDataOpenSession->baseAddr;
+ mcpMessage->cmdOpen.ofsLoadData = pLoadDataOpenSession->offs;
+ mcpMessage->cmdOpen.lenLoadData = pLoadDataOpenSession->len;
+ memcpy(&mcpMessage->cmdOpen.tlHeader, pLoadDataOpenSession->tlHeader, sizeof(*pLoadDataOpenSession->tlHeader));
+
+ // Clear the notifications queue. We asume the race condition we have
+ // seen in openSession never happens elsewhere
+ notifications = std::queue<notification_t>();
+
+ mcResult_t mcRet = mshNotifyAndWait();
+ if (mcRet != MC_MCP_RET_OK)
+ {
+ LOG_E("mshNotifyAndWait failed for OPEN_SESSION, code %d.", mcRet);
+ // Here Mobicore can be considered dead.
+ if ((tciHandle != 0) && (tciLen != 0))
+ {
+ unlockWsmL2(tciHandle);
+ }
+ return mcRet;
+ }
+
+ // Check if the command response ID is correct
+ if ((MC_MCP_CMD_OPEN_SESSION | FLAG_RESPONSE) != mcpMessage->rspHeader.rspId) {
+ LOG_E("CMD_OPEN_SESSION got invalid MCP command response(0x%X)", mcpMessage->rspHeader.rspId);
+ // Something is messing with our MCI memory, we cannot know if the Trustlet was loaded.
+ // Had in been loaded, we are loosing track of it here.
+ if (tciHandle != 0 && tciLen != 0) {
+ unlockWsmL2(tciHandle);
+ }
+ return MC_DRV_ERR_DAEMON_MCI_ERROR;
+ }
+
+ mcRet = mcpMessage->rspOpen.rspHeader.result;
+
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_E("MCP OPEN returned code %d.", mcRet);
+ if (tciHandle != 0 && tciLen != 0) {
+ unlockWsmL2(tciHandle);
+ }
+ return MAKE_MC_DRV_MCP_ERROR(mcRet);
+ }
+
+ LOG_I(" After MCP OPEN, we have %d queued notifications",
+ notifications.size());
+ // Read MC answer from MCP buffer
+ TrustletSession *trustletSession = new TrustletSession(
+ deviceConnection,
+ mcpMessage->rspOpen.sessionId);
+
+ pRspOpenSessionPayload->sessionId = trustletSession->sessionId;
+ pRspOpenSessionPayload->deviceSessionId = (uintptr_t)trustletSession;
+ pRspOpenSessionPayload->sessionMagic = trustletSession->sessionMagic;
+
+ trustletSession->gp_level=((mclfHeaderV24_ptr)&pLoadDataOpenSession->tlHeader->mclfHeaderV2)->gp_level;
+ LOG_I(" Trusted App has gp_level %d",trustletSession->gp_level);
+ trustletSession->sessionState = TrustletSession::TS_TA_RUNNING;
+
+ trustletSessions.push_back(trustletSession);
+
+ if (tciHandle != 0 && tciLen != 0) {
+ trustletSession->addBulkBuff(new CWsm((void *)(uintptr_t)pLoadDataOpenSession->offs, pLoadDataOpenSession->len, tciHandle, 0));
+ }
+
+ // We have some queued notifications and we need to send them to them
+ // trustlet session
+ while (!notifications.empty()) {
+ trustletSession->queueNotification(¬ifications.front());
+ notifications.pop();
+ }
+
+ } while (0);
+ return MC_DRV_OK;
+}
+
+mcResult_t MobiCoreDevice::checkLoad(
+ loadDataOpenSession_ptr pLoadDataOpenSession,
+ mcDrvRspOpenSessionPayload_ptr pRspOpenSessionPayload __unused)
+{
+ do {
+ // Write MCP open message to buffer
+ mcpMessage->cmdCheckLoad.cmdHeader.cmdId = MC_MCP_CMD_CHECK_LOAD_TA;
+ mcpMessage->cmdCheckLoad.uuid = pLoadDataOpenSession->tlHeader->mclfHeaderV2.uuid;
+
+ // check if load data is provided
+ mcpMessage->cmdCheckLoad.wsmTypeLoadData = WSM_L2;
+ mcpMessage->cmdCheckLoad.adrLoadData = pLoadDataOpenSession->baseAddr;
+ mcpMessage->cmdCheckLoad.ofsLoadData = pLoadDataOpenSession->offs;
+ mcpMessage->cmdCheckLoad.lenLoadData = pLoadDataOpenSession->len;
+ memcpy(&mcpMessage->cmdCheckLoad.tlHeader, pLoadDataOpenSession->tlHeader, sizeof(*pLoadDataOpenSession->tlHeader));
+
+ // Clear the notifications queue. We asume the race condition we have
+ // seen in openSession never happens elsewhere
+ notifications = std::queue<notification_t>();
+
+ mcResult_t mcRet = mshNotifyAndWait();
+ if (mcRet != MC_MCP_RET_OK)
+ {
+ LOG_E("mshNotifyAndWait failed for CHECK_LOAD_TA, code %d.", mcRet);
+ // Here Mobicore can be considered dead.
+ return mcRet;
+ }
+
+ // Check if the command response ID is correct
+ if ((MC_MCP_CMD_CHECK_LOAD_TA | FLAG_RESPONSE) != mcpMessage->rspHeader.rspId) {
+ LOG_E("CMD_OPEN_SESSION got invalid MCP command response(0x%X)", mcpMessage->rspHeader.rspId);
+ // Something is messing with our MCI memory, we cannot know if the Trustlet was loaded.
+ // Had in been loaded, we are loosing track of it here.
+
+ return MC_DRV_ERR_DAEMON_MCI_ERROR;
+ }
+
+ mcRet = mcpMessage->rspCheckLoad.rspHeader.result;
+
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_E("MCP CHECK_LOAD returned code %d.", mcRet);
+ return MAKE_MC_DRV_MCP_ERROR(mcRet);
+ }
+ return MC_DRV_OK;
+
+ } while (0);
+ return MC_DRV_ERR_UNKNOWN;
+}
+
+
+
+//------------------------------------------------------------------------------
+TrustletSession *MobiCoreDevice::registerTrustletConnection(
+ Connection *connection,
+ MC_DRV_CMD_NQ_CONNECT_struct *cmdNqConnect
+)
+{
+ LOG_I(" Registering notification socket with Service session %d.",
+ cmdNqConnect->sessionId);
+ LOG_V(" Searching sessionId %d with sessionMagic %d",
+ cmdNqConnect->sessionId,
+ cmdNqConnect->sessionMagic);
+
+ for (trustletSessionIterator_t iterator = trustletSessions.begin();
+ iterator != trustletSessions.end();
+ ++iterator)
+ {
+ TrustletSession *session = *iterator;
+
+ if (session != (TrustletSession *)(uintptr_t) (cmdNqConnect->deviceSessionId)) {
+ continue;
+ }
+
+ if ( (session->sessionMagic != cmdNqConnect->sessionMagic)
+ || (session->sessionId != cmdNqConnect->sessionId)) {
+ continue;
+ }
+
+ session->notificationConnection = connection;
+
+ LOG_I(" Found Service session, registered connection.");
+
+ return session;
+ }
+
+ LOG_I("registerTrustletConnection(): search failed");
+ return NULL;
+}
+
+
+//------------------------------------------------------------------------------
+/**
+ * Need connection as well as according session ID, so that a client can not
+ * close sessions not belonging to him.
+ */
+mcResult_t MobiCoreDevice::closeSession(
+ Connection *deviceConnection,
+ uint32_t sessionId
+) {
+ TrustletSession *session = findSession(deviceConnection,sessionId);
+ if (session == NULL) {
+ LOG_E("cannot close session with id=%d", sessionId);
+ return MC_DRV_ERR_DAEMON_UNKNOWN_SESSION;
+ }
+
+ if (session->gp_level == 1) {
+ mutex_connection.lock();
+ LOG_I(" Closing GP TA session...");
+ // Disconnect client from this session
+ session->deviceConnection = NULL;
+ // Free connection, i.e. close nq socket
+ delete session->notificationConnection;
+ session->notificationConnection = NULL;
+ // If exit notification from task arrives during MCP_CLOSE,
+ // Daemon can see that CA is already away
+ session->sessionState = TrustletSession::TS_CLOSE_SEND;
+ mutex_connection.unlock();
+ }
+
+ /* close session */
+ mcResult_t mcRet = closeSessionInternal(session);
+
+ if ((session->gp_level==1) && (mcRet == MAKE_MC_DRV_MCP_ERROR(MC_MCP_RET_ERR_CLOSE_TASK_FAILED))) {
+ LOG_I(" Close session failed this time.");
+ // We could have received a spurious notification of TA dead
+ if (session->sessionState == TrustletSession::TS_TA_DEAD) {
+ LOG_V(" TA died in the meantime, try closing again");
+ // Try again
+ mcRet = closeSessionInternal(session);
+ assert(mcRet == MC_MCP_RET_OK);
+ } else {
+ // Clean up is deferred to handleTaExit()
+ return MC_MCP_RET_OK;
+ }
+ }
+
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_E("closeSession failed with %d", mcRet);
+ return MAKE_MC_DRV_MCP_ERROR(mcRet);
+ }
+
+
+ // clean session WSM
+ LOG_I("unlocking session buffers!");
+ CWsm_ptr pWsm = session->popBulkBuff();
+ while (pWsm)
+ {
+ unlockWsmL2(pWsm->handle);
+ delete pWsm;
+ pWsm = session->popBulkBuff();
+ }
+
+ // remove sesson from list.
+ for (trustletSessionIterator_t iterator = trustletSessions.begin();
+ iterator != trustletSessions.end();
+ ++iterator)
+ {
+ if (session == *iterator)
+ {
+ trustletSessions.erase(iterator);
+ delete session;
+ break;
+ }
+ }
+
+ return MC_MCP_RET_OK;
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDevice::queueUnknownNotification(
+ notification_t notification
+) {
+ notifications.push(notification);
+}
+
+//------------------------------------------------------------------------------
+mcResult_t MobiCoreDevice::notify(
+ Connection *deviceConnection,
+ uint32_t sessionId
+) {
+ TrustletSession *session = findSession(deviceConnection,sessionId);
+ if (session == NULL)
+ {
+ LOG_E("cannot notify session with id=%d", sessionId);
+ return MC_DRV_ERR_DAEMON_UNKNOWN_SESSION;
+ }
+
+ notify(sessionId);
+
+ return MC_DRV_OK;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t MobiCoreDevice::mapBulk(
+ Connection *deviceConnection,
+ uint32_t sessionId,
+ uint32_t handle,
+ uint64_t pAddrL2,
+ uint32_t offsetPayload,
+ uint32_t lenBulkMem,
+ uint32_t *secureVirtualAdr
+) {
+ TrustletSession *session = findSession(deviceConnection,sessionId);
+ if (session == NULL) {
+ LOG_E("cannot mapBulk on session with id=%d", sessionId);
+ return MC_DRV_ERR_DAEMON_UNKNOWN_SESSION;
+ }
+
+ // TODO-2012-09-06-haenellu: considernot ignoring the error case, ClientLib
+ // does not allow this.
+ session->addBulkBuff(
+ new CWsm((void *)(uintptr_t)offsetPayload,
+ lenBulkMem,
+ handle,
+ pAddrL2));
+
+ // Write MCP map message to buffer
+ mcpMessage->cmdMap.cmdHeader.cmdId = MC_MCP_CMD_MAP;
+ mcpMessage->cmdMap.sessionId = sessionId;
+ mcpMessage->cmdMap.wsmType = WSM_L2;
+ mcpMessage->cmdMap.adrBuffer = pAddrL2;
+ mcpMessage->cmdMap.ofsBuffer = offsetPayload;
+ mcpMessage->cmdMap.lenBuffer = lenBulkMem;
+
+ mcResult_t mcRet = mshNotifyAndWait();
+ if (mcRet != MC_MCP_RET_OK)
+ {
+ LOG_E("mshNotifyAndWait failed for MAP, code %d.", mcRet);
+ return mcRet;
+ }
+
+ // Check if the command response ID is correct
+ if (mcpMessage->rspHeader.rspId != (MC_MCP_CMD_MAP | FLAG_RESPONSE)) {
+ LOG_E("invalid MCP response for CMD_MAP");
+ return MC_DRV_ERR_DAEMON_MCI_ERROR;
+ }
+
+ mcRet = mcpMessage->rspMap.rspHeader.result;
+
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_E("MCP MAP returned code %d.", mcRet);
+ return MAKE_MC_DRV_MCP_ERROR(mcRet);
+ }
+
+ *secureVirtualAdr = mcpMessage->rspMap.secureVirtualAdr;
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t MobiCoreDevice::unmapBulk(
+ Connection *deviceConnection,
+ uint32_t sessionId,
+ uint32_t handle,
+ uint32_t secureVirtualAdr,
+ uint32_t lenBulkMem
+) {
+ TrustletSession *session = findSession(deviceConnection,sessionId);
+ if (session == NULL) {
+ LOG_E("cannot unmapBulk on session with id=%d", sessionId);
+ return MC_DRV_ERR_DAEMON_UNKNOWN_SESSION;
+ }
+
+ if (!session->findBulkBuff(handle, lenBulkMem)) {
+ LOG_E("cannot unmapBulk with handle=%d", handle);
+ return MC_DRV_ERR_DAEMON_WSM_HANDLE_NOT_FOUND;
+ }
+
+ // Write MCP unmap command to buffer
+ mcpMessage->cmdUnmap.cmdHeader.cmdId = MC_MCP_CMD_UNMAP;
+ mcpMessage->cmdUnmap.sessionId = sessionId;
+ mcpMessage->cmdUnmap.wsmType = WSM_L2;
+ mcpMessage->cmdUnmap.secureVirtualAdr = secureVirtualAdr;
+ mcpMessage->cmdUnmap.lenVirtualBuffer = lenBulkMem;
+
+ mcResult_t mcRet = mshNotifyAndWait();
+ if (mcRet != MC_MCP_RET_OK)
+ {
+ LOG_E("mshNotifyAndWait failed for UNMAP, code %d.", mcRet);
+ return mcRet;
+ }
+
+ // Check if the command response ID is correct
+ if (mcpMessage->rspHeader.rspId != (MC_MCP_CMD_UNMAP | FLAG_RESPONSE)) {
+ LOG_E("invalid MCP response for OPEN_SESSION");
+ return MC_DRV_ERR_DAEMON_MCI_ERROR;
+ }
+
+ mcRet = mcpMessage->rspUnmap.rspHeader.result;
+
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_E("MCP UNMAP returned code %d.", mcRet);
+ return MAKE_MC_DRV_MCP_ERROR(mcRet);
+ }
+
+ // Just remove the buffer
+ // TODO-2012-09-06-haenellu: Haven't we removed it already?
+ if (!session->removeBulkBuff(handle))
+ {
+ LOG_I("unmapBulk(): no buffer found found with handle=%u", handle);
+ }
+
+ return MC_DRV_OK;
+}
+
+mcResult_t MobiCoreDevice::getMobiCoreVersion(
+ mcDrvRspGetMobiCoreVersionPayload_ptr pRspGetMobiCoreVersionPayload
+) {
+ // retunt info it we have already fetched it before
+ if (mcVersionInfo != NULL)
+ {
+ pRspGetMobiCoreVersionPayload->versionInfo = *mcVersionInfo;
+ return MC_DRV_OK;
+ }
+
+ // Write MCP unmap command to buffer
+ mcpMessage->cmdGetMobiCoreVersion.cmdHeader.cmdId = MC_MCP_CMD_GET_MOBICORE_VERSION;
+
+ mcResult_t mcRet = mshNotifyAndWait();
+ if (mcRet != MC_MCP_RET_OK)
+ {
+ LOG_E("mshNotifyAndWait failed for GET_MOBICORE_VERSION, code %d.", mcRet);
+ return mcRet;
+ }
+
+ // Check if the command response ID is correct
+ if ((MC_MCP_CMD_GET_MOBICORE_VERSION | FLAG_RESPONSE) != mcpMessage->rspHeader.rspId) {
+ LOG_E("invalid MCP response for GET_MOBICORE_VERSION");
+ return MC_DRV_ERR_DAEMON_MCI_ERROR;
+ }
+
+ mcRet = mcpMessage->rspGetMobiCoreVersion.rspHeader.result;
+
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_E("MC_MCP_CMD_GET_MOBICORE_VERSION error %d", mcRet);
+ return MAKE_MC_DRV_MCP_ERROR(mcRet);
+ }
+
+ pRspGetMobiCoreVersionPayload->versionInfo = mcpMessage->rspGetMobiCoreVersion.versionInfo;
+
+ // Store MobiCore info for future reference.
+ mcVersionInfo = new mcVersionInfo_t();
+ *mcVersionInfo = pRspGetMobiCoreVersionPayload->versionInfo;
+ return MC_DRV_OK;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t MobiCoreDevice::loadToken(Connection *deviceConnection __unused,
+ loadTokenData_ptr pLoadTokenData)
+{
+ do {
+ mcpMessage->cmdLoadToken.cmdHeader.cmdId = MC_MCP_CMD_LOAD_TOKEN;
+ mcpMessage->cmdLoadToken.wsmTypeLoadData = WSM_L2;
+ mcpMessage->cmdLoadToken.adrLoadData = (uint32_t) pLoadTokenData->addr;
+ mcpMessage->cmdLoadToken.ofsLoadData = pLoadTokenData->offs;
+ mcpMessage->cmdLoadToken.lenLoadData = pLoadTokenData->len;
+
+ /* Clear the notifications queue. We asume the race condition we have
+ * seen in openSession never happens elsewhere
+ */
+ notifications = std::queue<notification_t>();
+
+ mcResult_t mcRet = mshNotifyAndWait();
+ if (mcRet != MC_MCP_RET_OK)
+ {
+ LOG_E("mshNotifyAndWait failed for LOAD_TOKEN, code 0x%x.", mcRet);
+ /* Here <t-base can be considered dead. */
+ return mcRet;
+ }
+
+ /* Check if the command response ID is correct */
+ if ((MC_MCP_CMD_LOAD_TOKEN | FLAG_RESPONSE) !=
+ mcpMessage->rspHeader.rspId) {
+ LOG_E("CMD_LOAD_TOKEN got invalid MCP command response(0x%X)",
+ mcpMessage->rspHeader.rspId);
+ return MC_DRV_ERR_DAEMON_MCI_ERROR;
+ }
+
+ mcRet = mcpMessage->rspLoadToken.rspHeader.result;
+
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_E("MCP LOAD_TOKEN returned code 0x%x.", mcRet);
+ return MAKE_MC_DRV_MCP_ERROR(mcRet);
+ }
+
+ } while (0);
+
+ return MC_DRV_OK;
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "NotificationQueue.h"
+#include <stddef.h>
+
+#include "log.h"
+
+//------------------------------------------------------------------------------
+NotificationQueue::NotificationQueue(
+ notificationQueue_t *i,
+ notificationQueue_t *o,
+ uint32_t size
+) : in(i), out(o)
+{
+ in->hdr.queueSize = size;
+ out->hdr.queueSize = size;
+}
+
+
+//------------------------------------------------------------------------------
+void NotificationQueue::putNotification(
+ notification_t *notification
+)
+{
+ mutex.lock();
+ if ((out->hdr.writeCnt - out->hdr.readCnt) < out->hdr.queueSize) {
+ out->notification[out->hdr.writeCnt & (out->hdr.queueSize - 1)]
+ = *notification;
+ out->hdr.writeCnt++;
+ }
+ mutex.unlock();
+}
+
+
+//------------------------------------------------------------------------------
+notification_t *NotificationQueue::getNotification(
+ void
+)
+{
+ notification_t *ret = NULL;
+ mutex.lock();
+ if ((in->hdr.writeCnt - in->hdr.readCnt) > 0) {
+ ret = &(in->notification[in->hdr.readCnt & (in->hdr.queueSize - 1)]);
+ in->hdr.readCnt++;
+ }
+ mutex.unlock();
+ return ret;
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ * MobiCore Notification Queue handling.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef NOTIFICATIONQUEUE_H_
+#define NOTIFICATIONQUEUE_H_
+
+#include <inttypes.h> //C99 data
+#include "Mci/mcinq.h"
+#include "CMutex.h"
+
+
+class NotificationQueue
+{
+
+public:
+
+ /** NQ Constructor, initializes the NQ component.
+ *
+ * makes the given queue object usable with the queue<Command> type of functions
+ *
+ * @param in queue to initialize
+ * @param out beginning of queue header
+ * @param queueSize Size of the queue
+ */
+ NotificationQueue(
+ notificationQueue_t *in,
+ notificationQueue_t *out,
+ uint32_t size
+ );
+
+ /** Places an element to the outgoing queue.
+ *
+ * @param notification Data to be placed in queue.
+ */
+ void putNotification(
+ notification_t *notification
+ );
+
+ /** Retrieves the first element from the queue.
+ *
+ * @return first notification Queue element.
+ * @return NULL if the queue is empty.
+ */
+ notification_t *getNotification(
+ void
+ );
+
+private:
+
+ notificationQueue_t *in;
+ notificationQueue_t *out;
+ CMutex mutex;
+
+};
+
+#endif /* NOTIFICATIONQUEUE_H_ */
+
+/** @} */
--- /dev/null
+# =============================================================================
+#
+# Makefile pointing to the platform specific makefile.
+#
+# =============================================================================
+
+PLATFORMS_PATH := $(LOCAL_PATH)/Daemon/Device/Platforms
+
+# Always include the Generic code
+include $(PLATFORMS_PATH)/Generic/Android.mk
+
+ifneq ($(filter-out Generic,$(PLATFORM)),)
+ $(info PLATFORM: $(PLATFORM))
+ include $(PLATFORMS_PATH)/$(PLATFORM)/Android.mk
+endif
--- /dev/null
+# =============================================================================
+#
+# Generic TrustZone device includes
+#
+# =============================================================================
+
+# This is not a separate module.
+# Only for inclusion by other modules.
+
+GENERIC_PATH := Daemon/Device/Platforms/Generic
+
+# Add new source files here
+LOCAL_SRC_FILES += $(GENERIC_PATH)/TrustZoneDevice.cpp
+
+# Header files for components including this module
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(GENERIC_PATH)
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ */
+
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <cstdlib>
+#include <stdio.h>
+#include <inttypes.h>
+#include <list>
+
+#include "McTypes.h"
+#include "mc_linux.h"
+#include "McTypes.h"
+#include "Mci/mci.h"
+#include "mcVersionHelper.h"
+
+#include "CSemaphore.h"
+#include "CMcKMod.h"
+
+#include "MobiCoreDevice.h"
+#include "TrustZoneDevice.h"
+#include "NotificationQueue.h"
+
+#include "log.h"
+
+
+#define NQ_NUM_ELEMS (16)
+#define NQ_BUFFER_SIZE (2 * (sizeof(notificationQueueHeader_t)+ NQ_NUM_ELEMS * sizeof(notification_t)))
+#define MCP_BUFFER_SIZE (sizeof(mcpBuffer_t))
+#define MCI_BUFFER_SIZE (NQ_BUFFER_SIZE + MCP_BUFFER_SIZE)
+
+//------------------------------------------------------------------------------
+__attribute__ ((weak)) MobiCoreDevice *getDeviceInstance(
+ void
+)
+{
+ return new TrustZoneDevice();
+}
+
+//------------------------------------------------------------------------------
+TrustZoneDevice::TrustZoneDevice(
+ void
+)
+{
+ schedulerEnabled = false;
+ pMcKMod = NULL;
+ pWsmMcp = NULL;
+ mobicoreInDDR = NULL;
+}
+
+//------------------------------------------------------------------------------
+TrustZoneDevice::~TrustZoneDevice(
+ void
+)
+{
+ delete pMcKMod;
+ delete pWsmMcp;
+ delete nq;
+}
+
+
+//------------------------------------------------------------------------------
+/**
+ * Set up MCI and wait till MC is initialized
+ * @return true if <t-base is already initialized
+ */
+bool TrustZoneDevice::initDevice(
+ const char *devFile,
+ bool enableScheduler)
+{
+ notificationQueue_t *nqStartOut;
+ notificationQueue_t *nqStartIn;
+ addr_t mciBuffer;
+
+ pMcKMod = new CMcKMod();
+ mcResult_t ret = pMcKMod->open(devFile);
+ if (ret != MC_DRV_OK)
+ {
+ LOG_W(" Opening kernel module device failed");
+ return false;
+ }
+ if (!pMcKMod->checkVersion())
+ {
+ LOG_E("kernel module version mismatch");
+ return false;
+ }
+
+ this->schedulerEnabled = enableScheduler;
+
+ // Init MC with NQ and MCP buffer addresses
+
+ // Set up MCI buffer
+ if (!getMciInstance(MCI_BUFFER_SIZE, &pWsmMcp, &mciReused))
+ {
+ LOG_E("getMciInstance failed");
+ return false;
+ }
+ mciBuffer = pWsmMcp->virtAddr;
+
+ // Only do a fastcall if MCI has not been reused (MC already initialized)
+ if (!mciReused)
+ {
+ // Wipe memory before first usage
+ memset(mciBuffer, 0, MCI_BUFFER_SIZE);
+
+ // Init MC with NQ and MCP buffer addresses
+ int ret = pMcKMod->fcInit(NQ_BUFFER_SIZE, NQ_BUFFER_SIZE, MCP_BUFFER_SIZE);
+ if (ret != 0)
+ {
+ LOG_E("pMcKMod->fcInit() failed");
+ return false;
+ }
+
+ // Here we are safe to setup the <t-base logs
+ setupLog();
+
+ // First empty N-SIQ which results in set up of the MCI structure
+ if (!nsiq())
+ {
+ LOG_E("sending N-SIQ failed");
+ return false;
+ }
+
+ // Wait until <t-base state switches to MC_STATUS_INITIALIZED
+ // It is assumed that <t-base always switches state at a certain point in time.
+ for(;;)
+ {
+ uint32_t timeslot;
+ uint32_t status = getMobicoreStatus();
+
+ if (MC_STATUS_INITIALIZED == status)
+ {
+ break;
+ }
+
+ if (MC_STATUS_NOT_INITIALIZED == status)
+ {
+ // Switch to <t-base to give it more CPU time.
+ for (timeslot = 0; timeslot < 10; timeslot++)
+ {
+ if (!yield())
+ {
+ LOG_E("yielding to SWd failed");
+ return false;
+ }
+ }
+ continue;
+ }
+
+ if (MC_STATUS_HALT == status)
+ {
+ dumpMobicoreStatus();
+ LOG_E("<t-base halted during init !!!, state is 0x%x", status);
+ return false;
+ }
+
+ // MC_STATUS_BAD_INIT or anything else
+ LOG_E("MCI buffer init failed, state is 0x%x", status);
+ return false;
+
+ } // for(;;)
+ }
+
+ nqStartOut = (notificationQueue_t *) mciBuffer;
+ nqStartIn = (notificationQueue_t *) ((uint8_t *) nqStartOut
+ + sizeof(notificationQueueHeader_t) + NQ_NUM_ELEMS
+ * sizeof(notification_t));
+
+ // Set up the NWd NQ
+ nq = new NotificationQueue(nqStartIn, nqStartOut, NQ_NUM_ELEMS);
+
+ mcpBuffer_t *mcpBuf = (mcpBuffer_t *) ((uint8_t *) mciBuffer + NQ_BUFFER_SIZE);
+
+ // Set up the MC flags
+ mcFlags = &(mcpBuf->mcFlags);
+
+ // Set up the MCP message
+ mcpMessage = &(mcpBuf->mcpMessage);
+
+ // convert virtual address of mapping to physical address for the init.
+ LOG_I("MCI established, at %p, phys=%#llx, reused=%s",
+ pWsmMcp->virtAddr,
+ pWsmMcp->physAddr,
+ mciReused ? "true" : "false");
+ return true;
+}
+
+
+//------------------------------------------------------------------------------
+void TrustZoneDevice::initDeviceStep2(
+ void
+)
+{
+ // not needed
+}
+
+
+//------------------------------------------------------------------------------
+bool TrustZoneDevice::yield(
+ void
+)
+{
+ int32_t ret = pMcKMod->fcYield();
+ if (ret != 0) {
+ LOG_E("pMcKMod->fcYield() failed: %d", ret);
+ }
+ return ret == 0;
+}
+
+
+//------------------------------------------------------------------------------
+bool TrustZoneDevice::nsiq(
+ void
+)
+{
+ // There is no need to set the NON-IDLE flag here. Sending an N-SIQ will
+ // make the <t-base run until it could set itself to a state where it
+ // set the flag itself. IRQs and FIQs are disbaled for this period, so
+ // there is no way the NWd can interrupt here.
+
+ // not needed: mcFlags->schedule = MC_FLAG_SCHEDULE_NON_IDLE;
+
+ int32_t ret = pMcKMod->fcNSIQ();
+ if (ret != 0) {
+ LOG_E("pMcKMod->fcNSIQ() failed : %d", ret);
+ return false;
+ }
+ // now we have to wake the scheduler, so <t-base gets CPU time.
+ schedSync.signal();
+ return true;
+}
+
+
+//------------------------------------------------------------------------------
+void TrustZoneDevice::notify(
+ uint32_t sessionId
+)
+{
+ // Check if it is MCP session - handle openSession() command
+ if (sessionId != SID_MCP) {
+ // Check if session ID exists to avoid flooding of nq by clients
+ TrustletSession *ts = getTrustletSession(sessionId);
+ if (ts == NULL) {
+ LOG_E("no session with id=%d", sessionId);
+ return;
+ }
+
+ LOG_I(" Sending notification for session %d to <t-base", sessionId);
+ } else {
+ LOG_I(" Sending MCP notification to <t-base");
+ }
+
+ // Notify <t-base about new data
+ notification_t notification = {
+ .sessionId = sessionId,
+ .payload = 0
+ };
+
+ nq->putNotification(¬ification);
+ //IMPROVEMENT-2012-03-07-maneaval What happens when/if nsiq fails?
+ //In the old days an exception would be thrown but it was uncertain
+ //where it was handled, some server(sock or Netlink). In that case
+ //the server would just die but never actually signaled to the client
+ //any error condition
+ nsiq();
+}
+
+//------------------------------------------------------------------------------
+uint32_t TrustZoneDevice::getMobicoreStatus(void)
+{
+ uint32_t status;
+ //IMPROVEMENT-2012-03-07-maneaval Can fcInfo ever fail? Before it threw an
+ //exception but the handler depended on the context.
+ pMcKMod->fcInfo(0, &status, NULL);
+
+ return status;
+}
+
+//------------------------------------------------------------------------------
+void TrustZoneDevice::dumpMobicoreStatus(
+ void
+) {
+ uint32_t status, info;
+
+ // read additional info about exception-point and print
+ LOG_E("<t-base halted. Status dump:");
+ pMcKMod->fcInfo(1, &status, &info);
+ LOG_W(" flags = 0x%08x", info);
+ pMcKMod->fcInfo(2, &status, &info);
+ LOG_W(" haltCode = 0x%08x", info);
+ pMcKMod->fcInfo(3, &status, &info);
+ LOG_W(" haltIp = 0x%08x", info);
+ pMcKMod->fcInfo(4, &status, &info);
+ LOG_W(" faultRec.cnt = 0x%08x", info);
+ pMcKMod->fcInfo(5, &status, &info);
+ LOG_W(" faultRec.cause = 0x%08x", info);
+ pMcKMod->fcInfo(6, &status, &info);
+ LOG_W(" faultRec.meta = 0x%08x", info);
+ pMcKMod->fcInfo(7, &status, &info);
+ LOG_W(" faultRec.thread = 0x%08x", info);
+ pMcKMod->fcInfo(8, &status, &info);
+ LOG_W(" faultRec.ip = 0x%08x", info);
+ pMcKMod->fcInfo(9, &status, &info);
+ LOG_W(" faultRec.sp = 0x%08x", info);
+ pMcKMod->fcInfo(10, &status, &info);
+ LOG_W(" faultRec.arch.dfsr = 0x%08x", info);
+ pMcKMod->fcInfo(11, &status, &info);
+ LOG_W(" faultRec.arch.adfsr = 0x%08x", info);
+ pMcKMod->fcInfo(12, &status, &info);
+ LOG_W(" faultRec.arch.dfar = 0x%08x", info);
+ pMcKMod->fcInfo(13, &status, &info);
+ LOG_W(" faultRec.arch.ifsr = 0x%08x", info);
+ pMcKMod->fcInfo(14, &status, &info);
+ LOG_W(" faultRec.arch.aifsr = 0x%08x", info);
+ pMcKMod->fcInfo(15, &status, &info);
+ LOG_W(" faultRec.arch.ifar = 0x%08x", info);
+ pMcKMod->fcInfo(16, &status, &info);
+ LOG_W(" mcData.flags = 0x%08x", info);
+ pMcKMod->fcInfo(19, &status, &info);
+ LOG_W(" mcExcep.partner = 0x%08x", info);
+ pMcKMod->fcInfo(20, &status, &info);
+ LOG_W(" mcExcep.peer = 0x%08x", info);
+ pMcKMod->fcInfo(21, &status, &info);
+ LOG_W(" mcExcep.message = 0x%08x", info);
+ pMcKMod->fcInfo(22, &status, &info);
+ LOG_W(" mcExcep.data = 0x%08x", info);
+}
+
+//------------------------------------------------------------------------------
+bool TrustZoneDevice::waitSsiq(void)
+{
+ uint32_t cnt;
+ if (!pMcKMod->waitSSIQ(&cnt)) {
+ LOG_E("pMcKMod->SSIQ() failed");
+ return false;
+ }
+ LOG_I(" Received SSIQ interrupt from <t-base, counter=%u", cnt);
+ return true;
+}
+
+
+//------------------------------------------------------------------------------
+bool TrustZoneDevice::getMciInstance(uint32_t len, CWsm_ptr *mci, bool *reused)
+{
+ addr_t virtAddr;
+ uint32_t handle;
+ uint64_t physAddr;
+ bool isReused = true;
+ if (len == 0) {
+ LOG_E("allocateWsm() length is 0");
+ return false;
+ }
+
+ mcResult_t ret = pMcKMod->mapMCI(len, &handle, &virtAddr, &physAddr, &isReused);
+ if (ret != MC_DRV_OK) {
+ LOG_E("pMcKMod->mmap() failed: %x", ret);
+ return false;
+ }
+
+ *mci = new CWsm(virtAddr, len, handle, physAddr);
+ *reused = isReused;
+ return true;
+}
+
+
+//------------------------------------------------------------------------------
+//bool TrustZoneDevice::freeWsm(CWsm_ptr pWsm)
+//{
+// int ret = pMcKMod->free(pWsm->handle, pWsm->virtAddr, pWsm->len);
+// if (ret != 0) {
+// LOG_E("pMcKMod->free() failed: %d", ret);
+// return false;
+// }
+// delete pWsm;
+// return true;
+//}
+
+
+//------------------------------------------------------------------------------
+CWsm_ptr TrustZoneDevice::registerWsmL2(addr_t buffer, uint32_t len, uint32_t pid)
+{
+ uint64_t physAddr;
+ uint32_t handle;
+
+ int ret = pMcKMod->registerWsmL2(
+ buffer,
+ len,
+ pid,
+ &handle,
+ &physAddr);
+ if (ret != 0) {
+ LOG_E("ipMcKMod->registerWsmL2() failed: %d", ret);
+ return NULL;
+ }
+
+ return new CWsm(buffer, len, handle, physAddr);
+}
+
+
+//------------------------------------------------------------------------------
+CWsm_ptr TrustZoneDevice::allocateContiguousPersistentWsm(uint32_t len)
+{
+ CWsm_ptr pWsm = NULL;
+ // Allocate shared memory
+ addr_t virtAddr;
+ uint32_t handle;
+ uint64_t physAddr;
+
+ if (len == 0 )
+ return NULL;
+
+ if (pMcKMod->mapWsm(len, &handle, &virtAddr, &physAddr))
+ return NULL;
+
+ // Register (vaddr,paddr) with device
+ pWsm = new CWsm(virtAddr, len, handle, physAddr);
+
+ // Return pointer to the allocated memory
+ return pWsm;
+}
+
+
+//------------------------------------------------------------------------------
+bool TrustZoneDevice::unregisterWsmL2(CWsm_ptr pWsm)
+{
+ int ret = pMcKMod->unregisterWsmL2(pWsm->handle);
+ if (ret != 0) {
+ LOG_E("pMcKMod->unregisterWsmL2 failed: %d", ret);
+ //IMPROVEMENT-2012-03-07 maneaval Make sure we don't leak objects
+ return false;
+ }
+ delete pWsm;
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool TrustZoneDevice::lockWsmL2(uint32_t handle)
+{
+ int ret = pMcKMod->lockWsmL2(handle);
+ if (ret != 0) {
+ LOG_E("pMcKMod->unregisterWsmL2 failed: %d", ret);
+ return false;
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool TrustZoneDevice::unlockWsmL2(uint32_t handle)
+{
+ LOG_I(" Unlocking buffer with handle %u", handle);
+ int ret = pMcKMod->unlockWsmL2(handle);
+ if (ret != 0) {
+ // Failure here is not important
+ LOG_I(" pMcKMod->unregisterWsmL2 failed: %d", ret);
+ return false;
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool TrustZoneDevice::cleanupWsmL2(void)
+{
+ int ret = pMcKMod->cleanupWsmL2();
+ if (ret != 0) {
+ LOG_E("pMcKMod->cleanupWsmL2 failed: %d", ret);
+ return false;
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------------
+uint64_t TrustZoneDevice::findWsmL2(uint32_t handle, int fd)
+{
+ uint64_t ret = pMcKMod->findWsmL2(handle, fd);
+ if (!ret) {
+ LOG_E("pMcKMod->findWsmL2 failed");
+ return 0;
+ }
+ LOG_I("Resolved buffer with handle %u to %#llx", handle, ret);
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+bool TrustZoneDevice::findContiguousWsm(uint32_t handle, int fd, uint64_t *phys, uint32_t *len)
+{
+ if (pMcKMod->findContiguousWsm(handle, fd, phys, len)) {
+ LOG_V(" pMcKMod->findContiguousWsm failed");
+ return false;
+ }
+ LOG_I("Resolved buffer with handle %u to %#llx", handle, *phys);
+ return true;
+}
+//------------------------------------------------------------------------------
+bool TrustZoneDevice::setupLog(void)
+{
+ if (pMcKMod->setupLog()) {
+ LOG_W("pMcKMod->setupLog failed");
+ return false;
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool TrustZoneDevice::schedulerAvailable(void)
+{
+ return schedulerEnabled;
+}
+
+//------------------------------------------------------------------------------
+//TODO Schedulerthread to be switched off if MC is idle. Will be woken up when
+// driver is called again.
+void TrustZoneDevice::schedule(void)
+{
+ uint32_t timeslice = SCHEDULING_FREQ;
+
+ // loop forever
+ for (;;)
+ {
+ // Scheduling decision
+ if (MC_FLAG_SCHEDULE_IDLE == mcFlags->schedule)
+ {
+ // <t-base is IDLE. Prevent unnecessary consumption of CPU cycles
+ // and wait for S-SIQ
+ schedSync.wait(); // check return code?
+ continue;
+ }
+
+ // <t-base is no longer IDLE, Check timeslice
+ if (timeslice == 0)
+ {
+ // Slice expired, so force MC internal scheduling decision
+ timeslice = SCHEDULING_FREQ;
+ if (!nsiq())
+ {
+ LOG_E("sending N-SIQ failed");
+ break;
+ }
+ continue;
+ }
+
+ // Slice not used up, simply hand over control to the MC
+ timeslice--;
+ if (!yield())
+ {
+ LOG_E("yielding to SWd failed");
+ break;
+ }
+ } //for (;;)
+
+ LOG_E("schedule loop terminated");
+}
+
+
+//------------------------------------------------------------------------------
+void TrustZoneDevice::handleTaExit(void)
+{
+ LOG_I("Starting Trusted Application Exit handler...");
+ for (;;) {
+ // Wait until we get a notification without CA
+ taExitNotification.wait();
+
+ // Wait until socket server frees MCP
+ // Make sure we don't interfere with handleConnection/dropConnection
+ mutex_mcp.lock();
+
+ // Check all sessions
+ // Socket server might have closed already and removed the session we were waken up for
+ for (trustletSessionIterator_t iterator = trustletSessions.begin();
+ iterator != trustletSessions.end();
+ )
+ {
+ TrustletSession *ts = *iterator;
+
+ if (ts->sessionState == TrustletSession::TS_TA_DEAD) {
+ LOG_I("Cleaning up session %i", ts->sessionId);
+
+ // Tell t-base to close the session
+ mcResult_t mcRet = closeSessionInternal(ts);
+
+ // If ok, remove objects
+ if (mcRet == MC_DRV_OK) {
+ iterator = trustletSessions.erase(iterator);
+ LOG_I("TA session %i finally closed", ts->sessionId);
+ delete ts;
+ continue;
+ } else {
+ LOG_I("TA session %i could not be closed yet.", ts->sessionId);
+ }
+ }
+ ++iterator;
+ }
+ mutex_mcp.unlock();
+ }
+ TAExitHandler::setExiting();
+ signalMcpNotification();
+
+ LOG_E("schedule loop terminated");
+}
+
+
+//------------------------------------------------------------------------------
+void TrustZoneDevice::handleIrq(
+ void
+) {
+ LOG_I("Starting Notification Queue IRQ handler...");
+
+ for (;;)
+ {
+
+ LOG_I(" No notifications pending, waiting for S-SIQ");
+ if (!waitSsiq())
+ {
+ LOG_E("Waiting for S-SIQ failed");
+ break;
+ }
+
+ LOG_V("S-SIQ received");
+
+ // get notifications from queue
+ for (;;)
+ {
+ notification_t *notification = nq->getNotification();
+ if (NULL == notification)
+ {
+ break;
+ }
+
+ // process the notification
+ // check if the notification belongs to the MCP session
+ if (notification->sessionId == SID_MCP)
+ {
+ LOG_I(" Notification for MCP, payload=%d",
+ notification->payload);
+
+ // Signal main thread of the driver to continue after MCP
+ // command has been processed by the MC
+ signalMcpNotification();
+
+ continue;
+ }
+
+ LOG_I(" Notification for session %d, payload=%d",
+ notification->sessionId, notification->payload);
+
+ // Get the Trustlet session for the session ID
+ TrustletSession *ts = NULL;
+
+ ts = getTrustletSession(notification->sessionId);
+ if (ts == NULL) {
+ /* Couldn't find the session for this notifications
+ * In practice this only means one thing: there is
+ * a race condition between RTM and the Daemon and
+ * RTM won. But we shouldn't drop the notification
+ * right away we should just queue it in the device
+ */
+ LOG_W("Notification for unknown session ID");
+ queueUnknownNotification(*notification);
+ } else {
+ mutex_connection.lock();
+ // Get the NQ connection for the session ID
+ Connection *connection = ts->notificationConnection;
+ if (connection == NULL) {
+ ts->queueNotification(notification);
+ if (ts->deviceConnection == NULL) {
+ LOG_I(" Notification for disconnected client, scheduling cleanup of sessions.");
+ taExitNotification.signal();
+ }
+ } else {
+ LOG_I(" Forward notification to McClient.");
+ // Forward session ID and additional payload of
+ // notification to the TLC/Application layer
+ connection->writeData((void *)notification,
+ sizeof(notification_t));
+ }
+ mutex_connection.unlock();
+ }
+ } // for (;;) over notifiction queue
+
+ // finished processing notifications. It does not matter if there were
+ // any notification or not. S-SIQs can also be triggered by an SWd
+ // driver which was waiting for a FIQ. In this case the S-SIQ tells
+ // NWd that SWd is no longer idle an will need scheduling again
+ schedSync.signal();
+
+ } //for (;;)
+
+
+ LOG_E("S-SIQ exception");
+ // Tell main thread that "something happened"
+ // MSH thread MUST not block!
+ DeviceIrqHandler::setExiting();
+ signalMcpNotification();
+}
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ * Class for TrustZone Devices.
+ * TrustZone device implements communication functions needed for
+ * accessing MobiCore located in an TrustZone environment.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef TRUSTZONEDEVICE_H_
+#define TRUSTZONEDEVICE_H_
+
+
+#include <stdint.h>
+
+#include "McTypes.h"
+
+#include "CSemaphore.h"
+#include "CMcKMod.h"
+#include "CWsm.h"
+
+#include "ExcDevice.h"
+#include "MobiCoreDevice.h"
+
+
+#define SCHEDULING_FREQ 5 /**< N-SIQ every n-th time */
+
+class TrustZoneDevice : public MobiCoreDevice
+{
+
+protected:
+ bool schedulerEnabled; /**< NQ IRQ Scheduler enabling */
+ CSemaphore schedSync; /**< Semaphore to synchronize S-SIQs with scheduler thread */
+ CMcKMod_ptr pMcKMod; /**< kernel module */
+ CWsm_ptr pWsmMcp; /**< WSM use for MCP */
+ CWsm_ptr mobicoreInDDR; /**< WSM used for Mobicore binary */
+
+ /** Access functions to the MC Linux kernel module
+ */
+ bool yield(void);
+
+ bool nsiq(void);
+
+ bool waitSsiq(void);
+
+public:
+
+ TrustZoneDevice(void);
+
+ virtual ~TrustZoneDevice(void);
+
+// static MobiCoreDevice* getDeviceInstance(
+// void
+// );
+ /** Set up MCI and wait till MC is initialized
+ *
+ * @param devFile the device node to speak to.
+ * @param loadMobiCore
+ * @param mobicoreImage
+ * @param enableScheduler
+ *
+ * @return true if mobicore is initialized
+ * @trows ExcDevice
+ */
+ bool initDevice(
+ const char *devFile,
+ bool enableScheduler
+ );
+
+ void initDeviceStep2(void);
+
+ void notify(uint32_t sessionId);
+
+ void dumpMobicoreStatus(void);
+
+ uint32_t getMobicoreStatus(void);
+
+ bool checkMciVersion(void);
+
+ /** Memory allocation functions */
+ bool getMciInstance(uint32_t len, CWsm_ptr *mci, bool *reused);
+
+ //bool freeWsm(CWsm_ptr pWsm);
+
+ CWsm_ptr registerWsmL2(addr_t buffer, uint32_t len, uint32_t pid);
+
+ bool unregisterWsmL2(CWsm_ptr pWsm);
+
+ bool lockWsmL2(uint32_t handle);
+
+ bool unlockWsmL2(uint32_t handle);
+
+ uint64_t findWsmL2(uint32_t handle, int fd);
+
+ bool findContiguousWsm(uint32_t handle, int fd, uint64_t *phys, uint32_t *len);
+
+ /**
+ * Cleanup all orphaned bulk buffers.
+ */
+ bool cleanupWsmL2(void);
+
+ /**
+ * Allocates persistent WSM memory for TL (won't be fried when TLC exits).
+ */
+ CWsm_ptr allocateContiguousPersistentWsm(uint32_t len);
+
+ bool setupLog(void);
+
+ bool schedulerAvailable(void);
+
+ void schedule(void);
+
+ void handleIrq(void);
+
+ void handleTaExit(void);
+};
+
+#endif /* TRUSTZONEDEVICE_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "TAExitHandler.h"
+#include "log.h"
+
+//------------------------------------------------------------------------------
+void TAExitHandler::run(
+ void
+)
+{
+ handleTaExit();
+ this->exit(-1);
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ * Trusted Application exit handler thread.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _TAEXITHANDLER_H_
+#define _TAEXITHANDLER_H_
+
+#include "CThread.h"
+#include "CMutex.h"
+#include "TrustletSession.h"
+
+
+class TAExitHandler: public CThread
+{
+public:
+ CSemaphore taExitNotification;
+
+ virtual void handleTaExit() = 0;
+
+ void run();
+};
+
+#endif /* TAEXITHANDLER_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "TrustletSession.h"
+#include <cstdlib>
+
+#include "log.h"
+
+using namespace std;
+
+//------------------------------------------------------------------------------
+TrustletSession::TrustletSession(Connection *deviceConnection, uint32_t sessionId)
+{
+ this->deviceConnection = deviceConnection;
+ this->notificationConnection = NULL;
+ this->sessionId = sessionId;
+ sessionMagic = rand();
+ this->gp_level=0;
+ this->sessionState=TS_TA_RUNNING;
+}
+
+
+//------------------------------------------------------------------------------
+TrustletSession::~TrustletSession(void)
+{
+ map<uint32_t, CWsm_ptr>::iterator it;
+ delete notificationConnection;
+
+ if (!buffers.empty()) {
+ LOG_W("%s: Mapped buffers still available %u", __func__, buffers.size());
+ }
+ for ( it = buffers.begin() ; it != buffers.end(); it++ )
+ delete (*it).second;
+
+ buffers.clear();
+}
+
+//------------------------------------------------------------------------------
+void TrustletSession::queueNotification(notification_t *notification)
+{
+ if (sessionState == TS_TA_DEAD) {
+ return;
+ }
+ if ((gp_level == 1) && (notification->payload != 0)) {
+ LOG_I(" Mark session %i dead", sessionId);
+ sessionState = TS_TA_DEAD;
+ }
+ // Note this is a very subtle synchronization requirement:
+ // The TrustletSession object is manipulated by several threads
+ // If the sessionState is set to closed,
+ // it means another thread could soon delete the object
+ // Also in this case we don't care about any notifications anymore
+ if (sessionState == TS_CLOSE_SEND) {
+ return;
+ }
+
+ notifications.push(*notification);
+}
+
+//------------------------------------------------------------------------------
+void TrustletSession::processQueuedNotifications(void)
+{
+ LOG_I(" %s:%i", __FILE__, __LINE__ );
+
+ // Nothing to do here!
+ if (notificationConnection == NULL)
+ return;
+
+ while (!notifications.empty()) {
+ // Forward session ID and additional payload of
+ // notification to the just established connection
+ notificationConnection->writeData((void *)¬ifications.front(),
+ sizeof(notification_t));
+ notifications.pop();
+ }
+}
+
+//------------------------------------------------------------------------------
+bool TrustletSession::addBulkBuff(CWsm_ptr pWsm)
+{
+ if (!pWsm)
+ return false;
+ if (buffers.find(pWsm->handle) != buffers.end()) {
+ delete pWsm;
+ return false;
+ }
+ buffers[pWsm->handle] = pWsm;
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool TrustletSession::removeBulkBuff(uint32_t handle)
+{
+ if (buffers.find(handle) == buffers.end()) {
+ return false;
+ }
+ CWsm_ptr pWsm = buffers[handle];
+ delete pWsm;
+ buffers.erase(handle);
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool TrustletSession::findBulkBuff(uint32_t handle, uint32_t lenBulkMem)
+{
+ if (buffers.find(handle) == buffers.end()) {
+ return false;
+ }
+ CWsm_ptr pWsm = buffers[handle];
+ if ((uint32_t)pWsm->len != lenBulkMem) {
+ return false;
+ }
+
+ return true;
+}
+
+//------------------------------------------------------------------------------
+CWsm_ptr TrustletSession::popBulkBuff()
+{
+ if (buffers.empty()) {
+ return NULL;
+ }
+
+ CWsm_ptr pWsm = buffers.begin()->second;
+ // Remove it from the map
+ buffers.erase(pWsm->handle);
+ return pWsm;
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef TRUSTLETSESSION_H_
+#define TRUSTLETSESSION_H_
+
+#include "NotificationQueue.h"
+#include "CWsm.h"
+#include "Connection.h"
+#include <queue>
+#include <map>
+
+
+class TrustletSession
+{
+private:
+ std::queue<notification_t> notifications;
+ std::map<uint32_t, CWsm_ptr> buffers;
+
+public:
+ uint32_t sessionId; // Assigned by t-base
+ uint32_t sessionMagic; // Random data
+ Connection *deviceConnection; // Command socket for client "device"
+ Connection *notificationConnection; // Notification socket for client session
+ uint32_t gp_level;
+ enum TS_STATE {
+ TS_TA_RUNNING,//->dead,close_send
+ TS_TA_DEAD, //->close_send, closed
+ TS_CLOSE_SEND,//->close_send, dead, closed
+ TS_CLOSED,//unused
+ } sessionState;
+
+ TrustletSession(Connection *deviceConnection, uint32_t sessionId);
+
+ ~TrustletSession(void);
+
+ void queueNotification(notification_t *notification);
+
+ void processQueuedNotifications(void);
+
+ bool addBulkBuff(CWsm_ptr pWsm);
+
+ bool removeBulkBuff(uint32_t handle);
+
+ bool findBulkBuff(uint32_t handle, uint32_t lenBulkMem);
+
+ CWsm_ptr popBulkBuff();
+
+};
+
+typedef std::list<TrustletSession *> trustletSessionList_t;
+typedef trustletSessionList_t::iterator trustletSessionIterator_t;
+
+#endif /* TRUSTLETSESSION_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ * Device exceptions.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef EXCDEVICE_H_
+#define EXCDEVICE_H_
+
+#include <stdint.h>
+#include <exception>
+#include <cstdio>
+#include <cstdlib>
+
+#define ERROR_MCI_VERSION_MISMATCH ((int)(-2))
+#define ERROR_KMOD_VERSION_MISMATCH ((int)(-3))
+
+class ExcDevice: public std::exception
+{
+
+public:
+
+ ExcDevice(const char *description, int cause) :
+ cause(cause), description(description) {
+ }
+
+ virtual int getCause() const throw () {
+ return cause;
+ }
+
+ virtual const char *getDescription() const throw () {
+ return description;
+ }
+
+private:
+
+ int cause;
+ const char *description;
+};
+
+#endif /* EXCDEVICE_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
+ * @{
+ * @file
+ *
+ * MobiCore device.
+ * The MobiCore device class handles the MCP processing within the driver.
+ * Concrete devices implementing the communication behavior for the platforms have to be derived
+ * from this.
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef MOBICOREDEVICE_H_
+#define MOBICOREDEVICE_H_
+
+#include <stdint.h>
+#include <vector>
+
+#include "McTypes.h"
+#include "MobiCoreDriverApi.h"
+
+#include "Mci/mcimcp.h"
+#include "mcLoadFormat.h"
+#include "MobiCoreDriverCmd.h"
+
+#include "Connection.h"
+#include "CWsm.h"
+
+#include "ExcDevice.h"
+#include "DeviceScheduler.h"
+#include "DeviceIrqHandler.h"
+#include "TAExitHandler.h"
+#include "NotificationQueue.h"
+#include "TrustletSession.h"
+#include "mcVersionInfo.h"
+
+
+class MobiCoreDevice;
+
+typedef struct {
+ uint64_t baseAddr; /**< Physical address of the data to load. */
+ uint32_t offs; /**< Offset to the data. */
+ uint32_t len; /**< Length of the data to load. */
+ mclfHeader_ptr tlHeader; /**< Pointer to trustlet header. */
+} loadDataOpenSession_t, *loadDataOpenSession_ptr;
+
+typedef struct {
+ uint64_t addr; /**< Physical address of the data to load. */
+ uint64_t offs; /**< Offset to the data. */
+ uint64_t len; /**< Length of the data to load. */
+} loadTokenData_t, *loadTokenData_ptr;
+
+/**
+ * Factory method to return the platform specific MobiCore device.
+ * Implemented in the platform specific *Device.cpp
+ */
+extern MobiCoreDevice *getDeviceInstance(void);
+
+class MobiCoreDevice : public DeviceScheduler, public DeviceIrqHandler, public TAExitHandler
+{
+
+protected:
+
+ NotificationQueue *nq; /**< Pointer to the notification queue within the MCI buffer */
+ mcFlags_t *mcFlags; /**< Pointer to the MC flags within the MCI buffer */
+ mcpMessage_t *mcpMessage; /**< Pointer to the MCP message structure within the MCI buffer */
+ CSemaphore mcpSessionNotification; /**< Semaphore to synchronize incoming notifications for the MCP session */
+
+ trustletSessionList_t trustletSessions; /**< Available Trustlet Sessions */
+ mcVersionInfo_t *mcVersionInfo; /**< MobiCore version info. */
+ bool mcFault; /**< Signal RTM fault */
+ bool mciReused; /**< Signal restart of Daemon. */
+ CMutex mutex_connection; // Mutex to share session->notificationConnection for GP cases
+
+ /* In a special case a Trustlet can create a race condition in the daemon.
+ * If at Trustlet start it detects an error of some sort and calls the
+ * exit function before waiting for any notifications from NWD then the daemon
+ * will receive the openSession notification from RTM and the error notification
+ * from the Trustlet at the same time but because the internal objects in
+ * the daemon are not yet completely setup then the error notification will
+ * never be sent to the TLC!
+ *
+ * This queue holds notifications received between the time the daemon
+ * puts the MCP command for open session until the internal session objects
+ * are setup correctly.
+ */
+ std::queue<notification_t> notifications; /**< Notifications queue for open session notification */
+
+ MobiCoreDevice();
+
+ mcResult_t closeSessionInternal(
+ TrustletSession* session);
+
+ mcResult_t sendSessionCloseCmd(
+ uint32_t sessionId);
+
+ TrustletSession* findSession(
+ Connection *deviceConnection,
+ uint32_t sessionId);
+
+ TrustletSession *getTrustletSession(
+ uint32_t sessionId);
+
+ mcResult_t mshNotifyAndWait(void);
+
+ void signalMcpNotification(void);
+
+ bool waitMcpNotification(void);
+
+private:
+ virtual bool yield(void) = 0;
+
+ virtual bool nsiq(void) = 0;
+
+ virtual bool waitSsiq(void) = 0;
+
+public:
+ CMutex mutex_mcp; // This mutex should be taken before any access to below functions
+
+ virtual ~MobiCoreDevice();
+
+ Connection *getSessionConnection(uint32_t sessionId, notification_t *notification);
+
+ bool open(Connection *connection);
+
+ void close(Connection *connection);
+
+ mcResult_t openSession(Connection *deviceConnection,
+ loadDataOpenSession_ptr pLoadDataOpenSession,
+ uint32_t tciHandle,
+ uint32_t tciLen,
+ uint32_t tciOffset,
+ mcDrvRspOpenSessionPayload_ptr pRspOpenSessionPayload);
+
+ mcResult_t checkLoad(loadDataOpenSession_ptr pLoadDataOpenSession,
+ mcDrvRspOpenSessionPayload_ptr pRspOpenSessionPayload);
+
+
+ TrustletSession *registerTrustletConnection(Connection *connection,
+ MC_DRV_CMD_NQ_CONNECT_struct *cmdNqConnect);
+
+
+ mcResult_t closeSession(Connection *deviceConnection, uint32_t sessionId);
+
+ virtual mcResult_t notify(Connection *deviceConnection, uint32_t sessionId);
+
+ virtual void notify(uint32_t sessionId) = 0;
+
+ mcResult_t mapBulk(Connection *deviceConnection, uint32_t sessionId, uint32_t handle, uint64_t pAddrL2,
+ uint32_t offsetPayload, uint32_t lenBulkMem, uint32_t *secureVirtualAdr);
+
+ mcResult_t unmapBulk(Connection *deviceConnection, uint32_t sessionId, uint32_t handle,
+ uint32_t secureVirtualAdr, uint32_t lenBulkMem);
+
+ void start();
+
+ mcResult_t getMobiCoreVersion(mcDrvRspGetMobiCoreVersionPayload_ptr pRspGetMobiCoreVersionPayload);
+
+ bool getMcFault() {
+ return mcFault;
+ }
+
+ void queueUnknownNotification(notification_t notification);
+
+ virtual void dumpMobicoreStatus(void) = 0;
+
+ virtual uint32_t getMobicoreStatus(void) = 0;
+
+ virtual bool schedulerAvailable(void) = 0;
+
+ virtual void schedule(void) = 0;
+
+ virtual void handleIrq(void) = 0;
+
+ //virtual bool freeWsm(CWsm_ptr pWsm) = 0;
+
+ /**
+ * Initialize MobiCore.
+ *
+ * @param devFile the device node to speak to.
+ * @param loadMobiCore
+ * @param mobicoreImage
+ * @param enableScheduler
+ *
+ * @returns true if MobiCore is already initialized.
+ * */
+ virtual bool initDevice(
+ const char *devFile,
+ bool enableScheduler
+ ) = 0;
+
+ virtual void initDeviceStep2(void) = 0;
+
+ virtual bool getMciInstance(uint32_t len, CWsm_ptr *mci, bool *reused) = 0;
+
+ virtual CWsm_ptr registerWsmL2(addr_t buffer, uint32_t len, uint32_t pid) = 0;
+
+ virtual bool unregisterWsmL2(CWsm_ptr pWsm) = 0;
+
+ virtual bool lockWsmL2(uint32_t handle) = 0;
+
+ virtual bool unlockWsmL2(uint32_t handle) = 0;
+
+ virtual uint64_t findWsmL2(uint32_t handle, int fd) = 0;
+
+ virtual bool findContiguousWsm(uint32_t handle, int fd, uint64_t *phys, uint32_t *len) = 0;
+
+ /**
+ * Cleanup all orphaned bulk buffers.
+ */
+ virtual bool cleanupWsmL2(void) = 0;
+
+ virtual bool setupLog(void) = 0;
+
+ /**
+ * Allocates persistent WSM memory for TL (won't be released when TLC exits).
+ */
+ virtual CWsm_ptr allocateContiguousPersistentWsm(uint32_t len) = 0;
+
+ mcResult_t loadToken(Connection *deviceConnection,
+ loadTokenData_ptr pLoadTokenData);
+
+};
+
+#endif /* MOBICOREDEVICE_H_ */
+
+/** @} */
--- /dev/null
+# =============================================================================
+#
+# MC driver server files
+#
+# =============================================================================
+
+# This is not a separate module.
+# Only for inclusion by other modules.
+
+FSD_PATH := Daemon/FSD
+
+# Add new folders with header files here
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(FSD_PATH)/public \
+ $(MOBICORE_PROJECT_PATH)/include/GPD_TEE_Internal_API
+
+# Add new source files here
+LOCAL_SRC_FILES += $(FSD_PATH)/FSD.cpp
\ No newline at end of file
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * FSD server.
+ *
+ * Handles incoming storage requests from TA through STH
+ */
+/* Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "public/FSD.h"
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <cstdlib>
+#include <stdio.h>
+
+//#define LOG_VERBOSE
+#include "log.h"
+
+extern string getTlRegistryPath();
+
+extern pthread_mutex_t syncMutex;
+extern pthread_cond_t syncCondition;
+extern bool Th_sync;
+
+//------------------------------------------------------------------------------
+FSD::FSD(
+ void
+)
+{
+ sessionHandle = {0,0};
+ dci = NULL;
+}
+
+FSD::~FSD(
+ void
+)
+{
+ FSD_Close();
+}
+
+//------------------------------------------------------------------------------
+void FSD::run(
+ void
+)
+{
+ struct stat st;
+ mcResult_t ret;
+ string storage = getTlRegistryPath()+"/TbStorage";
+ const char* tbstpath = storage.c_str();
+
+ /*Create Tbase storage directory*/
+ if (stat(tbstpath, &st) == -1) {
+ LOG_I("%s: Creating <t-base storage Folder %s\n",TAG_LOG,tbstpath);
+ if(mkdir(tbstpath, 0600)==-1)
+ {
+ LOG_E("%s: failed creating storage folder\n",TAG_LOG);
+ }
+ }
+ do{
+ pthread_mutex_lock(&syncMutex);
+ pthread_cond_wait(&syncCondition, &syncMutex);
+ if (Th_sync==true)
+ {
+ LOG_I("%s: starting File Storage Daemon", TAG_LOG);
+
+ }
+ pthread_mutex_unlock(&syncMutex);
+
+ ret = FSD_Open();
+ if (ret != MC_DRV_OK)
+ break;
+ LOG_I("%s: Start listening for request from STH", TAG_LOG);
+ FSD_listenDci();
+ }while(false);
+ LOG_E("Exiting File Storage Daemon 0x%08X", ret);
+}
+
+
+mcResult_t FSD::FSD_Open(void) {
+ mcResult_t mcRet;
+ const mcUuid_t uuid = DRV_STH_UUID;
+
+ memset(&sessionHandle,0, sizeof(mcSessionHandle_t));
+
+ dci = (dciMessage_t*)calloc(DCI_BUFF_SIZE,sizeof(uint8_t));
+ if (dci == NULL) {
+ LOG_E("FSD_Open(): allocation failed");
+ return MC_DRV_ERR_NO_FREE_MEMORY;
+ }
+
+ /* Open <t-base device */
+ mcRet = mcOpenDevice(MC_DEVICE_ID_DEFAULT);
+ if (MC_DRV_OK != mcRet)
+ {
+ LOG_E("FSD_Open(): mcOpenDevice returned: %d\n", mcRet);
+ goto error;
+ }
+
+ /* Open session to the sth driver */
+ sessionHandle.deviceId = MC_DEVICE_ID_DEFAULT;
+ mcRet = mcOpenSession(&sessionHandle,
+ &uuid,
+ (uint8_t *) dci,
+ DCI_BUFF_SIZE);
+ if (MC_DRV_OK != mcRet)
+ {
+ LOG_E("FSD_Open(): mcOpenSession returned: %d\n", mcRet);
+ goto close_device;
+ }
+
+ /* Wait for notification from SWd */
+ mcRet = mcWaitNotification(&sessionHandle, MC_INFINITE_TIMEOUT);
+ if (MC_DRV_OK != mcRet)
+ {
+ goto close_session;
+ }
+
+ /**
+ * The following notification is required for initial sync up
+ * with the driver
+ */
+ dci->command.header.commandId = CMD_ST_SYNC;
+ mcRet = mcNotify(&sessionHandle);
+ if (MC_DRV_OK != mcRet)
+ {
+ LOG_E("FSD_Open(): mcNotify returned: %d\n", mcRet);
+ goto close_session;
+ }
+
+ /* Wait for notification from SWd */
+ mcRet = mcWaitNotification(&sessionHandle, MC_INFINITE_TIMEOUT);
+ if (MC_DRV_OK != mcRet)
+ {
+ goto close_session;
+ }
+ LOG_I("FSD_Open(): received first notification \n");
+ LOG_I("FSD_Open(): send notification back \n");
+ mcRet = mcNotify(&sessionHandle);
+ if (MC_DRV_OK != mcRet)
+ {
+ LOG_E("FSD_Open(): mcNotify returned: %d\n", mcRet);
+ goto close_session;
+ }
+
+ LOG_I("FSD_Open(): returning success");
+ return mcRet;
+
+close_session:
+ mcCloseSession(&sessionHandle);
+
+close_device:
+ mcCloseDevice(MC_DEVICE_ID_DEFAULT);
+
+error:
+ free(dci);
+ dci = NULL;
+
+ return mcRet;
+}
+
+mcResult_t FSD::FSD_Close(void){
+ mcResult_t mcRet;
+
+ /* Clear DCI message buffer */
+ memset(dci, 0, sizeof(dciMessage_t));
+
+ /* Close session to the debug driver trustlet */
+ mcRet = mcCloseSession(&sessionHandle);
+ if (MC_DRV_OK != mcRet)
+ {
+ LOG_E("FSD_Close(): mcCloseSession returned: %d\n", mcRet);
+ }
+
+ free(dci);
+ dci = NULL;
+ memset(&sessionHandle,0,sizeof(mcSessionHandle_t));
+
+ /* Close <t-base device */
+ mcRet = mcCloseDevice(MC_DEVICE_ID_DEFAULT);
+ if (MC_DRV_OK != mcRet)
+ {
+ LOG_E("FSD_Close(): mcCloseDevice returned: %d\n", mcRet);
+ }
+
+ LOG_I("FSD_Close(): returning: 0x%.8x\n", mcRet);
+
+ return mcRet;
+}
+
+
+void FSD::FSD_listenDci(void){
+ mcResult_t mcRet;
+ LOG_I("FSD_listenDci(): DCI listener \n");
+
+
+ for(;;)
+ {
+ LOG_I("FSD_listenDci(): Waiting for notification\n");
+
+ /* Wait for notification from SWd */
+ if (MC_DRV_OK != mcWaitNotification(&sessionHandle, MC_INFINITE_TIMEOUT))
+ {
+ LOG_E("FSD_listenDci(): mcWaitNotification failed\n");
+ break;
+ }
+
+ /* Received exception. */
+ LOG_I("FSD_listenDci(): Received Command (0x%.8x) from STH\n", dci->sth_request.type);
+
+ mcRet = FSD_ExecuteCommand();
+
+ /* notify the STH*/
+ mcRet = mcNotify(&sessionHandle);
+ if (MC_DRV_OK != mcRet)
+ {
+ LOG_E("FSD_executeCommand(): mcNotify returned: %d\n", mcRet);
+ break;
+ }
+ }
+}
+
+void FSD_HexFileName(
+ unsigned char* fn,
+ char* FileName,
+ uint32_t elems
+){
+
+ char tmp[elems * 2 + 1];
+ uint32_t i=0;
+
+ for (i = 0; i < elems; i++) {
+ sprintf(&tmp[i * 2], "%02x", fn[i]);
+ }
+ strcpy(FileName,tmp);
+}
+
+
+void FSD_CreateTaDirName(
+ TEE_UUID* ta_uuid,
+ char* DirName,
+ uint32_t elems
+){
+
+ char tmp[elems * 2 + 1];
+ unsigned char* fn;
+ uint32_t i=0;
+
+ fn = (unsigned char*)ta_uuid;
+ for (i = 0; i < elems; i++) {
+ sprintf(&tmp[i * 2], "%02x", fn[i]);
+ }
+ strcat(DirName,tmp);
+}
+
+//------------------------------------------------------------------------------
+mcResult_t FSD::FSD_ExecuteCommand(void){
+ switch(dci->sth_request.type)
+ {
+ //--------------------------------------
+ case STH_MESSAGE_TYPE_LOOK:
+ LOG_I("FSD_ExecuteCommand(): Looking for file\n");
+ dci->sth_request.status=FSD_LookFile();
+
+ break;
+ //--------------------------------------
+ case STH_MESSAGE_TYPE_READ:
+ LOG_I("FSD_ExecuteCommand(): Reading file\n");
+ dci->sth_request.status=FSD_ReadFile();
+
+ break;
+ //--------------------------------------
+ case STH_MESSAGE_TYPE_WRITE:
+ LOG_I("FSD_ExecuteCommand(): Writing file\n");
+ dci->sth_request.status=FSD_WriteFile();
+
+ break;
+ //--------------------------------------
+ case STH_MESSAGE_TYPE_DELETE:
+ LOG_I("FSD_ExecuteCommand(): Deleting file\n");
+ dci->sth_request.status=FSD_DeleteFile();
+ LOG_I("FSD_ExecuteCommand(): file deleted status is 0x%08x\n",dci->sth_request.status);
+
+ break;
+ //--------------------------------------
+ default:
+ LOG_E("FSD_ExecuteCommand(): Received unknown command %x. Ignoring..\n", dci->sth_request.type);
+ break;
+ }
+ return dci->sth_request.status;
+}
+
+
+/**************************** File operations *******************************/
+
+
+mcResult_t FSD::FSD_LookFile(void){
+ FILE * pFile=NULL;
+ STH_FSD_message_t* sth_request=NULL;
+ uint32_t res=0;
+ string storage = getTlRegistryPath()+"/TbStorage";
+ const char* tbstpath = storage.c_str();
+ char tadirname[TEE_UUID_STRING_SIZE+1];
+ char filename[2*FILENAMESIZE+1];
+ char TAdirpath[strlen(tbstpath)+1+TEE_UUID_STRING_SIZE+1];
+ char Filepath[strlen(tbstpath)+1+TEE_UUID_STRING_SIZE+1+2*FILENAMESIZE+1];
+
+ sth_request= &dci->sth_request;
+ //create TA folder name from TA UUID
+ FSD_CreateTaDirName(&sth_request->uuid,tadirname,sizeof(TEE_UUID));
+ FSD_HexFileName(sth_request->filename,filename,FILENAMESIZE);
+
+ //Create path to TA folder and test if does exist
+ strcpy(TAdirpath,tbstpath);
+ strcat(TAdirpath, "/");
+ strcat(TAdirpath, tadirname);
+
+ strcpy(Filepath, TAdirpath);
+ strcat(Filepath, "/");
+ strcat(Filepath, filename);
+ LOG_I("%s: Storage %s\n", __func__, tbstpath);
+ LOG_I("%s: TA dirname %s\n", __func__, tadirname);
+ LOG_I("%s: filename %s\n", __func__, filename);
+ LOG_I("%s: fullpath %s\n", __func__, Filepath);
+ pFile = fopen(Filepath, "r");
+ if (pFile==NULL)
+ {
+ LOG_E("%s: Error looking for file 0x%.8x\n",__func__,TEE_ERROR_ITEM_NOT_FOUND);
+ return TEE_ERROR_ITEM_NOT_FOUND;
+ }
+
+ res = fread(sth_request->payload,sizeof(char),sth_request->payloadLen,pFile);
+ fclose(pFile);
+
+ if (res != sth_request->payloadLen)
+ {
+ LOG_E("%s: Error reading file res is %d and errno is %s\n",__func__,res,strerror(errno));
+ return TEE_ERROR_ITEM_NOT_FOUND;
+ }
+ return TEE_SUCCESS;
+}
+
+
+mcResult_t FSD::FSD_ReadFile(void){
+ FILE * pFile=NULL;
+ STH_FSD_message_t* sth_request=NULL;
+ uint32_t res=0;
+ string storage = getTlRegistryPath()+"/TbStorage";
+ const char* tbstpath = storage.c_str();
+ char tadirname[TEE_UUID_STRING_SIZE+1];
+ char filename[2*FILENAMESIZE+1];
+ char TAdirpath[strlen(tbstpath)+1+TEE_UUID_STRING_SIZE+1];
+ char Filepath[strlen(tbstpath)+1+TEE_UUID_STRING_SIZE+1+2*FILENAMESIZE+1];
+
+ sth_request= &dci->sth_request;
+ //create TA folder name from TA UUID
+ FSD_CreateTaDirName(&sth_request->uuid,tadirname,sizeof(TEE_UUID));
+ FSD_HexFileName(sth_request->filename,filename,FILENAMESIZE);
+
+ //Create path to TA folder and test if does exist
+ strcpy(TAdirpath,tbstpath);
+ strcat(TAdirpath, "/");
+ strcat(TAdirpath, tadirname);
+
+ strcpy(Filepath, TAdirpath);
+ strcat(Filepath, "/");
+ strcat(Filepath, filename);
+ LOG_I("%s: Storage %s\n", __func__, tbstpath);
+ LOG_I("%s: TA dirname %s\n", __func__, tadirname);
+ LOG_I("%s: filename %s\n", __func__, filename);
+ LOG_I("%s: fullpath %s\n", __func__, Filepath);
+ pFile = fopen(Filepath, "r");
+ if (pFile==NULL)
+ {
+ LOG_E("%s: Error looking for file 0x%.8x\n", __func__,TEE_ERROR_ITEM_NOT_FOUND);
+ return TEE_ERROR_ITEM_NOT_FOUND;
+ }
+ res = fread(sth_request->payload,sizeof(char),sth_request->payloadLen,pFile);
+
+ fclose(pFile);
+
+ if (res != sth_request->payloadLen)
+ {
+ LOG_E("%s: Error reading file res is %d and errno is %s\n",__func__,res,strerror(errno));
+ return TEE_ERROR_ITEM_NOT_FOUND;
+ }
+ return TEE_SUCCESS;
+}
+
+
+mcResult_t FSD::FSD_WriteFile(void){
+ FILE * pFile=NULL;
+ int fd=0;
+ STH_FSD_message_t* sth_request=NULL;
+ uint32_t res=0;
+ int stat=0;
+ string storage = getTlRegistryPath()+"/TbStorage";
+ const char* tbstpath = storage.c_str();
+ char tadirname[TEE_UUID_STRING_SIZE+1];
+ char filename[2*FILENAMESIZE+1];
+ char TAdirpath[strlen(tbstpath)+1+TEE_UUID_STRING_SIZE+1];
+ char Filepath[strlen(tbstpath)+1+TEE_UUID_STRING_SIZE+1+2*FILENAMESIZE+1];
+ char Filepath_new[strlen(tbstpath)+TEE_UUID_STRING_SIZE+2*FILENAMESIZE+strlen(NEW_EXT)+1];
+
+ sth_request= &dci->sth_request;
+
+ FSD_CreateTaDirName(&sth_request->uuid,tadirname,sizeof(TEE_UUID));
+ FSD_HexFileName(sth_request->filename,filename,FILENAMESIZE);
+
+ strcpy(TAdirpath,tbstpath);
+ strcat(TAdirpath, "/");
+ strcat(TAdirpath, tadirname);
+
+ stat = mkdir(TAdirpath, 0700);
+ if((stat==-1) && (errno!=EEXIST))
+ {
+ LOG_I("%s: error when creating TA dir: %s (%s)\n",__func__,TAdirpath,strerror(errno));
+ return TEE_ERROR_STORAGE_NO_SPACE;
+ }
+
+ /* Directory exists. */
+ strcpy(Filepath, TAdirpath);
+ strcat(Filepath, "/");
+ strcat(Filepath, filename);
+ strcpy(Filepath_new,Filepath);
+ strcat(Filepath_new, NEW_EXT);
+ LOG_I("%s: Storage %s\n", __func__, tbstpath);
+ LOG_I("%s: TA dirname %s\n", __func__, tadirname);
+ LOG_I("%s: filename %s\n", __func__, filename);
+ LOG_I("%s: fullpath %s\n", __func__, Filepath);
+ LOG_I("%s: filename.new %s\n", __func__, Filepath_new);
+ if(sth_request->flags == TEE_DATA_FLAG_EXCLUSIVE)
+ {
+ LOG_I("%s: opening file in exclusive mode\n",__func__);
+ fd = open (Filepath, O_WRONLY | O_CREAT | O_EXCL, S_IWUSR);
+ if (fd == -1)
+ {
+ LOG_I("%s: error creating file: %s (%s)\n",__func__,Filepath,strerror(errno));
+ return TEE_ERROR_ACCESS_CONFLICT;
+ }
+ else
+ {
+ close(fd);
+ }
+ }
+ pFile = fopen(Filepath_new, "w");
+ LOG_I("%s: opening file for writing\n",__func__);
+ if(pFile==NULL)
+ {
+ remove(Filepath);
+ return TEE_ERROR_STORAGE_NO_SPACE;
+ }
+ res = fwrite(sth_request->payload,sizeof(char),sth_request->payloadLen,pFile);
+
+
+ if (res != sth_request->payloadLen)
+ {
+ LOG_E("%s: Error writing file res is %d and errno is %s\n",__func__,res,strerror(errno));
+ fclose(pFile);
+ remove(Filepath);
+ remove(Filepath_new);
+ return TEE_ERROR_ITEM_NOT_FOUND;
+ }
+ else
+ {
+ res = fclose(pFile);
+ if (res < 0)
+ {
+ LOG_E("%s: Error closing file res is %d and errno is %s\n",__func__,res,strerror(errno));
+ remove(Filepath);
+ remove(Filepath_new);
+ return TEE_ERROR_STORAGE_NO_SPACE;
+ }
+
+ res = rename(Filepath_new,Filepath);
+ if (res < 0)
+ {
+ LOG_E("%s: Error renaming %s: %s\n",__func__,Filepath_new,strerror(errno));
+ remove(Filepath);
+ remove(Filepath_new);
+ return TEE_ERROR_STORAGE_NO_SPACE;
+ }
+ }
+ return TEE_SUCCESS;
+}
+
+
+mcResult_t FSD::FSD_DeleteFile(void){
+ FILE * pFile=NULL;
+ uint32_t res=0;
+ STH_FSD_message_t* sth_request=NULL;
+ string storage = getTlRegistryPath()+"/TbStorage";
+ const char* tbstpath = storage.c_str();
+ char tadirname[TEE_UUID_STRING_SIZE+1];
+ char filename[2*FILENAMESIZE+1];
+ char TAdirpath[strlen(tbstpath)+1+TEE_UUID_STRING_SIZE+1];
+ char Filepath[strlen(tbstpath)+1+TEE_UUID_STRING_SIZE+1+2*FILENAMESIZE+1];
+
+ sth_request= &dci->sth_request;
+
+ //create TA folder name from TA UUID
+ FSD_CreateTaDirName(&sth_request->uuid,tadirname,sizeof(TEE_UUID));
+ FSD_HexFileName(sth_request->filename,filename,FILENAMESIZE);
+
+ //Create path to TA folder and test if does exist
+ strcpy(TAdirpath,tbstpath);
+ strcat(TAdirpath, "/");
+ strcat(TAdirpath, tadirname);
+
+ /* Directory exists. */
+ strcpy(Filepath, TAdirpath);
+ strcat(Filepath, "/");
+ strcat(Filepath, filename);
+ LOG_I("%s: Storage %s\n", __func__, tbstpath);
+ LOG_I("%s: TA dirname %s\n", __func__, tadirname);
+ LOG_I("%s: filename %s\n", __func__, filename);
+ LOG_I("%s: fullpath %s\n", __func__, Filepath);
+
+ pFile = fopen(Filepath, "r");
+ if (pFile==NULL)
+ {
+ LOG_I("%s: file not found: %s (%s)\n",__func__, Filepath, strerror(errno));
+ res = TEE_SUCCESS;
+ }
+ else
+ {
+ fclose(pFile);
+ if(remove(Filepath)==-1)
+ {
+ res = TEE_ERROR_STORAGE_NO_SPACE;
+ }
+ }
+
+ LOG_I("%s: before rmdir res %d errno %d (%s)\n",__func__,res, errno,strerror(errno));
+
+ res = rmdir(TAdirpath);
+
+ LOG_I("%s: after rmdir res %d errno %d (%s)\n",__func__,res, errno,strerror(errno));
+
+ if ((res < 0) && (errno != ENOTEMPTY) && (errno != EEXIST) && (errno != ENOENT))
+ {
+ res = TEE_ERROR_STORAGE_NO_SPACE;
+ LOG_I("%s: rmdir failed: %s (%s)\n",__func__, TAdirpath, strerror(errno));
+ }
+ else
+ {
+ res = TEE_SUCCESS;
+ }
+
+ return res;
+}
+
+
+//------------------------------------------------------------------------------
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * FSD server.
+ *
+ * Handles incoming storage requests from TA through STH
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef FSD_H_
+#define FSD_H_
+
+#include <sys/types.h>
+#include <string>
+#include <cstdio>
+#include "CThread.h"
+#include "MobiCoreDriverApi.h"
+#include "drSecureStorage_Api.h"
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <android/log.h>
+
+
+#define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
+#define DCI_BUFF_SIZE 1000*1024
+
+#define TEE_UUID_STRING_SIZE 32
+#define FILENAMESIZE 20
+#define NEW_EXT ".new"
+
+#define TAG_LOG "FSD"
+
+class FSD: public CThread
+{
+
+public:
+ /**
+ * FSD contructor.
+ *
+ * @param tbstoragepath Absolute path to the secure storage
+ */
+ FSD(
+ void
+ );
+
+ /**
+ * FSD destructor.
+ * Close the current session and resources will be freed.
+ */
+ virtual ~FSD(
+ void
+ );
+
+ /**
+ * Start server and listen for incoming request from STH.
+ */
+ virtual void run(void);
+
+ /*
+ * FSD_Open
+ *
+ * Open a session with the STH
+ *
+ */
+ virtual mcResult_t FSD_Open(void);
+
+
+ /*
+ * FSD_Close
+ *
+ * Close a session opened with the STH
+ *
+ */
+ virtual mcResult_t FSD_Close(void);
+
+
+ /*
+ * FSD_listenDci
+ *
+ * DCI listener function
+ *
+ */
+ virtual void FSD_listenDci(void);
+
+
+
+private:
+ mcSessionHandle_t sessionHandle; /**< current session */
+ dciMessage_t* dci; /**< dci buffer */
+
+
+ /** Private methods*/
+
+ /*
+ * FSD_ExecuteCommand
+ *
+ * Execute command received from the STH
+ *
+ */
+ mcResult_t FSD_ExecuteCommand(void);
+
+ /**************************** File operations *******************************/
+
+ /*
+ * FSD_LookFile
+ *
+ * look for a file
+ */
+ mcResult_t FSD_LookFile(void);
+
+
+ /*
+ * FSD_ReadFile
+ *
+ * Read a file
+ */
+ mcResult_t FSD_ReadFile(void);
+
+
+ /*
+ * FSD_WriteFile
+ *
+ * Write a file
+ */
+ mcResult_t FSD_WriteFile(void);
+
+
+ /*
+ * FSD_DeleteFile
+ *
+ * Delete a file
+ */
+ mcResult_t FSD_DeleteFile(void);
+};
+
+#endif /* FSD_H_ */
+
+/** @} */
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+/**
+ * @file dci.h
+ * @brief Contains DCI (Driver Control
+ * Interface) definitions and data structures
+ *
+ */
+
+#ifndef __DCI_H__
+#define __DCI_H__
+
+
+typedef uint32_t dciCommandId_t;
+typedef uint32_t dciResponseId_t;
+typedef uint32_t dciReturnCode_t;
+
+/**< Responses have bit 31 set */
+#define RSP_ID_MASK (1U << 31)
+#define RSP_ID(cmdId) (((uint32_t)(cmdId)) | RSP_ID_MASK)
+#define IS_CMD(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == 0)
+#define IS_RSP(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == RSP_ID_MASK)
+
+/**
+ * Return codes of driver commands.
+ */
+#define RET_OK 0
+#define RET_ERR_UNKNOWN_CMD 1
+#define RET_ERR_NOT_SUPPORTED 2
+#define RET_ERR_INTERNAL_ERROR 3
+/* ... add more error codes when needed */
+
+/**
+ * DCI command header.
+ */
+typedef struct{
+ dciCommandId_t commandId; /**< Command ID */
+} dciCommandHeader_t;
+
+/**
+ * DCI response header.
+ */
+typedef struct{
+ dciResponseId_t responseId; /**< Response ID (must be command ID | RSP_ID_MASK )*/
+ dciReturnCode_t returnCode; /**< Return code of command */
+} dciResponseHeader_t;
+
+#endif // __DCI_H__
--- /dev/null
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved
+ *
+ * The present software is the confidential and proprietary information of
+ * TRUSTONIC LIMITED. You shall not disclose the present software and shall
+ * use it only in accordance with the terms of the license agreement you
+ * entered into with TRUSTONIC LIMITED. This software may be subject to
+ * export or import laws in certain countries.
+ */
+
+/**
+ * @file drSecureStorage_Api.h
+ * @brief Contains DCI command definitions and data structures
+ *
+ */
+
+#ifndef __DRTEMPLATEAPI_H__
+#define __DRTEMPLATEAPI_H__
+
+#include "dci.h"
+#include "tee_internal_api.h"
+
+
+#define RW_DATA_SIZE 4096
+
+/**
+ * Command ID's for communication
+ * FSD <--> STH
+ */
+
+#define STH_MESSAGE_TYPE_LOOK 0
+#define STH_MESSAGE_TYPE_READ 1
+#define STH_MESSAGE_TYPE_WRITE 2
+#define STH_MESSAGE_TYPE_DELETE 3
+
+#define CMD_ST_SYNC 5
+#define NOTIFY_DCIH 6
+#define NOTIFY_IPCH 7
+/*... add more command ids when needed */
+
+#define STH_PUBLIC_FILE_NAME_SIZE 20
+
+typedef struct {
+ uint32_t status;
+ uint8_t type;
+ uint8_t reserved0;
+ uint16_t flags;
+ uint32_t payloadLen;
+ TEE_UUID uuid;
+ unsigned char filename[STH_PUBLIC_FILE_NAME_SIZE];
+ unsigned char payload[];
+} STH_FSD_message_t;
+
+typedef struct
+{
+ char header[5];
+ unsigned char version;
+ uint16_t cryptoLen;
+ uint32_t dataLen;
+}FSD_plaintext;
+
+/**
+ * command message.
+ *
+ * @param len Lenght of the data to process.
+ * @param data Data to be processed
+ */
+typedef struct {
+ dciCommandHeader_t header; /**< Command header */
+ uint32_t len; /**< Length of data to process */
+} cmd_t;
+
+
+/**
+ * Response structure
+ */
+typedef struct {
+ dciResponseHeader_t header; /**< Response header */
+ uint32_t len;
+} rsp_t;
+
+/**
+ * DCI message data.
+ */
+typedef struct {
+ union {
+ cmd_t command;
+ rsp_t response;
+ };
+
+ STH_FSD_message_t sth_request;
+} dciMessage_t;
+
+/**
+ * Driver UUID. Update accordingly after reserving UUID
+ */
+#define DRV_STH_UUID { { 0x07, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
+
+
+#endif // __DRTEMPLATEAPI_H__
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_CONHDLR
+ * @{
+ * @file
+ *
+ * Entry of the MobiCore Driver.
+ */
+
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <cstdlib>
+#include <signal.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+#include "mcVersion.h"
+#include "mcVersionHelper.h"
+#include "mc_linux.h"
+#include "log.h"
+#include "Mci/mci.h"
+
+#include "MobiCoreDriverApi.h"
+#include "MobiCoreDriverCmd.h"
+#include "MobiCoreDriverDaemon.h"
+#include "PrivateRegistry.h"
+#include "MobiCoreDevice.h"
+#include "NetlinkServer.h"
+#include "FSD.h"
+
+#define DRIVER_TCI_LEN 4096
+
+MC_CHECK_VERSION(MCI, 0, 2);
+MC_CHECK_VERSION(SO, 2, 0);
+MC_CHECK_VERSION(MCLF, 2, 0);
+MC_CHECK_VERSION(CONTAINER, 2, 0);
+
+static void checkMobiCoreVersion(MobiCoreDevice *mobiCoreDevice);
+
+#define LOG_I_RELEASE(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+
+pthread_mutex_t syncMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t syncCondition = PTHREAD_COND_INITIALIZER;
+bool Th_sync=false;
+
+//------------------------------------------------------------------------------
+MobiCoreDriverDaemon::MobiCoreDriverDaemon(
+ bool enableScheduler,
+ bool loadDriver,
+ std::vector<std::string> drivers)
+{
+ mobiCoreDevice = NULL;
+
+ this->enableScheduler = enableScheduler;
+ this->loadDriver = loadDriver;
+ this->drivers = drivers;
+
+ for (int i = 0; i < MAX_SERVERS; i++) {
+ servers[i] = NULL;
+ }
+}
+
+//------------------------------------------------------------------------------
+MobiCoreDriverDaemon::~MobiCoreDriverDaemon(
+ void
+)
+{
+ // Unload any device drivers might have been loaded
+ driverResourcesList_t::iterator it;
+ for (it = driverResources.begin(); it != driverResources.end(); it++) {
+ MobicoreDriverResources *res = *it;
+ mobiCoreDevice->closeSession(res->conn, res->sessionId);
+ mobiCoreDevice->unregisterWsmL2(res->pTciWsm);
+ }
+ delete mobiCoreDevice;
+ for (int i = 0; i < MAX_SERVERS; i++) {
+ delete servers[i];
+ servers[i] = NULL;
+ }
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::run(
+ void
+)
+{
+ const char *devNode = "/dev/" MC_ADMIN_DEVNODE;
+
+ LOG_I_RELEASE("Daemon starting up...");
+ LOG_I_RELEASE("Socket interface version is %u.%u", DAEMON_VERSION_MAJOR, DAEMON_VERSION_MINOR);
+
+#ifdef MOBICORE_COMPONENT_BUILD_TAG
+ LOG_I_RELEASE("%s", MOBICORE_COMPONENT_BUILD_TAG);
+#else
+#warning "MOBICORE_COMPONENT_BUILD_TAG is not defined!"
+#endif
+
+ LOG_I_RELEASE("Build timestamp is %s %s", __DATE__, __TIME__);
+
+ int i;
+
+ mobiCoreDevice = getDeviceInstance();
+
+ LOG_I("Initializing Device, Daemon sheduler is %s",
+ enableScheduler ? "enabled" : "disabled");
+
+ // initialize device (setupo MCI)
+ if (!mobiCoreDevice->initDevice(
+ devNode,
+ enableScheduler)) {
+ LOG_E("Could not initialize <t-base (because %s could not be openend)!", devNode);
+ return;
+ }
+
+ // start device (scheduler)
+ mobiCoreDevice->start();
+
+ // Load device driver if requested
+ if (loadDriver) {
+ for (unsigned int i = 0; i < drivers.size(); i++)
+ loadDeviceDriver(drivers[i]);
+ }
+
+ /* Look for tokens in the registry and pass them to <t-base for endorsement
+ * purposes.
+ */
+ LOG_I("Looking for suitable tokens");
+
+ mcSoAuthTokenCont_t authtoken;
+ mcSoRootCont_t rootcont;
+ uint32_t sosize;
+ uint8_t *p = NULL;
+
+ mcResult_t ret = mcRegistryReadAuthToken(&authtoken);
+ if (ret != MC_DRV_OK) {
+ LOG_I("Failed to read AuthToken (ret=%u). Trying Root Container", ret);
+
+ sosize = sizeof(rootcont);
+ ret = mcRegistryReadRoot(&rootcont, &sosize);
+ if (ret != MC_DRV_OK) {
+ LOG_I("Failed to read Root Cont, (ret=%u)", ret);
+ LOG_W("Device endorsements not supported!");
+ sosize = 0;
+ }
+ else {
+ LOG_I("Found Root Cont.");
+ p = (uint8_t *) &rootcont;
+ }
+ } else {
+ LOG_I("Found AuthToken.");
+ p = (uint8_t *) &authtoken;
+ sosize = sizeof(authtoken);
+ }
+
+ if (sosize) {
+ LOG_I("Found token of size: %u", sosize);
+ if (!loadToken(p, sosize)) {
+ LOG_E("Failed to pass token to <t-base. "
+ "Device endorsements disabled");
+ }
+ }
+
+ LOG_I("Creating socket servers");
+ // Start listening for incoming TLC connections
+ servers[0] = new NetlinkServer(this);
+ servers[1] = new Server(this, SOCK_PATH);
+ LOG_I("Successfully created servers");
+
+ // Start all the servers
+ for (i = 0; i < MAX_SERVERS; i++) {
+ servers[i]->start(i ? "McDaemon.Server" : "NetlinkServer");
+ }
+
+ // Create the <t-base File Storage Daemon
+ FSD *FileStorageDaemon = new FSD();
+ // Start File Storage Daemon
+ FileStorageDaemon->start("McDaemon.FSD");
+
+ // then wait for them to exit
+ for (i = 0; i < MAX_SERVERS; i++) {
+ servers[i]->join();
+ }
+ //Wait for File Storage Daemon to exit
+ FileStorageDaemon->join();
+ delete FileStorageDaemon;
+}
+
+//------------------------------------------------------------------------------
+bool MobiCoreDriverDaemon::checkPermission(Connection *connection __unused)
+{
+#ifdef REGISTRY_CHECK_PERMISSIONS
+ struct ucred cred;
+ if (!connection)
+ return true;
+
+ if (connection->getPeerCredentials(cred)) {
+ gid_t gid = getegid();
+ uid_t uid = geteuid();
+ LOG_I("Peer connection has pid = %u and uid = %u gid = %u", cred.pid, cred.uid, cred.gid);
+ LOG_I("Daemon has uid = %u gid = %u", cred.uid, cred.gid);
+ // If the daemon and the peer have the same uid or gid then we're good
+ if (gid == cred.gid || uid == cred.uid) {
+ return true;
+ }
+ return false;
+
+ }
+ return false;
+#else
+ return true;
+#endif
+}
+
+//------------------------------------------------------------------------------
+MobiCoreDevice *MobiCoreDriverDaemon::getDevice(
+ uint32_t deviceId
+)
+{
+ // Always return the trustZoneDevice as it is currently the only one supported
+ if (MC_DEVICE_ID_DEFAULT != deviceId)
+ return NULL;
+ return mobiCoreDevice;
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::dropConnection(
+ Connection *connection
+)
+{
+ // Check if a Device has already been registered with the connection
+ MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
+
+ if (device != NULL) {
+ // A connection has been found and has to be closed
+ LOG_I("dropConnection(): closing still open device.");
+
+ // Make sure nobody else writes the MCP, e.g. netlink/socket server, cleanup of TAs
+ device->mutex_mcp.lock();
+ device->close(connection);
+ device->mutex_mcp.unlock();
+ }
+}
+
+
+//------------------------------------------------------------------------------
+size_t MobiCoreDriverDaemon::writeResult(
+ Connection *connection,
+ mcResult_t code
+)
+{
+ if (0 != code) {
+ LOG_V(" sending error code %d", code);
+ }
+ return connection->writeData(&code, sizeof(mcResult_t));
+}
+
+//------------------------------------------------------------------------------
+bool MobiCoreDriverDaemon::loadDeviceDriver(
+ std::string driverPath
+)
+{
+ bool ret = false;
+ CWsm_ptr pWsm = NULL, pTciWsm = NULL;
+ regObject_t *regObj = NULL;
+ Connection *conn = NULL;
+ mcDrvRspOpenSession_t rspOpenSession;
+
+ do {
+ //mobiCoreDevice
+ LOG_I("%s: loading %s", __FUNCTION__, driverPath.c_str());
+
+ regObj = mcRegistryGetDriverBlob(driverPath.c_str());
+ if (regObj == NULL) {
+ break;;
+ }
+
+ LOG_I("registering L2 in kmod, p=%p, len=%i",
+ regObj->value, regObj->len);
+
+ pWsm = mobiCoreDevice->registerWsmL2(
+ (addr_t)(regObj->value), regObj->len, 0);
+ if (pWsm == NULL) {
+ LOG_E("allocating WSM for Trustlet failed");
+ break;
+ }
+ // Initialize information data of open session command
+ loadDataOpenSession_t loadDataOpenSession;
+ loadDataOpenSession.baseAddr = pWsm->physAddr;
+ loadDataOpenSession.offs = ((uintptr_t) regObj->value) & 0xFFF;
+ loadDataOpenSession.len = regObj->len;
+ loadDataOpenSession.tlHeader = (mclfHeader_ptr) (regObj->value + regObj->tlStartOffset);
+
+ pTciWsm = mobiCoreDevice->allocateContiguousPersistentWsm(DRIVER_TCI_LEN);
+ if (pTciWsm == NULL) {
+ LOG_E("allocating WSM TCI for Trustlet failed");
+ break;
+ }
+
+ conn = new Connection();
+ uint32_t mcRet = mobiCoreDevice->openSession(
+ conn,
+ &loadDataOpenSession,
+ pTciWsm->handle,
+ pTciWsm->len,
+ 0,
+ &(rspOpenSession.payload));
+
+ // Unregister physical memory from kernel module.
+ // This will also destroy the WSM object.
+ mobiCoreDevice->unregisterWsmL2(pWsm);
+ pWsm = NULL;
+
+ // Free memory occupied by Trustlet data
+ free(regObj);
+ regObj = NULL;
+
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_E("open session error %d", mcRet);
+ break;
+ }
+
+ ret = true;
+ } while (false);
+ // Free all allocated resources
+ if (ret == false) {
+ LOG_I("%s: Freeing previously allocated resources!", __FUNCTION__);
+ if (pWsm != NULL) {
+ if (!mobiCoreDevice->unregisterWsmL2(pWsm)) {
+ // At least make sure we don't leak the WSM object
+ delete pWsm;
+ }
+ }
+ // No matter if we free NULL objects
+ free(regObj);
+
+ if (conn != NULL) {
+ delete conn;
+ }
+ } else if (conn != NULL) {
+ driverResources.push_back(new MobicoreDriverResources(
+ conn, pTciWsm, rspOpenSession.payload.sessionId));
+ }
+
+ return ret;
+}
+
+#define RECV_PAYLOAD_FROM_CLIENT(CONNECTION, CMD_BUFFER) \
+{ \
+ void *payload = (void*)((uintptr_t)CMD_BUFFER + sizeof(mcDrvCommandHeader_t)); \
+ uint32_t payload_len = sizeof(*CMD_BUFFER) - sizeof(mcDrvCommandHeader_t); \
+ int32_t rlen = CONNECTION->readData(payload, payload_len); \
+ if (rlen < 0) { \
+ LOG_E("reading from Client failed"); \
+ /* it is questionable, if writing to broken socket has any effect here. */ \
+ writeResult(CONNECTION, MC_DRV_ERR_DAEMON_SOCKET); \
+ return; \
+ } \
+ if (rlen != (int32_t)payload_len) {\
+ LOG_E("wrong buffer length %i received from Client", rlen); \
+ writeResult(CONNECTION, MC_DRV_ERR_DAEMON_SOCKET); \
+ return; \
+ } \
+}
+
+#define CHECK_DEVICE(DEVICE, CONNECTION) \
+ if (DEVICE == NULL) \
+ { \
+ LOG_V("%s: no device associated with connection",__FUNCTION__); \
+ writeResult(CONNECTION, MC_DRV_ERR_DAEMON_DEVICE_NOT_OPEN); \
+ return; \
+ }
+
+//------------------------------------------------------------------------------
+inline bool getData(Connection *con, void *buf, uint32_t len)
+{
+ uint32_t rlen = con->readData(buf, len);
+ if (rlen < len || (int32_t)rlen < 0) {
+ LOG_E("reading from Client failed");
+ return false;
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processOpenDevice(Connection *connection)
+{
+ MC_DRV_CMD_OPEN_DEVICE_struct cmdOpenDevice;
+ RECV_PAYLOAD_FROM_CLIENT(connection, &cmdOpenDevice);
+
+ // Check if device has been registered to the connection
+ MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
+ if (NULL != device) {
+ LOG_E("processOpenDevice(): device already set");
+ writeResult(connection, MC_DRV_ERR_DEVICE_ALREADY_OPEN);
+ return;
+ }
+
+ LOG_I(" Opening deviceId %d ", cmdOpenDevice.deviceId);
+
+ // Get device for device ID
+ device = getDevice(cmdOpenDevice.deviceId);
+
+ // Check if a device for the given name has been found
+ if (device == NULL) {
+ LOG_E("invalid deviceId");
+ writeResult(connection, MC_DRV_ERR_UNKNOWN_DEVICE);
+ return;
+ }
+
+ // Register device object with connection
+ device->open(connection);
+
+ // Return result code to client lib (no payload)
+ writeResult(connection, MC_DRV_OK);
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processCloseDevice(
+ Connection *connection
+)
+{
+ // there is no payload to read
+
+ // Device required
+ MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
+ CHECK_DEVICE(device, connection);
+
+ // No command data will be read
+ // Unregister device object with connection
+ device->close(connection);
+
+ // there is no payload
+ writeResult(connection, MC_DRV_OK);
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processOpenSession(Connection *connection, bool isGpUuid)
+{
+ MC_DRV_CMD_OPEN_SESSION_struct cmdOpenSession;
+ RECV_PAYLOAD_FROM_CLIENT(connection, &cmdOpenSession);
+
+ // Device required
+ MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
+ CHECK_DEVICE(device, connection);
+
+ // Get service blob from registry
+ regObject_t *regObj = mcRegistryGetServiceBlob(&cmdOpenSession.uuid, isGpUuid);
+ if (NULL == regObj) {
+ writeResult(connection, MC_DRV_ERR_TRUSTLET_NOT_FOUND);
+ return;
+ }
+ if (regObj->len == 0) {
+ free(regObj);
+ writeResult(connection, MC_DRV_ERR_TRUSTLET_NOT_FOUND);
+ return;
+ }
+ LOG_I(" Sharing Service loaded at %p with Secure World", (addr_t)(regObj->value));
+
+ CWsm_ptr pWsm = device->registerWsmL2((addr_t)(regObj->value), regObj->len, 0);
+ if (pWsm == NULL) {
+ // Free memory occupied by Trustlet data
+ free(regObj);
+ LOG_E("allocating WSM for Trustlet failed");
+ writeResult(connection, MC_DRV_ERR_DAEMON_KMOD_ERROR);
+ return;
+ }
+ // Initialize information data of open session command
+ loadDataOpenSession_t loadDataOpenSession;
+ loadDataOpenSession.baseAddr = pWsm->physAddr;
+ loadDataOpenSession.offs = ((uintptr_t) regObj->value) & 0xFFF;
+ loadDataOpenSession.len = regObj->len;
+ loadDataOpenSession.tlHeader = (mclfHeader_ptr) (regObj->value + regObj->tlStartOffset);
+
+ mcDrvRspOpenSession_t rspOpenSession;
+ mcResult_t ret = device->openSession(
+ connection,
+ &loadDataOpenSession,
+ cmdOpenSession.handle,
+ cmdOpenSession.len,
+ cmdOpenSession.tci,
+ &rspOpenSession.payload);
+
+ // Unregister physical memory from kernel module.
+ LOG_I(" Service buffer was copied to Secure world and processed. Stop sharing of buffer.");
+
+ // This will also destroy the WSM object.
+ if (!device->unregisterWsmL2(pWsm)) {
+ // TODO-2012-07-02-haenellu: Can this ever happen? And if so, we should assert(), also TL might still be running.
+ free(regObj);
+ writeResult(connection, MC_DRV_ERR_DAEMON_KMOD_ERROR);
+ return;
+ }
+
+ // Free memory occupied by Trustlet data
+ free(regObj);
+
+ if (ret != MC_DRV_OK) {
+ LOG_E("Service could not be loaded.");
+ writeResult(connection, ret);
+ } else {
+ rspOpenSession.header.responseId = ret;
+ connection->writeData(
+ &rspOpenSession,
+ sizeof(rspOpenSession));
+ }
+}
+
+//------------------------------------------------------------------------------
+mcResult_t MobiCoreDriverDaemon::processLoadCheck(mcSpid_t spid, void *blob, uint32_t size)
+{
+
+ // Device required
+ MobiCoreDevice *device = getDevice(MC_DEVICE_ID_DEFAULT);
+
+ if (device == NULL) {
+ LOG_E(" No device found");
+ return MC_DRV_ERR_DAEMON_DEVICE_NOT_OPEN;
+ }
+
+ // Get service blob from registry
+ regObject_t *regObj = mcRegistryMemGetServiceBlob(spid, blob, size);
+ if (NULL == regObj) {
+ LOG_E(" mcRegistryMemGetServiceBlob failed");
+ return MC_DRV_ERR_TRUSTLET_NOT_FOUND;
+ }
+ if (regObj->len == 0) {
+ free(regObj);
+ LOG_E("mcRegistryMemGetServiceBlob returned registry object with length equal to zero");
+ return MC_DRV_ERR_TRUSTLET_NOT_FOUND;
+ }
+ LOG_I(" Sharing Service loaded at %p with Secure World", (addr_t)(regObj->value));
+
+ CWsm_ptr pWsm = device->registerWsmL2((addr_t)(regObj->value), regObj->len, 0);
+ if (pWsm == NULL) {
+ // Free memory occupied by Trustlet data
+ free(regObj);
+ LOG_E("allocating WSM for Trustlet failed");
+ return MC_DRV_ERR_DAEMON_KMOD_ERROR;
+ }
+ // Initialize information data of open session command
+ loadDataOpenSession_t loadDataOpenSession;
+ loadDataOpenSession.baseAddr = pWsm->physAddr;
+ loadDataOpenSession.offs = ((uintptr_t) regObj->value) & 0xFFF;
+ loadDataOpenSession.len = regObj->len;
+ loadDataOpenSession.tlHeader = (mclfHeader_ptr) (regObj->value + regObj->tlStartOffset);
+
+ mcDrvRspOpenSession_t rspOpenSession;
+ mcResult_t ret = device->checkLoad(
+ &loadDataOpenSession,
+ &rspOpenSession.payload);
+
+ // Unregister physical memory from kernel module.
+ LOG_I(" Service buffer was copied to Secure world and processed. Stop sharing of buffer.");
+
+ // This will also destroy the WSM object.
+ if (!device->unregisterWsmL2(pWsm)) {
+ // Free memory occupied by Trustlet data
+ free(regObj);
+ LOG_E("deallocating WSM for Trustlet failed");
+ return MC_DRV_ERR_DAEMON_KMOD_ERROR;
+ }
+
+ // Free memory occupied by Trustlet data
+ free(regObj);
+
+ if (ret != MC_DRV_OK) {
+ LOG_E("TA could not be loaded.");
+ return ret;
+ } else {
+ return MC_DRV_OK;
+ }
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processOpenTrustlet(Connection *connection)
+{
+ MC_DRV_CMD_OPEN_TRUSTLET_struct cmdOpenTrustlet;
+ RECV_PAYLOAD_FROM_CLIENT(connection, &cmdOpenTrustlet);
+
+ // Device required
+ MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
+ CHECK_DEVICE(device, connection);
+
+ uint32_t total_len, rlen, len = cmdOpenTrustlet.trustlet_len;
+ uint8_t *payload = (uint8_t *)malloc(len);
+ uint8_t *p = payload;
+ if (payload == NULL) {
+ LOG_E("failed to allocate payload buffer");
+ writeResult(connection, MC_DRV_ERR_DAEMON_SOCKET);
+ return;
+ }
+ total_len = 0;
+ while (total_len < len) {
+ rlen = connection->readData(p, len - total_len);
+ if ((int32_t)rlen < 0) {
+ LOG_E("reading from Client failed");
+ /* it is questionable, if writing to broken socket has any effect here. */
+ writeResult(connection, MC_DRV_ERR_DAEMON_SOCKET);
+ free(payload);
+ return;
+ }
+ total_len += rlen;
+ p += rlen;
+ }
+
+ // Get service blob from registry
+ regObject_t *regObj = mcRegistryMemGetServiceBlob(cmdOpenTrustlet.spid, (uint8_t *)payload, len);
+
+ // Free the payload object no matter what
+ free(payload);
+ if (regObj == NULL) {
+ writeResult(connection, MC_DRV_ERR_TRUSTLET_NOT_FOUND);
+ return;
+ }
+
+ if (regObj->len == 0) {
+ free(regObj);
+ writeResult(connection, MC_DRV_ERR_TRUSTLET_NOT_FOUND);
+ return;
+ }
+ LOG_I(" Sharing Service loaded at %p with Secure World", (addr_t)(regObj->value));
+
+ CWsm_ptr pWsm = device->registerWsmL2((addr_t)(regObj->value), regObj->len, 0);
+ if (pWsm == NULL) {
+ free(regObj);
+ LOG_E("allocating WSM for Trustlet failed");
+ writeResult(connection, MC_DRV_ERR_DAEMON_KMOD_ERROR);
+ return;
+ }
+ // Initialize information data of open session command
+ loadDataOpenSession_t loadDataOpenSession;
+ loadDataOpenSession.baseAddr = pWsm->physAddr;
+ loadDataOpenSession.offs = ((uintptr_t) regObj->value) & 0xFFF;
+ loadDataOpenSession.len = regObj->len;
+ loadDataOpenSession.tlHeader = (mclfHeader_ptr) (regObj->value + regObj->tlStartOffset);
+
+ mcDrvRspOpenSession_t rspOpenSession;
+ mcResult_t ret = device->openSession(
+ connection,
+ &loadDataOpenSession,
+ cmdOpenTrustlet.handle,
+ cmdOpenTrustlet.len,
+ cmdOpenTrustlet.tci,
+ &rspOpenSession.payload);
+
+ // Unregister physical memory from kernel module.
+ LOG_I(" Service buffer was copied to Secure world and processed. Stop sharing of buffer.");
+
+ // This will also destroy the WSM object.
+ if (!device->unregisterWsmL2(pWsm)) {
+ free(regObj);
+ // TODO-2012-07-02-haenellu: Can this ever happen? And if so, we should assert(), also TL might still be running.
+ writeResult(connection, MC_DRV_ERR_DAEMON_KMOD_ERROR);
+ return;
+ }
+
+ // Free memory occupied by Trustlet data
+ free(regObj);
+
+ if (ret != MC_DRV_OK) {
+ LOG_E("Service could not be loaded.");
+ writeResult(connection, ret);
+ } else {
+ rspOpenSession.header.responseId = ret;
+ connection->writeData(
+ &rspOpenSession,
+ sizeof(rspOpenSession));
+ }
+}
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processCloseSession(Connection *connection)
+{
+ MC_DRV_CMD_CLOSE_SESSION_struct cmdCloseSession;
+ RECV_PAYLOAD_FROM_CLIENT(connection, &cmdCloseSession)
+
+ // Device required
+ MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
+ CHECK_DEVICE(device, connection);
+
+ mcResult_t ret = device->closeSession(connection, cmdCloseSession.sessionId);
+
+ // there is no payload
+ writeResult(connection, ret);
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processNqConnect(Connection *connection)
+{
+ // Set up the channel for sending SWd notifications to the client
+ // MC_DRV_CMD_NQ_CONNECT is only allowed on new connections not
+ // associated with a device. If a device is registered to the
+ // connection NQ_CONNECT is not allowed.
+
+ // Read entire command data
+ MC_DRV_CMD_NQ_CONNECT_struct cmd;
+ RECV_PAYLOAD_FROM_CLIENT(connection, &cmd);
+
+ // device must be empty since this is a new connection
+ MobiCoreDevice *device = (MobiCoreDevice *)(connection->connectionData);
+ if (device != NULL) {
+ LOG_E("device already set\n");
+ writeResult(connection, MC_DRV_ERR_NQ_FAILED);
+ return;
+ }
+
+ // Remove the connection from the list of known client connections
+ for (int i = 0; i < MAX_SERVERS; i++) {
+ servers[i]->detachConnection(connection);
+ }
+
+ device = getDevice(cmd.deviceId);
+ // Check if a device for the given name has been found
+ if (NULL == device) {
+ LOG_E("invalid deviceId");
+ writeResult(connection, MC_DRV_ERR_UNKNOWN_DEVICE);
+ return;
+ }
+
+ TrustletSession *ts = device->registerTrustletConnection(
+ connection,
+ &cmd);
+ if (!ts) {
+ LOG_E("registerTrustletConnection() failed!");
+ writeResult(connection, MC_DRV_ERR_UNKNOWN);
+ return;
+ }
+
+ writeResult(connection, MC_DRV_OK);
+ ts->processQueuedNotifications();
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processNotify(Connection *connection)
+{
+ // Read entire command data
+ MC_DRV_CMD_NOTIFY_struct cmd;
+ //RECV_PAYLOAD_FROM_CLIENT(connection, &cmd);
+ void *payload = (void *)((uintptr_t)&cmd + sizeof(mcDrvCommandHeader_t));
+ uint32_t payload_len = sizeof(cmd) - sizeof(mcDrvCommandHeader_t);
+ uint32_t rlen = connection->readData(payload, payload_len);
+ if ((int) rlen < 0) {
+ LOG_E("reading from Client failed");
+ /* it is questionable, if writing to broken socket has any effect here. */
+ // NOTE: notify fails silently
+ //writeResult(connection, MC_DRV_RSP_SOCKET_ERROR);
+ return;
+ }
+ if (rlen != payload_len) {
+ LOG_E("wrong buffer length %i received from Client", rlen);
+ // NOTE: notify fails silently
+ //writeResult(connection, MC_DRV_RSP_PAYLOAD_LENGTH_ERROR);
+ return;
+ }
+
+ // Device required
+ MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
+ if (NULL == device) {
+ LOG_V("%s: no device associated with connection", __FUNCTION__);
+ // NOTE: notify fails silently
+ // writeResult(connection,MC_DRV_RSP_DEVICE_NOT_OPENED);
+ return;
+ }
+
+ device->notify(connection, cmd.sessionId);
+ // NOTE: for notifications there is no response at all
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processMapBulkBuf(Connection *connection)
+{
+ MC_DRV_CMD_MAP_BULK_BUF_struct cmd;
+
+ RECV_PAYLOAD_FROM_CLIENT(connection, &cmd);
+
+ // Device required
+ MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
+ CHECK_DEVICE(device, connection);
+
+ if (!device->lockWsmL2(cmd.handle)) {
+ LOG_E("Couldn't lock the buffer!");
+ writeResult(connection, MC_DRV_ERR_DAEMON_WSM_HANDLE_NOT_FOUND);
+ return;
+ }
+
+ uint32_t secureVirtualAdr = (uint32_t)NULL;
+ uint64_t pAddrL2 = device->findWsmL2(cmd.handle, connection->socketDescriptor);
+
+ if (pAddrL2 == 0) {
+ LOG_E("Failed to resolve WSM with handle %u", cmd.handle);
+ writeResult(connection, MC_DRV_ERR_DAEMON_WSM_HANDLE_NOT_FOUND);
+ return;
+ }
+
+ // Map bulk memory to secure world
+ mcResult_t mcResult = device->mapBulk(connection, cmd.sessionId, cmd.handle, pAddrL2,
+ cmd.offsetPayload, cmd.lenBulkMem, &secureVirtualAdr);
+
+ if (mcResult != MC_DRV_OK) {
+ writeResult(connection, mcResult);
+ return;
+ }
+
+ mcDrvRspMapBulkMem_t rsp;
+ rsp.header.responseId = MC_DRV_OK;
+ rsp.payload.sessionId = cmd.sessionId;
+ rsp.payload.secureVirtualAdr = secureVirtualAdr;
+ connection->writeData(&rsp, sizeof(mcDrvRspMapBulkMem_t));
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processUnmapBulkBuf(Connection *connection)
+{
+ MC_DRV_CMD_UNMAP_BULK_BUF_struct cmd;
+ RECV_PAYLOAD_FROM_CLIENT(connection, &cmd)
+
+ // Device required
+ MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
+ CHECK_DEVICE(device, connection);
+
+ // Unmap bulk memory from secure world
+ uint32_t mcResult = device->unmapBulk(connection, cmd.sessionId, cmd.handle,
+ cmd.secureVirtualAdr, cmd.lenBulkMem);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_V("MCP UNMAP returned code %d", mcResult);
+ writeResult(connection, mcResult);
+ return;
+ }
+
+ // TODO-2012-09-06-haenellu: Think about not ignoring the error case.
+ device->unlockWsmL2(cmd.handle);
+
+ writeResult(connection, MC_DRV_OK);
+}
+
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processGetVersion(
+ Connection *connection
+)
+{
+ // there is no payload to read
+
+ mcDrvRspGetVersion_t rspGetVersion;
+ rspGetVersion.version = MC_MAKE_VERSION(DAEMON_VERSION_MAJOR, DAEMON_VERSION_MINOR);
+ rspGetVersion.responseId = MC_DRV_OK;
+
+ connection->writeData(&rspGetVersion, sizeof(mcDrvRspGetVersion_t));
+}
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processGetMobiCoreVersion(
+ Connection *connection
+)
+{
+ // there is no payload to read
+
+ // Device required
+ MobiCoreDevice *device = (MobiCoreDevice *) (connection->connectionData);
+ CHECK_DEVICE(device, connection);
+
+ // Get <t-base version info from secure world.
+ mcDrvRspGetMobiCoreVersion_t rspGetMobiCoreVersion;
+
+ mcResult_t mcResult = device->getMobiCoreVersion(&rspGetMobiCoreVersion.payload);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_V("MC GET_MOBICORE_VERSION returned code %d", mcResult);
+ writeResult(connection, mcResult);
+ return;
+ }
+
+ rspGetMobiCoreVersion.header.responseId = MC_DRV_OK;
+ connection->writeData(
+ &rspGetMobiCoreVersion,
+ sizeof(rspGetMobiCoreVersion));
+}
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processRegistryReadData(uint32_t commandId, Connection *connection)
+{
+#define MAX_DATA_SIZE 512
+mcDrvResponseHeader_t rspRegistry = { .responseId =
+ MC_DRV_ERR_INVALID_OPERATION
+ };
+ void *buf = alloca(MAX_DATA_SIZE);
+ uint32_t len = MAX_DATA_SIZE;
+ mcSoAuthTokenCont_t auth;
+ mcSpid_t spid;
+ mcUuid_t uuid;
+
+ if (!checkPermission(connection)) {
+ connection->writeData(&rspRegistry, sizeof(rspRegistry));
+ return;
+ }
+
+ switch (commandId) {
+ case MC_DRV_REG_READ_AUTH_TOKEN:
+ rspRegistry.responseId = mcRegistryReadAuthToken(&auth);
+ buf = &auth;
+ len = sizeof(mcSoAuthTokenCont_t);
+ break;
+ case MC_DRV_REG_READ_ROOT_CONT:
+ rspRegistry.responseId = mcRegistryReadRoot(buf, &len);
+ break;
+ case MC_DRV_REG_READ_SP_CONT:
+ if (!getData(connection, &spid, sizeof(spid)))
+ break;
+ rspRegistry.responseId = mcRegistryReadSp(spid, buf, &len);
+ break;
+ case MC_DRV_REG_READ_TL_CONT:
+ if (!getData(connection, &uuid, sizeof(uuid)))
+ break;
+ if (!getData(connection, &spid, sizeof(spid)))
+ break;
+ rspRegistry.responseId = mcRegistryReadTrustletCon(&uuid, spid, buf, &len);
+ break;
+ default:
+ break;
+ }
+ connection->writeData(&rspRegistry, sizeof(rspRegistry));
+ if (rspRegistry.responseId != MC_DRV_ERR_INVALID_OPERATION)
+ connection->writeData(buf, len);
+}
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processRegistryWriteData(uint32_t commandId, Connection *connection)
+{
+mcDrvResponseHeader_t rspRegistry = { .responseId =
+ MC_DRV_ERR_INVALID_OPERATION
+ };
+ uint32_t soSize;
+ void *so;
+
+ if (!checkPermission(connection)) {
+ connection->writeData(&rspRegistry, sizeof(rspRegistry));
+ return;
+ }
+
+ // First read the SO data size
+ if (!getData(connection, &soSize, sizeof(soSize))) {
+ LOG_E("Failed to read SO data size");
+ connection->writeData(&rspRegistry, sizeof(rspRegistry));
+ return;
+ }
+ so = malloc(soSize);
+ if (so == NULL) {
+ LOG_E("Allocation failure");
+ rspRegistry.responseId = MC_DRV_ERR_NO_FREE_MEMORY;
+ connection->writeData(&rspRegistry, sizeof(rspRegistry));
+ return;
+ }
+
+ switch (commandId) {
+ case MC_DRV_REG_STORE_AUTH_TOKEN: {
+ if (!getData(connection, so, soSize))
+ break;
+ rspRegistry.responseId = mcRegistryStoreAuthToken(so, soSize);
+ break;
+ }
+ case MC_DRV_REG_WRITE_ROOT_CONT: {
+ if (!getData(connection, so, soSize))
+ break;
+ rspRegistry.responseId = mcRegistryStoreRoot(so, soSize);
+ break;
+ }
+ case MC_DRV_REG_WRITE_SP_CONT: {
+ mcSpid_t spid;
+ if (!getData(connection, &spid, sizeof(spid)))
+ break;
+ if (!getData(connection, so, soSize))
+ break;
+ rspRegistry.responseId = mcRegistryStoreSp(spid, so, soSize);
+ break;
+ }
+ case MC_DRV_REG_WRITE_TL_CONT: {
+ mcUuid_t uuid;
+ mcSpid_t spid;
+ if (!getData(connection, &uuid, sizeof(uuid)))
+ break;
+ if (!getData(connection, &spid, sizeof(spid)))
+ break;
+ if (!getData(connection, so, soSize))
+ break;
+ rspRegistry.responseId = mcRegistryStoreTrustletCon(&uuid, spid, so, soSize);
+ break;
+ }
+ case MC_DRV_REG_WRITE_SO_DATA: {
+ if (!getData(connection, so, soSize))
+ break;
+ rspRegistry.responseId = mcRegistryStoreData(so, soSize);
+ break;
+ }
+ case MC_DRV_REG_STORE_TA_BLOB: {
+ uint32_t blobSize = soSize;
+ mcSpid_t spid;
+ void *blob;
+ if (!getData(connection, &spid, sizeof(spid)))
+ break;
+ blob = malloc(blobSize);
+ if (blob == NULL) {
+ LOG_E("Allocation failure");
+ rspRegistry.responseId = MC_DRV_ERR_NO_FREE_MEMORY;
+ break;
+ }
+ if (!getData(connection, blob, blobSize)) {
+ free(blob);
+ break;
+ }
+ //LOG_I("processLoadCheck");
+ rspRegistry.responseId = processLoadCheck(spid, blob, blobSize);
+ if (rspRegistry.responseId != MC_DRV_OK){
+ LOG_I("processLoadCheck failed");
+ free(blob);
+ break;
+ }
+ //LOG_I("mcRegistryStoreTABlob");
+ rspRegistry.responseId = mcRegistryStoreTABlob(spid, blob, blobSize);
+ free(blob);
+ break;
+ }
+ default:
+ break;
+ }
+ free(so);
+ connection->writeData(&rspRegistry, sizeof(rspRegistry));
+}
+
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::processRegistryDeleteData(uint32_t commandId, Connection *connection)
+{
+mcDrvResponseHeader_t rspRegistry = { .responseId =
+ MC_DRV_ERR_INVALID_OPERATION
+ };
+ mcSpid_t spid;
+
+ if (!checkPermission(connection)) {
+ connection->writeData(&rspRegistry, sizeof(rspRegistry));
+ return;
+ }
+
+ switch (commandId) {
+ case MC_DRV_REG_DELETE_AUTH_TOKEN:
+ rspRegistry.responseId = mcRegistryDeleteAuthToken();
+ break;
+ case MC_DRV_REG_DELETE_ROOT_CONT:
+ rspRegistry.responseId = mcRegistryCleanupRoot();
+ break;
+ case MC_DRV_REG_DELETE_SP_CONT:
+ if (!getData(connection, &spid, sizeof(spid)))
+ break;
+ rspRegistry.responseId = mcRegistryCleanupSp(spid);
+ break;
+ case MC_DRV_REG_DELETE_TL_CONT:
+ mcUuid_t uuid;
+ if (!getData(connection, &uuid, sizeof(uuid)))
+ break;
+ if (!getData(connection, &spid, sizeof(spid)))
+ break;
+ rspRegistry.responseId = mcRegistryCleanupTrustlet(&uuid, spid);
+ break;
+ default:
+ break;
+ }
+
+ connection->writeData(&rspRegistry, sizeof(rspRegistry));
+}
+
+//------------------------------------------------------------------------------
+bool MobiCoreDriverDaemon::handleConnection(
+ Connection *connection
+)
+{
+ bool ret = false;
+
+ // This is the big lock around everything the Daemon does, including socket and MCI access
+ static CMutex mutex;
+
+ /* In case of RTM fault do not try to signal anything to MobiCore
+ * just answer NO to all incoming connections! */
+ if (mobiCoreDevice->getMcFault()) {
+ LOG_I("Ignore request, <t-base has faulted before.");
+ return false;
+ }
+
+ mutex.lock();
+ mobiCoreDevice->mutex_mcp.lock();
+
+ LOG_I("handleConnection()==== %p", connection);
+ do {
+ // Read header
+ mcDrvCommandHeader_t mcDrvCommandHeader;
+ ssize_t rlen = connection->readData(
+ &(mcDrvCommandHeader),
+ sizeof(mcDrvCommandHeader));
+
+ if (rlen == 0) {
+ LOG_V(" handleConnection(): Connection closed.");
+ break;
+ }
+ if (rlen == -1) {
+ LOG_E("Socket error.");
+ break;
+ }
+ if (rlen == -2) {
+ LOG_E("Timeout.");
+ break;
+ }
+ ret = true;
+
+ switch (mcDrvCommandHeader.commandId) {
+ //-----------------------------------------
+ case MC_DRV_CMD_OPEN_DEVICE:
+ processOpenDevice(connection);
+ break;
+ //-----------------------------------------
+ case MC_DRV_CMD_CLOSE_DEVICE:
+ processCloseDevice(connection);
+ break;
+ //-----------------------------------------
+ case MC_DRV_CMD_OPEN_SESSION:
+ processOpenSession(connection, false);
+ break;
+ //-----------------------------------------
+ case MC_DRV_CMD_OPEN_TRUSTLET:
+ processOpenTrustlet(connection);
+ break;
+ //-----------------------------------------
+ case MC_DRV_CMD_OPEN_TRUSTED_APP:
+ processOpenSession(connection, true);
+ break;
+ //-----------------------------------------
+ case MC_DRV_CMD_CLOSE_SESSION:
+ processCloseSession(connection);
+ break;
+ //-----------------------------------------
+ case MC_DRV_CMD_NQ_CONNECT:
+ processNqConnect(connection);
+ break;
+ //-----------------------------------------
+ case MC_DRV_CMD_NOTIFY:
+ processNotify(connection);
+ break;
+ //-----------------------------------------
+ case MC_DRV_CMD_MAP_BULK_BUF:
+ processMapBulkBuf(connection);
+ break;
+ //-----------------------------------------
+ case MC_DRV_CMD_UNMAP_BULK_BUF:
+ processUnmapBulkBuf(connection);
+ break;
+ //-----------------------------------------
+ case MC_DRV_CMD_GET_VERSION:
+ processGetVersion(connection);
+ break;
+ //-----------------------------------------
+ case MC_DRV_CMD_GET_MOBICORE_VERSION:
+ processGetMobiCoreVersion(connection);
+ break;
+ //-----------------------------------------
+ /* Registry functionality */
+ // Write Registry Data
+ case MC_DRV_REG_STORE_AUTH_TOKEN:
+ case MC_DRV_REG_WRITE_ROOT_CONT:
+ case MC_DRV_REG_WRITE_SP_CONT:
+ case MC_DRV_REG_WRITE_TL_CONT:
+ case MC_DRV_REG_WRITE_SO_DATA:
+ case MC_DRV_REG_STORE_TA_BLOB:
+ processRegistryWriteData(mcDrvCommandHeader.commandId, connection);
+ break;
+ //-----------------------------------------
+ // Read Registry Data
+ case MC_DRV_REG_READ_AUTH_TOKEN:
+ case MC_DRV_REG_READ_ROOT_CONT:
+ case MC_DRV_REG_READ_SP_CONT:
+ case MC_DRV_REG_READ_TL_CONT:
+ processRegistryReadData(mcDrvCommandHeader.commandId, connection);
+ break;
+ //-----------------------------------------
+ // Delete registry data
+ case MC_DRV_REG_DELETE_AUTH_TOKEN:
+ case MC_DRV_REG_DELETE_ROOT_CONT:
+ case MC_DRV_REG_DELETE_SP_CONT:
+ case MC_DRV_REG_DELETE_TL_CONT:
+ processRegistryDeleteData(mcDrvCommandHeader.commandId, connection);
+ break;
+ //-----------------------------------------
+ default:
+ LOG_E("Unknown command: %d=0x%x",
+ mcDrvCommandHeader.commandId,
+ mcDrvCommandHeader.commandId);
+ ret = false;
+ break;
+ }
+ } while (0);
+ mobiCoreDevice->mutex_mcp.unlock();
+ mutex.unlock();
+ LOG_I("handleConnection()<-------");
+
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+/**
+ * Print daemon command line options
+ */
+
+void printUsage(
+ int argc __unused,
+ char *args[]
+)
+{
+#ifdef MOBICORE_COMPONENT_BUILD_TAG
+ fprintf(stderr, "<t-base Driver Daemon %u.%u. \"%s\" %s %s\n", DAEMON_VERSION_MAJOR, DAEMON_VERSION_MINOR, MOBICORE_COMPONENT_BUILD_TAG, __DATE__, __TIME__);
+#else
+#warning "MOBICORE_COMPONENT_BUILD_TAG is not defined!"
+#endif
+
+ fprintf(stderr, "usage: %s [-mdsbhp]\n", args[0]);
+ fprintf(stderr, "Start <t-base Daemon\n\n");
+ fprintf(stderr, "-h\t\tshow this help\n");
+ fprintf(stderr, "-b\t\tfork to background\n");
+ fprintf(stderr, "-s\t\tdisable daemon scheduler(default enabled)\n");
+ fprintf(stderr, "-r DRIVER\t<t-base driver to load at start-up\n");
+}
+
+//------------------------------------------------------------------------------
+/**
+ * Signal handler for daemon termination
+ * Using this handler instead of the standard libc one ensures the daemon
+ * can cleanup everything -> read() on a FD will now return EINTR
+ */
+void terminateDaemon(
+ int signum
+)
+{
+ LOG_E("Signal %d received\n", signum);
+}
+
+//------------------------------------------------------------------------------
+/**
+ * Main entry of the <t-base Driver Daemon.
+ */
+int main(int argc, char *args[])
+{
+ // Create the <t-base Driver Singleton
+ MobiCoreDriverDaemon *mobiCoreDriverDaemon = NULL;
+ // Process signal action
+ struct sigaction action;
+
+ // Read the Command line options
+ extern char *optarg;
+ extern int optopt;
+ int c, errFlag = 0;
+ // Scheduler enabled by default
+ int schedulerFlag = 1;
+ // Autoload driver at start-up
+ int driverLoadFlag = 0;
+ std::vector<std::string> drivers;
+ // By default don't fork
+ bool forkDaemon = false;
+
+ /* Initialize mutex and condition variable objects */
+ pthread_mutex_init(&syncMutex, NULL);
+ pthread_cond_init (&syncCondition, NULL);
+
+ while ((c = getopt(argc, args, "r:sbhp:")) != -1) {
+ switch (c) {
+ case 'h': /* Help */
+ errFlag++;
+ break;
+ case 's': /* Disable Scheduler */
+ schedulerFlag = 0;
+ break;
+ case 'b': /* Fork to background */
+ forkDaemon = true;
+ break;
+ case 'r': /* Load <t-base driver at start-up */
+ driverLoadFlag = 1;
+ drivers.push_back(optarg);
+ break;
+ case ':': /* -r operand */
+ fprintf(stderr, "Option -%c requires an operand\n", optopt);
+ errFlag++;
+ break;
+ case '?':
+ fprintf(stderr, "Unrecognized option: -%c\n", optopt);
+ errFlag++;
+ }
+ }
+ if (errFlag) {
+ printUsage(argc, args);
+ exit(2);
+ }
+
+ // We should fork the daemon to background
+ if (forkDaemon == true) {
+
+ /* ignore terminal has been closed signal */
+ signal(SIGHUP, SIG_IGN);
+
+ int i = fork();
+ if (i < 0) {
+ exit(1);
+ }
+ // Parent
+ else if (i > 0) {
+ exit(0);
+ }
+
+ // obtain a new process group */
+ setsid();
+ /* close all descriptors */
+ for (i = sysconf(_SC_OPEN_MAX); i >= 0; --i) {
+ close(i);
+ }
+ // STDIN, STDOUT and STDERR should all point to /dev/null */
+ i = open("/dev/null", O_RDWR);
+ dup(i);
+ dup(i);
+ /* ignore tty signals */
+ signal(SIGTSTP, SIG_IGN);
+ signal(SIGTTOU, SIG_IGN);
+ signal(SIGTTIN, SIG_IGN);
+ }
+
+ // Set up the structure to specify the new action.
+ action.sa_handler = terminateDaemon;
+ sigemptyset (&action.sa_mask);
+ action.sa_flags = 0;
+ sigaction (SIGINT, &action, NULL);
+ sigaction (SIGTERM, &action, NULL);
+ signal(SIGPIPE, SIG_IGN);
+
+ mobiCoreDriverDaemon = new MobiCoreDriverDaemon(
+ /* Scheduler status */
+ schedulerFlag,
+ /* Auto Driver loading */
+ driverLoadFlag,
+ drivers);
+
+ // Start the driver
+ mobiCoreDriverDaemon->run();
+
+ delete mobiCoreDriverDaemon;
+
+ pthread_mutex_destroy(&syncMutex);
+ pthread_cond_destroy(&syncCondition);
+
+ // This should not happen
+ LOG_E("Exiting <t-base Daemon");
+
+ return EXIT_FAILURE;
+}
+
+//------------------------------------------------------------------------------
+static void __unused checkMobiCoreVersion(
+ MobiCoreDevice *mobiCoreDevice
+)
+{
+ bool failed = false;
+
+ // Get MobiCore version info.
+ mcDrvRspGetMobiCoreVersionPayload_t versionPayload;
+ mcResult_t mcResult = mobiCoreDevice->getMobiCoreVersion(&versionPayload);
+
+ if (mcResult != MC_DRV_OK) {
+ LOG_E("Failed to obtain <t-base version info. MCP return code: %u", mcResult);
+ failed = true;
+ } else {
+ LOG_I_RELEASE("Product ID is %s", versionPayload.versionInfo.productId);
+
+ // Check <t-base version info.
+ char *msg;
+ if (!checkVersionOkMCI(versionPayload.versionInfo.versionMci, &msg)) {
+ LOG_E("%s", msg);
+ failed = true;
+ }
+ LOG_I_RELEASE("%s", msg);
+ if (!checkVersionOkSO(versionPayload.versionInfo.versionSo, &msg)) {
+ LOG_E("%s", msg);
+ failed = true;
+ }
+ LOG_I_RELEASE("%s", msg);
+ if (!checkVersionOkMCLF(versionPayload.versionInfo.versionMclf, &msg)) {
+ LOG_E("%s", msg);
+ failed = true;
+ }
+ LOG_I_RELEASE("%s", msg);
+ if (!checkVersionOkCONTAINER(versionPayload.versionInfo.versionContainer, &msg)) {
+ LOG_E("%s", msg);
+ failed = true;
+ }
+ LOG_I_RELEASE("%s", msg);
+ }
+
+ if (failed) {
+ exit(1);
+ }
+}
+
+//------------------------------------------------------------------------------
+bool MobiCoreDriverDaemon::loadToken(uint8_t *token, uint32_t sosize)
+{
+ bool ret = false;
+ CWsm_ptr pWsm = NULL;
+ Connection *conn = NULL;
+
+ do {
+ LOG_I("registering L2 in kmod, p=%p, len=%i", token, sosize);
+
+ pWsm = mobiCoreDevice->registerWsmL2((addr_t) (token), sosize, 0);
+ if (pWsm == NULL) {
+ LOG_E("allocating WSM for Token failed");
+ break;
+ }
+
+ /* Initialize information data of LOAD_TOKEN command */
+ loadTokenData_t loadTokenData;
+ loadTokenData.addr = pWsm->physAddr;
+ loadTokenData.offs = ((uintptr_t) token) & 0xFFF;
+ loadTokenData.len = sosize;
+
+ conn = new Connection();
+ uint32_t mcRet = mobiCoreDevice->loadToken(conn, &loadTokenData);
+
+ /* Unregister physical memory from kernel module. This will also destroy
+ * the WSM object.
+ */
+ mobiCoreDevice->unregisterWsmL2(pWsm);
+ pWsm = NULL;
+
+ if (mcRet != MC_MCP_RET_OK) {
+ LOG_E("LOAD_TOKEN error 0x%x", mcRet);
+ break;
+ }
+ ret = true;
+
+ } while (false);
+
+ delete pWsm;
+ delete conn;
+
+ return ret;
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_CONHDLR
+ * @{
+ * @file
+ *
+ * <t-base driver class.
+ * The <t-base driver class implements the ConnectionHandler interface.
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef MOBICOREDRIVER_H_
+#define MOBICOREDRIVER_H_
+
+#include "Server/public/ConnectionHandler.h"
+#include "Server/public/Server.h"
+
+#include "MobiCoreDevice.h"
+#include <string>
+#include <list>
+
+
+#define MAX_SERVERS 2
+
+extern string getTlRegistryPath();
+
+class MobicoreDriverResources
+{
+public:
+ Connection *conn;
+ CWsm *pTciWsm;
+ uint32_t sessionId;
+
+ MobicoreDriverResources(
+ Connection *conn,
+ CWsm *pTciWsm,
+ uint32_t sessionId
+ ) {
+ this->conn = conn;
+ this->pTciWsm = pTciWsm;
+ this->sessionId = sessionId;
+ };
+};
+
+typedef std::list<MobicoreDriverResources *> driverResourcesList_t;
+
+class MobiCoreDriverDaemon : ConnectionHandler
+{
+
+public:
+
+ /**
+ * Create daemon object
+ *
+ * @param enableScheduler Enable NQ IRQ scheduler
+ * @param loadDriver Load driver at daemon startup
+ * @param driverPath Startup driver path
+ */
+ MobiCoreDriverDaemon(
+ bool enableScheduler,
+
+ /**< <t-base driver loading at start-up */
+ bool loadDriver,
+ std::vector<std::string> drivers
+ );
+
+ virtual ~MobiCoreDriverDaemon(
+ void
+ );
+
+ void dropConnection(
+ Connection *connection
+ );
+
+ bool handleConnection(
+ Connection *connection
+ );
+
+ void run(
+ void
+ );
+
+private:
+ MobiCoreDevice *mobiCoreDevice;
+ /**< Flag to start/stop the scheduler */
+ bool enableScheduler;
+ /**< Flag to load drivers at startup */
+ bool loadDriver;
+ std::vector<std::string> drivers;
+ /**< List of resources for the loaded drivers */
+ driverResourcesList_t driverResources;
+ /**< List of servers processing connections */
+ Server *servers[MAX_SERVERS];
+
+ bool checkPermission(Connection *connection);
+
+ size_t writeResult(
+ Connection *connection,
+ mcResult_t code
+ );
+
+ /**
+ * Resolve a device ID to a MobiCore device.
+ *
+ * @param deviceId Device identifier of the device.
+ * @return Reference to the device or NULL if device could not be found.
+ */
+ MobiCoreDevice *getDevice(
+ uint32_t deviceId
+ );
+
+ /**
+ * Load Device driver
+ *
+ * @param driverPath Path to the driver file
+ * @return True for success/false for failure
+ */
+ bool loadDeviceDriver(std::string driverPath);
+
+ /**
+ * Open Device command
+ *
+ * @param connection Connection object
+ */
+ void processOpenDevice(Connection *connection);
+
+ /**
+ * Open Session command
+ *
+ * @param connection Connection object
+ */
+ void processOpenSession(Connection *connection, bool isGpUuid);
+
+ /**
+ * Check Load TA command
+ *
+ * @param spid claimed
+ * @param blob TA blob pointer
+ * @param size TA blob pointer size
+ * @return true in case of success, false in case of failure
+ */
+
+ mcResult_t processLoadCheck(mcSpid_t spid, void *blob, uint32_t size);
+
+ /**
+ * Open Trustlet command
+ *
+ * @param connection Connection object
+ */
+ void processOpenTrustlet(Connection *connection);
+
+ /**
+ * NQ Connect command
+ *
+ * @param connection Connection object
+ */
+ void processNqConnect(Connection *connection);
+
+ /**
+ * Close Device command
+ *
+ * @param connection Connection object
+ */
+ void processCloseDevice(Connection *connection);
+
+ /**
+ * Notify command
+ *
+ * @param connection Connection object
+ */
+ void processNotify(Connection *connection);
+
+ /**
+ * Close Session command
+ *
+ * @param connection Connection object
+ */
+ void processCloseSession(Connection *connection);
+
+ /**
+ * Map Bulk buf command
+ *
+ * @param connection Connection object
+ */
+ void processMapBulkBuf(Connection *connection);
+
+ /**
+ * Unmap bulk buf command
+ *
+ * @param connection Connection object
+ */
+ void processUnmapBulkBuf(Connection *connection);
+
+ /**
+ * Get Version command
+ *
+ * @param connection Connection object
+ */
+ void processGetVersion(Connection *connection);
+
+ /**
+ * Get MobiCore version command
+ *
+ * @param connection Connection object
+ */
+ void processGetMobiCoreVersion(Connection *connection);
+
+ /**
+ * Generic Registry read command
+ *
+ * @param commandId Actual command id
+ * @param connection Connection object
+ */
+ void processRegistryReadData(uint32_t commandId, Connection *connection);
+
+ /**
+ * Generic Registry write command
+ *
+ * @param commandId Actual command id
+ * @param connection Connection object
+ */
+ void processRegistryWriteData(uint32_t commandId, Connection *connection);
+
+ /**
+ * Generic Registry Delete command
+ *
+ * @param commandId Actual command id
+ * @param connection Connection object
+ */
+ void processRegistryDeleteData(uint32_t commandId, Connection *connection);
+
+ /**
+ * Load Token
+ * This function loads a token (if found) from the registry and uses it as
+ * the basis for the device attestation functionality
+ *
+ * @param token the token to base the attestation on (raw format)
+ * @param sosize the size of the token
+ */
+ bool loadToken(uint8_t *token, uint32_t sosize);
+};
+
+#endif /* MOBICOREDRIVER_H_ */
+
+/** @} */
--- /dev/null
+# =============================================================================
+#
+# MC driver server files
+#
+# =============================================================================
+
+# This is not a separate module.
+# Only for inclusion by other modules.
+
+SERVER_PATH := Daemon/Server
+
+# Add new folders with header files here
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(SERVER_PATH)/public
+
+# Add new source files here
+LOCAL_SRC_FILES += $(SERVER_PATH)/Server.cpp \
+ $(SERVER_PATH)/NetlinkServer.cpp
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Connection server.
+ *
+ * Handles incoming socket connections from clients using the MobiCore driver.
+ */
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "public/NetlinkServer.h"
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <linux/netlink.h>
+
+#include <stdlib.h>
+#include "NetlinkConnection.h"
+#include <signal.h>
+
+#define LOG_TAG "McDaemon"
+#include "log.h"
+
+//------------------------------------------------------------------------------
+NetlinkServer::NetlinkServer(
+ ConnectionHandler *connectionHandler
+): Server(connectionHandler, "dummy")
+{
+}
+
+
+//------------------------------------------------------------------------------
+void NetlinkServer::run(
+)
+{
+ do {
+ LOG_I("NetlinkServer: Starting to listen on netlink bus");
+
+ // Open a socket
+ serverSock = socket(PF_NETLINK, SOCK_DGRAM, MC_DAEMON_NETLINK);
+ if (serverSock < 0) {
+ LOG_ERRNO("Opening socket");
+ break;
+ }
+
+ // Fill in address structure and bind to socket
+ struct sockaddr_nl src_addr;
+ struct nlmsghdr *nlh = NULL;
+ struct iovec iov;
+ struct msghdr msg;
+ uint32_t len;
+
+ memset(&src_addr, 0, sizeof(src_addr));
+ src_addr.nl_family = AF_NETLINK;
+ src_addr.nl_pid = MC_DAEMON_PID; /* daemon pid */
+ src_addr.nl_groups = 0; /* not in mcast groups */
+ if (::bind(serverSock, (struct sockaddr *)&src_addr, sizeof(src_addr)) < 0) {
+ LOG_ERRNO("Binding to server socket failed, because bind");
+ close(serverSock);
+ serverSock = -1;
+ break;
+ }
+
+ // Start reading the socket
+ LOG_I("\n********* successfully initialized *********\n");
+
+ for (;;) {
+ // This buffer will be taken over by the connection it was routed to
+ nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD));
+ if (nlh == NULL) {
+ LOG_E("Allocation failure");
+ break;
+ }
+ memset(&msg, 0, sizeof(msg));
+ iov.iov_base = (void *)nlh;
+ iov.iov_len = NLMSG_SPACE(MAX_PAYLOAD);
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+ msg.msg_name = &src_addr;
+ msg.msg_namelen = sizeof(src_addr);
+
+ memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD));
+
+ // Read the incoming message and route it to the connection based
+ // on the incoming PID
+ if ((int) (len = recvmsg(serverSock, &msg, 0)) < 0) {
+ LOG_ERRNO("recvmsg");
+ break;
+ }
+
+ if (NLMSG_OK(nlh, len)) {
+ handleMessage(nlh);
+ } else {
+ break;
+ }
+ }
+ close(serverSock);
+ serverSock = -1;
+ } while (false);
+
+ LOG_W("Could not open netlink socket. KernelAPI disabled");
+}
+
+//------------------------------------------------------------------------------
+void NetlinkServer::handleMessage(
+ struct nlmsghdr *nlh
+)
+{
+ uint32_t seq = nlh->nlmsg_seq;
+ uint32_t pid = nlh->nlmsg_pid;
+ //LOG_I("%s: Handling NQ message for pid %u seq %u...", __FUNCTION__, pid, seq);
+ uint64_t hash = hashConnection(pid, seq);
+ /* First cleanup the connection list */
+ cleanupConnections();
+
+ NetlinkConnection *connection = findConnection(hash);
+ // This is a message from a new client
+ if (connection == NULL) {
+ //LOG_I("%s: Cound't find the connection, creating a new one", __FUNCTION__);
+ connection = new NetlinkConnection(this, serverSock, pid, seq);
+ // Add the new connection
+ insertConnection(hash, connection);
+ }
+
+ connection->handleMessage(nlh);
+
+ // Only handle connections which have not been detached
+ if (connection->detached == false) {
+ if (!connectionHandler->handleConnection(connection)) {
+ LOG_I("%s: No command processed.", __FUNCTION__);
+ connection->socketDescriptor = -1;
+ //Inform the driver
+ connectionHandler->dropConnection(connection);
+
+ // Remove connection from list
+ removeConnection(hash);
+ connection->socketDescriptor = -1;
+ delete connection;
+ }
+ // If connection data is set to NULL then device close has been called
+ // so we must remove all connections associated with this hash
+ else if (connection->connectionData == NULL &&
+ connection->detached == false) {
+ delete connection;
+ }
+ }
+}
+
+
+//------------------------------------------------------------------------------
+void NetlinkServer::detachConnection(
+ Connection *connection
+)
+{
+ connection->detached = true;
+}
+
+
+//------------------------------------------------------------------------------
+NetlinkServer::~NetlinkServer(
+ void
+)
+{
+ connectionMap_t::iterator i;
+ // Shut down the server socket
+ if(serverSock != -1) {
+ close(serverSock);
+ serverSock = -1;
+ }
+
+ // Destroy all client connections
+ for (i = peerConnections.begin(); i != peerConnections.end(); i++) {
+ if (i->second->detached == false) {
+ delete i->second;
+ }
+ }
+ peerConnections.clear();
+}
+
+
+//------------------------------------------------------------------------------
+NetlinkConnection *NetlinkServer::findConnection(
+ uint64_t hash
+)
+{
+ connectionMap_t::iterator i = peerConnections.find(hash);
+ if (i != peerConnections.end()) {
+ return i->second;
+ }
+
+ return NULL;
+}
+
+
+//------------------------------------------------------------------------------
+void NetlinkServer::insertConnection(
+ uint64_t hash,
+ NetlinkConnection *connection
+)
+{
+ peerConnections[hash] = connection;
+}
+
+/* This is called from multiple threads! */
+//------------------------------------------------------------------------------
+void NetlinkServer::removeConnection(
+ uint64_t hash
+)
+{
+ connectionMap_t::iterator i = peerConnections.find(hash);
+ if (i != peerConnections.end()) {
+ peerConnections.erase(i);
+ }
+}
+
+//------------------------------------------------------------------------------
+void NetlinkServer::cleanupConnections(
+ void
+)
+{
+ connectionMap_t::reverse_iterator i;
+ pid_t pid;
+ NetlinkConnection *connection = NULL;
+ // Destroy all client connections
+ for (i = peerConnections.rbegin(); i != peerConnections.rend(); ++i) {
+ connection = i->second;
+ // Only 16 bits are for the actual PID, the rest is session magic
+ pid = connection->peerPid & 0xFFFF;
+ //LOG_I("%s: checking PID %u", __FUNCTION__, pid);
+ // Check if the peer pid is still alive
+ if (pid == 0) {
+ continue;
+ }
+ if (kill(pid, 0)) {
+ bool detached = connection->detached;
+ LOG_I("%s: PID %u has died, cleaning up session 0x%X",
+ __FUNCTION__, pid, connection->peerPid);
+
+ connection->socketDescriptor = -1;
+ //Inform the driver
+ connectionHandler->dropConnection(connection);
+
+ // We aren't handling this connection anymore no matter what
+ removeConnection(connection->hash);
+
+ // Remove connection from list only if detached, the detached
+ // connections are managed by the device
+ if (detached == false) {
+ delete connection;
+ }
+ if (peerConnections.size() == 0) {
+ break;
+ }
+ i = peerConnections.rbegin();
+ }
+ }
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Connection server.
+ *
+ * Handles incoming socket connections from clients using the MobiCore driver.
+ */
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "public/Server.h"
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+//#define LOG_VERBOSE
+#include "log.h"
+
+extern pthread_mutex_t syncMutex;
+extern pthread_cond_t syncCondition;
+extern bool Th_sync;
+
+//------------------------------------------------------------------------------
+Server::Server(
+ ConnectionHandler *connectionHandler,
+ const char *localAddr
+) : socketAddr(localAddr)
+{
+ this->connectionHandler = connectionHandler;
+ this->serverSock = -1;
+}
+
+
+//------------------------------------------------------------------------------
+void Server::run(
+ void
+)
+{
+ do {
+ pthread_mutex_lock(&syncMutex);
+
+ LOG_I("Server: start listening on socket %s", socketAddr.c_str());
+
+ // Open a socket (a UNIX domain stream socket)
+ serverSock = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (serverSock < 0) {
+ LOG_ERRNO("Can't open stream socket, because socket");
+ break;
+ }
+
+ // Fill in address structure and bind to socket
+ struct sockaddr_un serverAddr;
+ serverAddr.sun_family = AF_UNIX;
+ strncpy(serverAddr.sun_path, socketAddr.c_str(), sizeof(serverAddr.sun_path) - 1);
+
+ uint32_t len = strlen(serverAddr.sun_path) + sizeof(serverAddr.sun_family);
+ // Make the socket in the Abstract Domain(no path but everyone can connect)
+ serverAddr.sun_path[0] = 0;
+ if (::bind(serverSock, (struct sockaddr *) &serverAddr, len) < 0) {
+ LOG_ERRNO("Binding to server socket failed, because bind");
+ }
+
+ // Start listening on the socket
+ if (listen(serverSock, LISTEN_QUEUE_LEN) < 0) {
+ LOG_ERRNO("listen");
+ break;
+ }
+
+ LOG_I("\n********* successfully initialized Daemon *********\n");
+
+
+
+ for (;;) {
+ fd_set fdReadSockets;
+
+ // Clear FD for select()
+ FD_ZERO(&fdReadSockets);
+
+ // Select server socket descriptor
+ FD_SET(serverSock, &fdReadSockets);
+ int maxSocketDescriptor = serverSock;
+
+ // Select socket descriptor of all connections
+ for (connectionIterator_t iterator = peerConnections.begin();
+ iterator != peerConnections.end();
+ ++iterator) {
+ Connection *connection = (*iterator);
+ int peerSocket = connection->socketDescriptor;
+ FD_SET(peerSocket, &fdReadSockets);
+ if (peerSocket > maxSocketDescriptor) {
+ maxSocketDescriptor = peerSocket;
+ }
+ }
+
+ pthread_cond_signal(&syncCondition);
+ Th_sync=true;
+ pthread_mutex_unlock(&syncMutex);
+
+ // Wait for activities, select() returns the number of sockets
+ // which require processing
+ LOG_V(" Server: waiting on sockets");
+ int numSockets = select(
+ maxSocketDescriptor + 1,
+ &fdReadSockets,
+ NULL, NULL, NULL);
+
+ // Check if select failed
+ if (numSockets < 0) {
+ LOG_ERRNO("select");
+ break;
+ }
+
+ // actually, this should not happen.
+ if (0 == numSockets) {
+ LOG_W(" Server: select() returned 0, spurious event?.");
+ continue;
+ }
+
+ LOG_V(" Server: events on %d socket(s).", numSockets);
+
+ // Check if a new client connected to the server socket
+ if (FD_ISSET(serverSock, &fdReadSockets)) {
+ do {
+ LOG_V(" Server: new connection attempt.");
+ numSockets--;
+
+ struct sockaddr_un clientAddr;
+ socklen_t clientSockLen = sizeof(clientAddr);
+ int clientSock = accept(
+ serverSock,
+ (struct sockaddr *) &clientAddr,
+ &clientSockLen);
+
+ if (clientSock <= 0) {
+ LOG_ERRNO("accept");
+ break;
+ }
+
+ Connection *connection = new Connection(clientSock, &clientAddr);
+ peerConnections.push_back(connection);
+ LOG_I(" Server: new socket connection established and start listening.");
+ } while (false);
+
+ // we can ignore any errors from accepting a new connection.
+ // If this fail, the client has to deal with it, we are done
+ // and nothing has changed.
+ }
+
+ // Handle traffic on existing client connections
+ connectionIterator_t iterator = peerConnections.begin();
+ while ( (iterator != peerConnections.end())
+ && (numSockets > 0) ) {
+ Connection *connection = (*iterator);
+ int peerSocket = connection->socketDescriptor;
+
+ if (!FD_ISSET(peerSocket, &fdReadSockets)) {
+ ++iterator;
+ continue;
+ }
+
+ numSockets--;
+
+ // the connection will be terminated if command processing
+ // fails
+ if (!connectionHandler->handleConnection(connection)) {
+ LOG_I(" Server: dropping connection.");
+
+ //Inform the driver
+ connectionHandler->dropConnection(connection);
+
+ // Remove connection from list
+ delete connection;
+ iterator = peerConnections.erase(iterator);
+ continue;
+ }
+
+ ++iterator;
+ }
+ }
+
+ } while (false);
+
+ LOG_ERRNO("Exiting Server, because");
+}
+
+
+//------------------------------------------------------------------------------
+void Server::detachConnection(
+ Connection *connection
+)
+{
+ LOG_V(" Stopping to listen on notification socket.");
+
+ for (connectionIterator_t iterator = peerConnections.begin();
+ iterator != peerConnections.end();
+ ++iterator) {
+ Connection *tmpConnection = (*iterator);
+ if (tmpConnection == connection) {
+ peerConnections.erase(iterator);
+ LOG_I(" Stopped listening on notification socket.");
+ break;
+ }
+ }
+}
+
+
+//------------------------------------------------------------------------------
+Server::~Server(
+ void
+)
+{
+ // Shut down the server socket
+ if(serverSock != -1) {
+ close(serverSock);
+ serverSock = -1;
+ }
+
+ // Destroy all client connections
+ connectionIterator_t iterator = peerConnections.begin();
+ while (iterator != peerConnections.end()) {
+ Connection *tmpConnection = (*iterator);
+ delete tmpConnection;
+ iterator = peerConnections.erase(iterator);
+ }
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Interface for connection handlers used by Server.
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef CONNECTIONHANDLER_H_
+#define CONNECTIONHANDLER_H_
+
+#include "Connection.h"
+
+
+class ConnectionHandler
+{
+
+public:
+ virtual ~ConnectionHandler() {};
+
+ /**
+ * Handle connection activities.
+ * The connection handler shall process pending connection activities.
+ *
+ * @param [in] connection Reference to the connection which has data to process.
+ */
+ virtual bool handleConnection(
+ Connection *connection
+ ) = 0;
+
+ /**
+ * Connection has been closed.
+ * The connection handler shall clean up all resources associated with the given connection.
+ * After the method has been executed the connection object will be deleted.
+ *
+ * @param [in] connection Reference to the connection which will be deleted.
+ */
+ virtual void dropConnection(
+ Connection *connection
+ ) = 0;
+};
+
+#endif /* CONNECTIONHANDLER_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Connection server.
+ *
+ * Handles incoming socket connections from clients using the MobiCore driver.
+ *
+ * Iterative socket server using Netlink dgram protocol.
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef NETLINKSERVER_H_
+#define NETLINKSERVER_H_
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <linux/netlink.h>
+#include <cstdio>
+#include <map>
+
+#include "NetlinkConnection.h"
+#include "ConnectionHandler.h"
+#include "Server.h"
+
+class NetlinkServer: public Server, public NetlinkConnectionManager
+{
+public:
+ /**
+ * Server contructor.
+ *
+ * @param connectionHanler Connection handler to pass incoming connections to.
+ */
+ NetlinkServer(
+ ConnectionHandler *connectionHandler
+ );
+
+ /**
+ * Server destructor.
+ * All available connections will be terminated. Resources will be freed.
+ */
+ virtual ~NetlinkServer(
+ void
+ );
+
+ /**
+ * Start server and listen for incoming connections.
+ * Implements the central socket server loop. Incoming connections will be stored.
+ */
+ virtual void run(
+ void
+ );
+
+ /**
+ * Remove a connection object from the list of available connections.
+ * Detaching is required for notification connections wich are never used to transfer command
+ * data from TLCs to the driver. If the function succeeds, freeing the connection will no longer
+ * be the server's responsability.
+ *
+ * @param connection The connection object to remove.
+ */
+ virtual void detachConnection(
+ Connection *connection
+ );
+
+private:
+ /**
+ * Handle incomming Netlink message.
+ * It routes the incomming packet to the apropriate connection based on the packet's
+ * session magic.
+ *
+ * @param nlh The netlink message's header + payload
+ */
+ void handleMessage(
+ struct nlmsghdr *nlh
+ );
+
+ /**
+ * Retreive connection based on hash.
+ * Search the peer connections hashmap for a hash and return
+ * the associated Connection object
+ *
+ * @param seq The seq to search
+ * @return The NetlinkConnection object if found or NULL if not found
+ */
+ NetlinkConnection *findConnection(
+ uint64_t hash
+ );
+
+ /**
+ * Insert a connection in the peer connection hashmap
+ * Insert a new connection in the peer connections hashmap. If there is
+ * already such a connection it will be overriden!
+ *
+ * @param seq The seq to use
+ * @param connection The connection object to insert
+ */
+ void insertConnection(
+ uint64_t hash,
+ NetlinkConnection *connection
+ );
+
+ /**
+ * Remove a connection from the peer connections
+ * Remove the connection associated with seq from the peer list.
+ * This doesn't actually free the connection object!
+ * If the seq is invalid nothing happens.
+ *
+ * @param seq The seq to use
+ */
+ void removeConnection(
+ uint64_t hash
+ );
+
+
+ /**
+ * Check for sessions started by applications that died(exited)
+ * Remove the connections to applications that are not active anymore
+ * If the application has died then all the sessions associated with it
+ * should be closed!
+ *
+ */
+ void cleanupConnections(
+ void
+ );
+
+ connectionMap_t peerConnections; /**< Hashmap with connections to clients */
+};
+
+#endif /* SERVER_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
+ * @{
+ * @file
+ *
+ * Connection server.
+ *
+ * Handles incoming socket connections from clients using the MobiCore driver.
+ *
+ * Iterative socket server using UNIX domain stream protocol.
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef SERVER_H_
+#define SERVER_H_
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <string>
+#include <cstdio>
+#include <vector>
+#include "CThread.h"
+#include "ConnectionHandler.h"
+
+/** Number of incoming connections that can be queued.
+ * Additional clients will generate the error ECONNREFUSED. */
+#define LISTEN_QUEUE_LEN (16)
+
+
+class Server: public CThread
+{
+
+public:
+ /**
+ * Server contructor.
+ *
+ * @param connectionHanler Connection handler to pass incoming connections to.
+ * @param localAdrerss Pointer to a zero terminated string containing the file to listen to.
+ */
+ Server(
+ ConnectionHandler *connectionHandler,
+ const char *localAddr
+ );
+
+ /**
+ * Server destructor.
+ * All available connections will be terminated. Resources will be freed.
+ */
+ virtual ~Server(
+ void
+ );
+
+ /**
+ * Start server and listen for incoming connections.
+ * Implements the central socket server loop. Incoming connections will be stored.
+ */
+ virtual void run(
+ );
+
+ /**
+ * Remove a connection object from the list of available connections.
+ * Detaching is required for notification connections wich are never used to transfer command
+ * data from TLCs to the driver. If the function succeeds, the connection object will no longer
+ * be handled by the server.
+ *
+ * @param connection The connection object to remove.
+ */
+ virtual void detachConnection(
+ Connection *connection
+ );
+
+protected:
+ int serverSock;
+ string socketAddr;
+ ConnectionHandler *connectionHandler; /**< Connection handler registered to the server */
+
+private:
+ connectionList_t peerConnections; /**< Connections to devices */
+
+};
+
+#endif /* SERVER_H_ */
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON
+ * @{
+ * @file
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef MCDAEMON_H_
+#define MCDAEMON_H_
+
+#include <inttypes.h> // ANSI C99
+
+#include "mcUuid.h"
+#include "mcVersionInfo.h"
+
+#define SOCK_PATH "#mcdaemon"
+
+typedef enum {
+ MC_DRV_CMD_PING = 0,
+ MC_DRV_CMD_GET_INFO = 1,
+ MC_DRV_CMD_OPEN_DEVICE = 2,
+ MC_DRV_CMD_CLOSE_DEVICE = 3,
+ MC_DRV_CMD_NQ_CONNECT = 4,
+ MC_DRV_CMD_OPEN_SESSION = 5,
+ MC_DRV_CMD_CLOSE_SESSION = 6,
+ MC_DRV_CMD_NOTIFY = 7,
+ MC_DRV_CMD_MAP_BULK_BUF = 8,
+ MC_DRV_CMD_UNMAP_BULK_BUF = 9,
+ MC_DRV_CMD_GET_VERSION = 10,
+ MC_DRV_CMD_GET_MOBICORE_VERSION = 11,
+ MC_DRV_CMD_OPEN_TRUSTLET = 12,
+ MC_DRV_CMD_OPEN_TRUSTED_APP = 13,
+
+ // Registry Commands
+
+ // Auth token OPS
+ MC_DRV_REG_STORE_AUTH_TOKEN = 0x100000,
+ MC_DRV_REG_READ_AUTH_TOKEN = 0x100001,
+ MC_DRV_REG_DELETE_AUTH_TOKEN = 0x100002,
+ // Root container OPS
+ MC_DRV_REG_READ_ROOT_CONT = 0x100003,
+ MC_DRV_REG_WRITE_ROOT_CONT = 0x100004,
+ MC_DRV_REG_DELETE_ROOT_CONT = 0x100005,
+ // Service Provider Container OPS
+ MC_DRV_REG_READ_SP_CONT = 0x100006,
+ MC_DRV_REG_WRITE_SP_CONT = 0x100007,
+ MC_DRV_REG_DELETE_SP_CONT = 0x100008,
+ // Trustlet Container OPS
+ MC_DRV_REG_READ_TL_CONT = 0x100009,
+ MC_DRV_REG_WRITE_TL_CONT = 0x10000A,
+ MC_DRV_REG_DELETE_TL_CONT = 0x10000B,
+ // Shared Object Data write
+ MC_DRV_REG_WRITE_SO_DATA = 0x10000C,
+ // TA Blob store
+ MC_DRV_REG_STORE_TA_BLOB = 0x10000D,
+
+} mcDrvCmd_t;
+
+typedef struct {
+ mcDrvCmd_t commandId;
+} mcDrvCommandHeader_t;
+
+typedef struct {
+ /* <t-base Daemon uses Client API return codes also in commands between Daemon and Client Library. */
+ uint32_t responseId;
+} mcDrvResponseHeader_t;
+
+
+#define MC_DEVICE_ID_DEFAULT 0 /**< The default device ID */
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_OPEN_DEVICE_struct {
+ uint32_t commandId;
+ uint32_t deviceId;
+};
+
+typedef struct {
+ mcDrvResponseHeader_t header;
+} mcDrvRspOpenDevice_t;
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_CLOSE_DEVICE_struct {
+ uint32_t commandId;
+};
+
+typedef struct {
+ mcDrvResponseHeader_t header;
+} mcDrvRspCloseDevice_t;
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_OPEN_SESSION_struct {
+ uint32_t commandId;
+ uint32_t deviceId;
+ mcUuid_t uuid;
+ uintptr_t tci;
+ uint32_t handle;
+ uint32_t len;
+};
+
+typedef struct {
+ uint32_t sessionId;
+ uint32_t deviceSessionId;
+ uint32_t sessionMagic;
+} mcDrvRspOpenSessionPayload_t, *mcDrvRspOpenSessionPayload_ptr;
+
+typedef struct {
+ mcDrvResponseHeader_t header;
+ mcDrvRspOpenSessionPayload_t payload;
+} mcDrvRspOpenSession_t;
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_OPEN_TRUSTLET_struct {
+ uint32_t commandId;
+ uint32_t deviceId;
+ mcSpid_t spid;
+ uint32_t trustlet_len;
+ uintptr_t tci;
+ uint32_t handle;
+ uint32_t len;
+};
+
+typedef struct {
+ uint32_t sessionId;
+ uint32_t deviceSessionId;
+ uint32_t sessionMagic;
+} mcDrvRspOpenTrustletPayload_t, *mcDrvRspOpenTrustletPayload_ptr;
+
+typedef struct {
+ mcDrvResponseHeader_t header;
+ mcDrvRspOpenTrustletPayload_t payload;
+} mcDrvRspOpenTrustlet_t;
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_OPEN_TRUSTED_APP_struct {
+ uint32_t commandId;
+ uint32_t deviceId;
+ mcUuid_t uuid;
+ uintptr_t tci;
+ uint32_t handle;
+ uint32_t len;
+};
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_CLOSE_SESSION_struct {
+ uint32_t commandId;
+ uint32_t sessionId;
+};
+
+typedef struct {
+ mcDrvResponseHeader_t header;
+} mcDrvRspCloseSession_t;
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_NOTIFY_struct {
+ uint32_t commandId;
+ uint32_t sessionId;
+};
+
+// Notify does not have a response
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_MAP_BULK_BUF_struct {
+ uint32_t commandId;
+ uint32_t sessionId;
+ uint32_t handle;
+ uint32_t rfu;
+ uintptr_t offsetPayload;
+ uint32_t lenBulkMem;
+};
+
+typedef struct {
+ uint32_t sessionId;
+ uint32_t secureVirtualAdr;
+} mcDrvRspMapBulkMemPayload_t, *mcDrvRspMapBulkMemPayload_ptr;
+
+typedef struct {
+ mcDrvResponseHeader_t header;
+ mcDrvRspMapBulkMemPayload_t payload;
+} mcDrvRspMapBulkMem_t;
+
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_UNMAP_BULK_BUF_struct {
+ uint32_t commandId;
+ uint32_t sessionId;
+ uint32_t handle;
+ uintptr_t secureVirtualAdr;
+ uint32_t lenBulkMem;
+};
+
+typedef struct {
+ mcDrvResponseHeader_t header;
+} mcDrvRspUnmapBulkMem_t;
+
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_NQ_CONNECT_struct {
+ uint32_t commandId;
+ uint32_t deviceId;
+ uint32_t sessionId;
+ uint32_t deviceSessionId;
+ uint32_t sessionMagic; //Random data
+};
+
+typedef struct {
+ mcDrvResponseHeader_t header;
+} mcDrvRspNqConnect_t;
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_GET_VERSION_struct {
+ uint32_t commandId;
+};
+
+typedef struct {
+ uint32_t responseId;
+ uint32_t version;
+} mcDrvRspGetVersion_t;
+
+//--------------------------------------------------------------
+struct MC_DRV_CMD_GET_MOBICORE_VERSION_struct {
+ uint32_t commandId;
+};
+
+typedef struct {
+ mcVersionInfo_t versionInfo;
+} mcDrvRspGetMobiCoreVersionPayload_t, *mcDrvRspGetMobiCoreVersionPayload_ptr;
+
+typedef struct {
+ mcDrvResponseHeader_t header;
+ mcDrvRspGetMobiCoreVersionPayload_t payload;
+} mcDrvRspGetMobiCoreVersion_t;
+
+//--------------------------------------------------------------
+typedef union {
+ mcDrvCommandHeader_t header;
+ MC_DRV_CMD_OPEN_DEVICE_struct mcDrvCmdOpenDevice;
+ MC_DRV_CMD_CLOSE_DEVICE_struct mcDrvCmdCloseDevice;
+ MC_DRV_CMD_OPEN_SESSION_struct mcDrvCmdOpenSession;
+ MC_DRV_CMD_OPEN_TRUSTLET_struct mcDrvCmdOpenTrustlet;
+ MC_DRV_CMD_OPEN_TRUSTED_APP_struct mcDrvCmdOpenTrustedApp;
+ MC_DRV_CMD_CLOSE_SESSION_struct mcDrvCmdCloseSession;
+ MC_DRV_CMD_NQ_CONNECT_struct mcDrvCmdNqConnect;
+ MC_DRV_CMD_NOTIFY_struct mcDrvCmdNotify;
+ MC_DRV_CMD_MAP_BULK_BUF_struct mcDrvCmdMapBulkMem;
+ MC_DRV_CMD_UNMAP_BULK_BUF_struct mcDrvCmdUnmapBulkMem;
+ MC_DRV_CMD_GET_VERSION_struct mcDrvCmdGetVersion;
+ MC_DRV_CMD_GET_MOBICORE_VERSION_struct mcDrvCmdGetMobiCoreVersion;
+} mcDrvCommand_t, *mcDrvCommand_ptr;
+
+typedef union {
+ mcDrvResponseHeader_t header;
+ mcDrvRspOpenDevice_t mcDrvRspOpenDevice;
+ mcDrvRspCloseDevice_t mcDrvRspCloseDevice;
+ mcDrvRspOpenSession_t mcDrvRspOpenSession;
+ mcDrvRspCloseSession_t mcDrvRspCloseSession;
+ mcDrvRspNqConnect_t mcDrvRspNqConnect;
+ mcDrvRspMapBulkMem_t mcDrvRspMapBulkMem;
+ mcDrvRspUnmapBulkMem_t mcDrvRspUnmapBulkMem;
+ mcDrvRspGetVersion_t mcDrvRspGetVersion;
+ mcDrvRspGetMobiCoreVersion_t mcDrvRspGetMobiCoreVersion;
+} mcDrvResponse_t, *mcDrvResponse_ptr;
+
+#endif /* MCDAEMON_H_ */
+
+/** @} */
--- /dev/null
+/**
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef DAEMON_VERSION_H_
+#define DAEMON_VERSION_H_
+
+#define DAEMON_VERSION_MAJOR 0
+#define DAEMON_VERSION_MINOR 2
+
+#endif /** DAEMON_VERSION_H_ */
+
--- /dev/null
+# =============================================================================
+#
+# Module: Kernel Module access
+# All paths are relative to application root!
+#
+# =============================================================================
+
+
+include $(LOCAL_PATH)/Kernel/Platforms/Generic/Android.mk
+
+# Include platform specific sub-makefiles
+ifdef $(PLATFORM)
+ include $(LOCAL_PATH)/Kernel/Platforms/$(PLATFORM)/Android.mk
+endif
+
+# Add new source files here
+LOCAL_SRC_FILES += Kernel/CKMod.cpp
+
+# Header files for components including this module
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/Kernel
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_KERNEL
+ * @{
+ * @file
+ *
+ * Kernel Module Interface.
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <cstdlib>
+
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+#include "CKMod.h"
+
+#include "log.h"
+
+#define INVALID_FILE_DESCRIPTOR ((int)(-1))
+
+//------------------------------------------------------------------------------
+CKMod::CKMod(void)
+{
+ fdKMod = INVALID_FILE_DESCRIPTOR;
+}
+
+
+//------------------------------------------------------------------------------
+CKMod::~CKMod(void)
+{
+ close();
+}
+
+
+//------------------------------------------------------------------------------
+bool CKMod::isOpen(void)
+{
+ return (INVALID_FILE_DESCRIPTOR == fdKMod) ? false : true;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t CKMod::open(const char *deviceName)
+{
+ if (isOpen()) {
+ LOG_W("already open");
+ return MC_DRV_ERR_DEVICE_ALREADY_OPEN;
+ }
+
+ LOG_I(" Opening kernel module at %s.", deviceName);
+
+ // open return -1 on error, "errno" is set with details
+ int openRet = ::open(deviceName, O_RDWR);
+ if (openRet == -1) {
+ LOG_ERRNO("open");
+ return MAKE_MC_DRV_KMOD_WITH_ERRNO(errno);
+ }
+
+ fdKMod = openRet;
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+void CKMod::close(
+ void
+)
+{
+ if (isOpen()) {
+ if (::close(fdKMod) != 0) {
+ LOG_ERRNO("close");
+ } else {
+ fdKMod = INVALID_FILE_DESCRIPTOR;
+ }
+ } else {
+ LOG_W(" Kernel module device not open");
+ }
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_KERNEL
+ * @{
+ * @file
+ *
+ * Kernel Module Interface.
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef CKMOD_H_
+#define CKMOD_H_
+
+#include <stdint.h>
+#include "ClientLib/public/MobiCoreDriverApi.h"
+
+
+/**
+ * Base class for accessing a kernel module.
+ */
+class CKMod
+{
+
+protected:
+
+ int fdKMod;
+
+ /**
+ * Helper function to check if connected to kernel module.
+ */
+ bool isOpen(
+ void
+ );
+
+public:
+
+ CKMod(
+ void
+ );
+
+ virtual ~CKMod(
+ void
+ );
+
+ mcResult_t open(
+ const char *deviceName
+ );
+
+ void close(
+ void
+ );
+
+};
+
+#endif // CKMOD_H_
--- /dev/null
+# =============================================================================
+#
+# Generic TrustZone device includes
+#
+# =============================================================================
+
+# This is not a separate module.
+# All paths are relative to APP_PROJECT_PATH!
+KERNEL_PATH := Kernel/Platforms/Generic
+
+# Add new source files here
+LOCAL_SRC_FILES += $(KERNEL_PATH)/CMcKMod.cpp
+
+# Header files for components including this module
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(KERNEL_PATH)
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_KERNEL
+ * @{
+ * @file
+ *
+ * <t-base Driver Kernel Module Interface.
+ */
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <cstdlib>
+
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <cstring>
+
+#include "McTypes.h"
+#include "mc_linux.h"
+#include "mcVersionHelper.h"
+
+#include "CMcKMod.h"
+
+#include "log.h"
+
+//------------------------------------------------------------------------------
+MC_CHECK_VERSION(MCDRVMODULEAPI, 1, 1);
+
+//------------------------------------------------------------------------------
+mcResult_t CMcKMod::mapWsm(
+ uint32_t len,
+ uint32_t *pHandle,
+ addr_t *pVirtAddr,
+ uint64_t *pPhysAddr)
+{
+ int ret = 0;
+ LOG_V(" mapWsm(): len=%d", len);
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ // mapping response data is in the buffer
+ struct mc_ioctl_map mapParams = {
+ .len = len
+ };
+
+ ret = ioctl(fdKMod, MC_IO_MAP_WSM, &mapParams);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_MAP_WSM");
+ return MAKE_MC_DRV_KMOD_WITH_ERRNO(errno);
+ }
+
+ addr_t virtAddr = ::mmap(0, len, PROT_READ | PROT_WRITE, MAP_SHARED,
+ fdKMod, mapParams.phys_addr);
+ if (virtAddr == MAP_FAILED) {
+ LOG_ERRNO("mmap");
+ return MAKE_MC_DRV_KMOD_WITH_ERRNO(errno);
+ }
+
+
+ LOG_V(" mapped to %p, handle=%d, phys=0x%llX ", virtAddr,
+ mapParams.handle, mapParams.phys_addr);
+
+ if (pVirtAddr != NULL) {
+ *pVirtAddr = virtAddr;
+ }
+
+ if (pHandle != NULL) {
+ *pHandle = mapParams.handle;
+ }
+
+ if (pPhysAddr != NULL) {
+ *pPhysAddr = mapParams.phys_addr;
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t CMcKMod::mapMCI(
+ uint32_t len,
+ uint32_t *pHandle,
+ addr_t *pVirtAddr,
+ uint64_t *pPhysAddr,
+ bool *pReuse)
+{
+ LOG_I("Mapping MCI: len=%d", len);
+ // mapping response data is in the buffer
+ struct mc_ioctl_map mapParams = {
+ .len = len
+ };
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ int ret = ioctl(fdKMod, MC_IO_MAP_MCI, &mapParams);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_MAP_MCI");
+ return MAKE_MC_DRV_KMOD_WITH_ERRNO(errno);
+ }
+
+ addr_t virtAddr = ::mmap(0, len, PROT_READ | PROT_WRITE, MAP_SHARED,
+ fdKMod, 0);
+ if (virtAddr == MAP_FAILED) {
+ LOG_ERRNO("mmap");
+ return MAKE_MC_DRV_KMOD_WITH_ERRNO(errno);
+ }
+ unsigned long addr = (unsigned long)virtAddr;
+ *pReuse = mapParams.reused;
+
+ LOG_V(" MCI mapped to %p, handle=%d, phys=%p, reused=%s",
+ (void *)addr, mapParams.handle, mapParams.phys_addr,
+ mapParams.reused ? "true" : "false");
+
+ if (pVirtAddr != NULL) {
+ *pVirtAddr = (void *)addr;
+ }
+
+ if (pHandle != NULL) {
+ *pHandle = mapParams.handle;
+ }
+
+ if (pPhysAddr != NULL) {
+ *pPhysAddr = mapParams.phys_addr;
+ }
+
+ // clean memory
+ //memset(pMmapResp, 0, sizeof(*pMmapResp));
+
+ return MC_DRV_OK;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t CMcKMod::mapPersistent(
+ uint32_t len __unused,
+ uint32_t *pHandle __unused,
+ addr_t *pVirtAddr __unused,
+ addr_t *pPhysAddr __unused)
+{
+ // Not currently supported by the driver
+ LOG_E("<t-base Driver doesn't support persistent buffers");
+ return MC_DRV_ERR_NOT_IMPLEMENTED;
+}
+
+
+//------------------------------------------------------------------------------
+int CMcKMod::read(addr_t buffer, uint32_t len)
+{
+ int ret = 0;
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ ret = ::read(fdKMod, buffer, len);
+ if (ret == -1) {
+ LOG_ERRNO("read");
+ }
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+bool CMcKMod::waitSSIQ(uint32_t *pCnt)
+{
+ uint32_t cnt;
+ if (read(&cnt, sizeof(cnt)) != sizeof(cnt)) {
+ return false;
+ }
+
+ if (pCnt != NULL) {
+ *pCnt = cnt;
+ }
+
+ return true;
+}
+
+
+//------------------------------------------------------------------------------
+int CMcKMod::fcInit(uint32_t nqLength, uint32_t mcpOffset, uint32_t mcpLength)
+{
+ int ret = 0;
+
+ if (!isOpen()) {
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ // Init MC with NQ and MCP buffer addresses
+ struct mc_ioctl_init fcInitParams = {
+ .nq_length = nqLength,
+ .mcp_offset = mcpOffset,
+ .mcp_length = mcpLength
+ };
+
+ ret = ioctl(fdKMod, MC_IO_INIT, &fcInitParams);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_INIT");
+ }
+
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+int CMcKMod::fcInfo(uint32_t extInfoId, uint32_t *pState, uint32_t *pExtInfo)
+{
+ int ret = 0;
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ // Init MC with NQ and MCP buffer addresses
+ struct mc_ioctl_info fcInfoParams = {
+ .ext_info_id = extInfoId
+ };
+ ret = ioctl(fdKMod, MC_IO_INFO, &fcInfoParams);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_INFO");
+ return ret;
+ }
+
+ if (pState != NULL) {
+ *pState = fcInfoParams.state;
+ }
+
+ if (pExtInfo != NULL) {
+ *pExtInfo = fcInfoParams.ext_info;
+ }
+
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+int CMcKMod::fcYield(void)
+{
+ int ret = 0;
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ ret = ioctl(fdKMod, MC_IO_YIELD, NULL);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_YIELD");
+ LOG_E("ret = %d", ret);
+ }
+
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+int CMcKMod::fcNSIQ(void)
+{
+ int ret = 0;
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ ret = ioctl(fdKMod, MC_IO_NSIQ, NULL);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_NSIQ");
+ LOG_E("ret = %d", ret);
+ }
+
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t CMcKMod::free(uint32_t handle, addr_t buffer, uint32_t len)
+{
+ LOG_V("free(): handle=%d", handle);
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ // Even if unmap fails we still go on with our request
+ if (::munmap(buffer, len)) {
+ LOG_I("buffer = %p, len = %d", buffer, len);
+ LOG_ERRNO("mmap failed");
+ }
+
+ int ret = ioctl(fdKMod, MC_IO_FREE, handle);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_FREE");
+ return MAKE_MC_DRV_KMOD_WITH_ERRNO(errno);
+ }
+
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t CMcKMod::registerWsmL2(
+ addr_t buffer,
+ uint32_t len,
+ uint32_t pid,
+ uint32_t *pHandle,
+ uint64_t *pPhysWsmL2)
+{
+ LOG_I(" Registering virtual buffer at %p, len=%d as World Shared Memory", buffer, len);
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ struct mc_ioctl_reg_wsm params = {
+ .buffer = (uintptr_t) buffer,
+ .len = len,
+ .pid = pid
+ };
+
+ int ret = ioctl(fdKMod, MC_IO_REG_WSM, ¶ms);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_REG_WSM");
+ return MAKE_MC_DRV_KMOD_WITH_ERRNO(errno);
+ }
+
+ LOG_I(" Registered, handle=%d, L2 phys=0x%llx ", params.handle, params.table_phys);
+
+ if (pHandle != NULL) {
+ *pHandle = params.handle;
+ }
+
+ if (pPhysWsmL2 != NULL) {
+ *pPhysWsmL2 = params.table_phys;
+ }
+
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t CMcKMod::unregisterWsmL2(uint32_t handle)
+{
+ LOG_I(" Unregistering World Shared Memory with handle %d", handle);
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ int ret = ioctl(fdKMod, MC_IO_UNREG_WSM, handle);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_UNREG_WSM");
+ return MAKE_MC_DRV_KMOD_WITH_ERRNO(errno);
+ }
+
+ return MC_DRV_OK;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t CMcKMod::lockWsmL2(uint32_t handle)
+{
+ int ret = 0;
+
+ LOG_I(" Locking World Shared Memory with handle %d", handle);
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ ret = ioctl(fdKMod, MC_IO_LOCK_WSM, handle);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_LOCK_WSM");
+ LOG_E("ret = %d", ret);
+ }
+
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t CMcKMod::unlockWsmL2(uint32_t handle)
+{
+ int ret = 0;
+
+ LOG_I(" Unlocking World Shared Memory with handle %d", handle);
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ ret = ioctl(fdKMod, MC_IO_UNLOCK_WSM, handle);
+ // Failure here is not really important
+ if (ret != 0) {
+ LOG_I("ret = %d", ret);
+ }
+
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+uint64_t CMcKMod::findWsmL2(uint32_t handle, int fd)
+{
+ int ret = 0;
+
+ struct mc_ioctl_resolv_wsm wsm;
+
+ wsm.handle = handle;
+ wsm.fd = fd;
+ wsm.phys = 0;
+
+ LOG_I(" Resolving the WSM l2 for handle=%u", handle);
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return 0;
+ }
+
+ ret = ioctl(fdKMod, MC_IO_RESOLVE_WSM, &wsm);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_RESOLVE_WSM");
+ LOG_E("ret = %d", ret);
+ return 0;
+ }
+
+ return wsm.phys;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t CMcKMod::findContiguousWsm(uint32_t handle, int fd, uint64_t *phys, uint32_t *len)
+{
+ mcResult_t ret = MC_DRV_OK;
+ struct mc_ioctl_resolv_cont_wsm wsm;
+
+ wsm.handle = handle;
+ wsm.phys = 0;
+ wsm.length = 0;
+ wsm.fd = fd;
+
+ LOG_I(" Resolving the contiguous WSM l2 for handle=%u", handle);
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ ret = ioctl(fdKMod, MC_IO_RESOLVE_CONT_WSM, &wsm);
+ if (ret != 0) {
+ LOG_W("ioctl MC_IO_RESOLVE_CONT_WSM failed with \"%s\"(errno %i)", strerror(errno), errno);
+ } else {
+ *phys = wsm.phys;
+ *len = wsm.length;
+ }
+
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t CMcKMod::cleanupWsmL2(void)
+{
+ int ret = 0;
+
+ LOG_I(" Cleaning up the orphaned bulk buffers");
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ ret = ioctl(fdKMod, MC_IO_CLEAN_WSM, 0);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_CLEAN_WSM");
+ LOG_E("ret = %d", ret);
+ }
+
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t CMcKMod::setupLog(void)
+{
+ int ret = 0;
+
+ LOG_I(" Setting up the memory logging system");
+
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return MC_DRV_ERR_KMOD_NOT_OPEN;
+ }
+
+ ret = ioctl(fdKMod, MC_IO_LOG_SETUP, 0);
+ if (ret != 0) {
+ LOG_W("ioctl MC_IO_LOG_SETUP failed with \"%s\"(errno %i)", strerror(errno), errno);
+ }
+
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+bool CMcKMod::checkVersion(void)
+{
+ uint32_t version;
+ if (!isOpen()) {
+ LOG_E("no connection to kmod");
+ return false;
+ }
+
+ int ret = ioctl(fdKMod, MC_IO_VERSION, &version);
+ if (ret != 0) {
+ LOG_ERRNO("ioctl MC_IO_VERSION");
+ LOG_E("ret = %d", ret);
+ return false;
+ }
+
+ // Run-time check.
+ char *errmsg;
+ if (!checkVersionOkMCDRVMODULEAPI(version, &errmsg)) {
+ LOG_E("%s", errmsg);
+ return false;
+ }
+ LOG_I("%s", errmsg);
+
+ return true;
+}
+
+/** @} */
--- /dev/null
+/** @addtogroup MCD_MCDIMPL_DAEMON_KERNEL
+ * @{
+ * @file
+ *
+ * <t-base Driver Kernel Module Interface.
+ *
+ *
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef CMCKMOD_H_
+#define CMCKMOD_H_
+
+#include <stdint.h>
+
+#include "McTypes.h"
+#include "CKMod.h"
+
+
+/**
+ * As this is also used by the ClientLib, we do not use exceptions.
+ */
+class CMcKMod : public CKMod
+{
+public:
+ /**
+ * Map data.
+ *
+ * @param len
+ * @param pHandle
+ * @param pVirtAddr
+ * @param pPhysAddr
+ *
+ * @return 0 if all went fine
+ * @return MC_DRV_ERR_KMOD_NOT_OPEN
+ * @return MC_DRV_ERR_KERNEL_MODULE or'ed with errno<<16
+ */
+ mcResult_t mapWsm(uint32_t len,
+ uint32_t *pHandle,
+ addr_t *pVirtAddr,
+ uint64_t *pPhysAddr);
+ /**
+ * Map data.
+ *
+ * @param len
+ * @param pHandle
+ * @param pVirtAddr
+ * @param pPhysAddr
+ * @param pMciReuse [in|out] set to true [in] for reusing MCI buffer
+ * is set to true [out] if MCI buffer has been reused
+ * @return 0 if all went fine
+ * @return MC_DRV_ERR_KMOD_NOT_OPEN
+ * @return MC_DRV_ERR_KERNEL_MODULE or'ed with errno<<16
+ */
+ mcResult_t mapMCI(
+ uint32_t len,
+ uint32_t *pHandle,
+ addr_t *pVirtAddr,
+ uint64_t *pPhysAddr,
+ bool *pReuse);
+
+ /**
+ * Map persistent WSM which will not be freed up once the calling process dies.
+ */
+ mcResult_t mapPersistent(
+ uint32_t len,
+ uint32_t *pHandle,
+ addr_t *pVirtAddr,
+ addr_t *pPhysAddr);
+
+ int read(addr_t buffer, uint32_t len);
+
+ bool waitSSIQ(uint32_t *pCnt);
+
+ int fcInit(uint32_t nqLength,
+ uint32_t mcpOffset,
+ uint32_t mcpLength);
+
+ int fcInfo(
+ uint32_t extInfoId,
+ uint32_t *pState,
+ uint32_t *pExtInfo);
+
+ int fcYield(void);
+
+ int fcNSIQ(void);
+
+ mcResult_t free(uint32_t handle, addr_t buffer, uint32_t len);
+
+ mcResult_t registerWsmL2(
+ addr_t buffer,
+ uint32_t len,
+ uint32_t pid,
+ uint32_t *pHandle,
+ uint64_t *pPhysWsmL2);
+
+ mcResult_t unregisterWsmL2(uint32_t handle);
+
+ mcResult_t lockWsmL2(uint32_t handle);
+
+ mcResult_t unlockWsmL2(uint32_t handle);
+
+ mcResult_t cleanupWsmL2(void);
+
+ uint64_t findWsmL2(uint32_t handle, int fd);
+
+ mcResult_t findContiguousWsm(uint32_t handle, int fd, uint64_t *phys, uint32_t *len);
+
+ mcResult_t setupLog(void);
+
+ bool checkVersion(void);
+};
+
+typedef CMcKMod *CMcKMod_ptr;
+
+#endif // CMCKMOD_H_
--- /dev/null
+ Copyright Giesecke & Devrient GmbH 2009 - 2012
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
--- /dev/null
+MobiCore Daemon in Android
+---
+Command line
+--
+The MobiCore Daemon supports 4 command line options. It also displays them with the help option:
+
+# ./mcDriverDaemon -h
+usage: ./mcDriverDaemon [-mdsbh]
+Start MobiCore Daemon
+
+-h show this help
+-b fork to background
+-m IMAGE load mobicore from IMAGE to DDR
+-s disable daemon scheduler(default enabled)
+-r DRIVER load dyamic driver
+
+-b Forks the daemon to background
+
+# ./mcDriverDaemon -b
+
+Makes the daemon run in background and returns immediate control to the shell. No need to use shell forking with &
+
+-m Loads a mobicore image to DDR
+
+# ./mcDriverDaemon -m /data/app/mobicore.img
+
+Loads the mobicore.img to DDR and starts executing it.
+
+-s Disables NQ IRQ scheduler
+
+# ./mcDriverDaemon -s
+
+-r Loads dynamic driver at startup. The full path of the driver binary must be given, eg. /data/app/driver.drbin
+
+# ./mcDriverDaemon -r /data/app/driver.drbin
+
+Custom registry locations
+--
+Registry fallback
+
+In case of a Device wipe in Android the /data/app/mcRegistry folder will be deleted with all it's contents. To overcome
+this the daemon supports a fallback location(eg /system/app/mcRegistry): it first tries to load the trustlet
+from /data/app/mcRegistry/[uuid].tlbin and if it fails then it tries to read the trustlet from /system/app/mcRegistry/[uuid].tlb
+
+Both paths are completely configurable for the Daemon using 2 environment variables:MC_REGISTRY_PATH and MC_REGISTRY_FALLBACK_PATH
+
+For example if you want to use /data/app/mcRegistry as the default path and /system/app/mcRegistry as the fallback path:
+
+$ export MC_REGISTRY_PATH=/data/app/mcRegistry
+$ export MC_REGISTRY_FALLBACK_PATH=/system/app/mcRegistry
+$ /data/app/mcDriverDaemon
+
+Custom authtoken path
+--
+
+The authtoken file is created at provisioning and is by default located in /data/app/mcRegistry/00000.authtoken
+
+Because a device wipe could delete this file and make MobiCore unusable a new environment variable has been added to change the
+default behaviour: MC_AUTH_TOKEN_PATH
+
+$ export MC_AUTH_TOKEN_PATH=/efs
+$ /data/app/mcDriverDaemon
+
+This would change the location of the authtoken file to /efs
--- /dev/null
+# =============================================================================
+#
+# Module: MobiCore driver registry
+#
+# =============================================================================
+
+# Add new folders with header files here
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/Registry/Public
+
+# Add new source files here
+LOCAL_SRC_FILES += Registry/Registry.cpp
--- /dev/null
+/** Mobicore Driver Registry.
+ *
+ * Implements the MobiCore driver registry which maintains trustlets.
+ *
+ * @file
+ * @ingroup MCD_MCDIMPL_DAEMON_REG
+ */
+
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <assert.h>
+#include <string.h>
+#include <string>
+#include <cstring>
+#include <cstddef>
+#include <sys/mman.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libgen.h>
+
+#include "mcLoadFormat.h"
+#include "mcSpid.h"
+#include "mcVersionHelper.h"
+
+#include "PrivateRegistry.h"
+#include "MobiCoreRegistry.h"
+
+#include "uuid_attestation.h"
+
+#include "log.h"
+
+/** Maximum size of a trustlet in bytes. */
+#define MAX_TL_SIZE (1 * 1024 * 1024)
+/** Maximum size of a shared object container in bytes. */
+#define MAX_SO_CONT_SIZE (512)
+
+// Asserts expression at compile-time (to be used within a function body).
+#define ASSERT_STATIC(e) do { enum { assert_static__ = 1 / (e) }; } while (0)
+
+#define MC_REGISTRY_CONTAINER_PATH "/data/app/mcRegistry"
+#define MC_REGISTRY_DEFAULT_PATH "/system/app/mcRegistry"
+#define MC_REGISTRY_FALLBACK_PATH "/data/app/mcRegistry"
+#define AUTH_TOKEN_FILE_NAME "00000000.authtokcont"
+#define ENV_MC_AUTH_TOKEN_PATH "MC_AUTH_TOKEN_PATH"
+#define ROOT_FILE_NAME "00000000.rootcont"
+#define SP_CONT_FILE_EXT ".spcont"
+#define TL_CONT_FILE_EXT ".tlcont"
+#define DATA_CONT_FILE_EXT ".datacont"
+#define TL_BIN_FILE_EXT ".tlbin"
+#define GP_TA_BIN_FILE_EXT ".tabin"
+#define GP_TA_SPID_FILE_EXT ".spid"
+
+using namespace std;
+
+//------------------------------------------------------------------------------
+static string byteArrayToString(const void *bytes, size_t elems)
+{
+ char hx[elems * 2 + 1];
+
+ for (size_t i = 0; i < elems; i++) {
+ sprintf(&hx[i * 2], "%02x", ((uint8_t *)bytes)[i]);
+ }
+ return string(hx);
+}
+
+//------------------------------------------------------------------------------
+static string uint32ToString(uint32_t value)
+{
+ char hx[8 + 1];
+ snprintf(hx, sizeof(hx), "%08X", value);
+ string str(hx);
+ return string(str.rbegin(), str.rend());
+}
+
+//------------------------------------------------------------------------------
+static bool doesDirExist(const char *path)
+{
+ struct stat ss;
+ if (path != NULL && stat(path, &ss) == 0 && S_ISDIR(ss.st_mode)) {
+ return true;
+ }
+ return false;
+}
+
+//------------------------------------------------------------------------------
+static string getRegistryPath()
+{
+ string registryPath;
+
+ // use the default registry path.
+ registryPath = MC_REGISTRY_CONTAINER_PATH;
+ LOG_I(" Using default registry path %s", registryPath.c_str());
+
+ assert(registryPath.length() != 0);
+
+ return registryPath;
+}
+
+//------------------------------------------------------------------------------
+string getTlRegistryPath()
+{
+ string registryPath;
+
+ // First, attempt to use regular registry environment variable.
+ if (doesDirExist(MC_REGISTRY_DEFAULT_PATH)) {
+ registryPath = MC_REGISTRY_DEFAULT_PATH;
+ LOG_I(" Using MC_REGISTRY_PATH %s", registryPath.c_str());
+ } else if (doesDirExist(MC_REGISTRY_FALLBACK_PATH)) {
+ // Second, attempt to use fallback registry environment variable.
+ registryPath = MC_REGISTRY_FALLBACK_PATH;
+ LOG_I(" Using MC_REGISTRY_FALLBACK_PATH %s", registryPath.c_str());
+ }
+
+ // As a last resort, use the default registry path.
+ if (registryPath.length() == 0) {
+ registryPath = MC_REGISTRY_CONTAINER_PATH;
+ LOG_I(" Using default registry path %s", registryPath.c_str());
+ }
+
+ assert(registryPath.length() != 0);
+
+ return registryPath;
+}
+
+//------------------------------------------------------------------------------
+static string getAuthTokenFilePath()
+{
+ const char *path;
+ string authTokenPath;
+
+ // First, attempt to use regular auth token path environment variable.
+ path = getenv(ENV_MC_AUTH_TOKEN_PATH);
+ if (doesDirExist(path)) {
+ LOG_I("getAuthTokenFilePath(): Using MC_AUTH_TOKEN_PATH %s", path);
+ authTokenPath = path;
+ } else {
+ authTokenPath = getRegistryPath();
+ LOG_I("getAuthTokenFilePath(): Using path %s", authTokenPath.c_str());
+ }
+
+ return authTokenPath + "/" + AUTH_TOKEN_FILE_NAME;
+}
+
+//------------------------------------------------------------------------------
+static string getRootContFilePath()
+{
+ return getRegistryPath() + "/" + ROOT_FILE_NAME;
+}
+
+//------------------------------------------------------------------------------
+static string getSpDataPath(mcSpid_t spid)
+{
+ return getRegistryPath() + "/" + uint32ToString(spid);
+}
+
+//------------------------------------------------------------------------------
+static string getSpContFilePath(mcSpid_t spid)
+{
+ return getRegistryPath() + "/" + uint32ToString(spid) + SP_CONT_FILE_EXT;
+}
+
+//------------------------------------------------------------------------------
+static string getTlContFilePath(const mcUuid_t *uuid, const mcSpid_t spid)
+{
+ return getRegistryPath() + "/" + byteArrayToString(uuid, sizeof(*uuid))
+ + "." + uint32ToString(spid) + TL_CONT_FILE_EXT;
+}
+
+//------------------------------------------------------------------------------
+static string getTlDataPath(const mcUuid_t *uuid)
+{
+ return getRegistryPath() + "/" + byteArrayToString(uuid, sizeof(*uuid));
+}
+
+//------------------------------------------------------------------------------
+static string getTlDataFilePath(const mcUuid_t *uuid, mcPid_t pid)
+{
+ return getTlDataPath(uuid) + "/" + uint32ToString(pid.data) + DATA_CONT_FILE_EXT;
+}
+
+//------------------------------------------------------------------------------
+static string getTlBinFilePath(const mcUuid_t *uuid)
+{
+ return getTlRegistryPath() + "/" + byteArrayToString(uuid, sizeof(*uuid)) + TL_BIN_FILE_EXT;
+}
+
+//------------------------------------------------------------------------------
+static string getTABinFilePath(const mcUuid_t *uuid)
+{
+ return getTlRegistryPath() + "/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_BIN_FILE_EXT;
+}
+
+//------------------------------------------------------------------------------
+static string getTASpidFilePath(const mcUuid_t *uuid)
+{
+ return getTlRegistryPath() + "/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_SPID_FILE_EXT;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryStoreAuthToken(void *so, uint32_t size)
+{
+ if (so == NULL || size > 3 * MAX_SO_CONT_SIZE) {
+ LOG_E("mcRegistry store So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ const string &authTokenFilePath = getAuthTokenFilePath();
+ LOG_I("store AuthToken: %s", authTokenFilePath.c_str());
+
+ FILE *fs = fopen(authTokenFilePath.c_str(), "wb");
+ if (!fs) {
+ LOG_E("mcRegistry store So.Soc failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ fseek(fs, 0, SEEK_SET);
+ fwrite((char *)so, 1, size, fs);
+ fflush(fs);
+ fclose(fs);
+
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryReadAuthToken(mcSoAuthTokenCont_t *so)
+{
+ if (NULL == so) {
+ LOG_E("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ const string &authTokenFilePath = getAuthTokenFilePath();
+ LOG_I("read AuthToken: %s", authTokenFilePath.c_str());
+
+ FILE *fs = fopen(authTokenFilePath.c_str(), "rb");
+ if (!fs) {
+ LOG_W("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ fseek(fs, 0, SEEK_END);
+ int32_t filesize = ftell(fs);
+ if (sizeof(mcSoAuthTokenCont_t) != filesize) {
+ fclose(fs);
+ LOG_W("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_OUT_OF_RESOURCES);
+ return MC_DRV_ERR_OUT_OF_RESOURCES;
+ }
+ fseek(fs, 0, SEEK_SET);
+ if (fread((char *)so, 1, sizeof(mcSoAuthTokenCont_t), fs) !=
+ sizeof(mcSoAuthTokenCont_t))
+ {
+ fclose(fs);
+ LOG_W("mcRegistry read So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ fclose(fs);
+
+ return MC_DRV_OK;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryDeleteAuthToken(void)
+{
+ if (remove(getAuthTokenFilePath().c_str())) {
+ LOG_ERRNO("Delete Auth token file!");
+ return MC_DRV_ERR_UNKNOWN;
+ } else
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryStoreRoot(void *so, uint32_t size)
+{
+ if (so == NULL || size > 3 * MAX_SO_CONT_SIZE) {
+ LOG_E("mcRegistry store So.Root failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+
+ const string &rootContFilePath = getRootContFilePath();
+ LOG_I("store Root: %s", rootContFilePath.c_str());
+
+ FILE *fs = fopen(rootContFilePath.c_str(), "wb");
+ if (!fs) {
+ LOG_E("mcRegistry store So.Root failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ fseek(fs, 0, SEEK_SET);
+ fwrite((char *)so, 1, size, fs);
+ fflush(fs);
+ fclose(fs);
+
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryReadRoot(void *so, uint32_t *size)
+{
+ const string &rootContFilePath = getRootContFilePath();
+ size_t readBytes;
+
+ if (so == NULL) {
+ LOG_E("mcRegistry read So.Root failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ LOG_I(" Opening %s", rootContFilePath.c_str());
+
+ FILE *fs = fopen(rootContFilePath.c_str(), "rb");
+ if (!fs) {
+ LOG_W("mcRegistry read So.Root failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ readBytes = fread((char *)so, 1, *size, fs);
+ fclose(fs);
+
+ if (readBytes > 0) {
+ *size = readBytes;
+ return MC_DRV_OK;
+ } else {
+ LOG_E("mcRegistry read So.Root failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryStoreSp(mcSpid_t spid, void *so, uint32_t size)
+{
+ if ((spid == 0) || (so == NULL) || size > 3 * MAX_SO_CONT_SIZE) {
+ LOG_E("mcRegistry store So.Sp(SpId) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+
+ const string &spContFilePath = getSpContFilePath(spid);
+ LOG_I("store SP: %s", spContFilePath.c_str());
+
+ FILE *fs = fopen(spContFilePath.c_str(), "wb");
+ if (!fs) {
+ LOG_E("mcRegistry store So.Sp(SpId) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ fseek(fs, 0, SEEK_SET);
+ fwrite((char *)so, 1, size, fs);
+ fflush(fs);
+ fclose(fs);
+
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryReadSp(mcSpid_t spid, void *so, uint32_t *size)
+{
+ const string &spContFilePath = getSpContFilePath(spid);
+ size_t readBytes;
+ if ((spid == 0) || (so == NULL)) {
+ LOG_E("mcRegistry read So.Sp(SpId=0x%x) failed", spid);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ LOG_I(" Reading %s", spContFilePath.c_str());
+
+ FILE *fs = fopen(spContFilePath.c_str(), "rb");
+ if (!fs) {
+ LOG_E("mcRegistry read So.Sp(SpId) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ readBytes = fread((char *)so, 1, *size, fs);
+ fclose(fs);
+
+ if (readBytes > 0) {
+ *size = readBytes;
+ return MC_DRV_OK;
+ } else {
+ LOG_E("mcRegistry read So.Sp(SpId) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t size)
+{
+ if ((uuid == NULL) || (so == NULL) || size > 3 * MAX_SO_CONT_SIZE) {
+ LOG_E("mcRegistry store So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+
+ const string &tlContFilePath = getTlContFilePath(uuid, spid);
+ LOG_I("store TLc: %s", tlContFilePath.c_str());
+
+ FILE *fs = fopen(tlContFilePath.c_str(), "wb");
+ if (!fs) {
+ LOG_E("mcRegistry store So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ fseek(fs, 0, SEEK_SET);
+ fwrite((char *)so, 1, size, fs);
+ fflush(fs);
+ fclose(fs);
+
+ return MC_DRV_OK;
+}
+
+static uint32_t getAsUint32BE(
+ void *pValueUnaligned
+)
+{
+ uint8_t *p = (uint8_t *)pValueUnaligned;
+ uint32_t val = p[3] | (p[2] << 8) | (p[1] << 16) | (p[0] << 24);
+ return val;
+}
+
+mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, void *blob, uint32_t size)
+{
+
+ LOG_I("mcRegistryStoreTABlob started");
+
+ // Check blob size
+ if (size < sizeof(mclfHeaderV24_t)) {
+ LOG_E("RegistryStoreTABlob failed - TA blob length is less then header size");
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+
+ mclfHeaderV24_t *header24 = (mclfHeaderV24_t *)blob;
+ mclfHeaderV2_t *header20 = (mclfHeaderV2_t *)blob;
+
+ // Check header version
+ if (header20->intro.version < MC_MAKE_VERSION(2, 4)) {
+ LOG_E("RegistryStoreTABlob failed - TA blob header version is less than 2.4");
+ return MC_DRV_ERR_TA_HEADER_ERROR;
+ }
+
+ //Check GP version
+ if (header24->gp_level != 1) {
+ LOG_E("RegistryStoreTABlob failed - TA blob header gp_level is not equal to 1");
+ return MC_DRV_ERR_TA_HEADER_ERROR;
+ }
+
+ TEEC_UUID uuid;
+ switch (header20->serviceType) {
+ case SERVICE_TYPE_SYSTEM_TRUSTLET: {
+ // Check spid
+ if (spid != MC_SPID_SYSTEM) {
+ LOG_E("RegistryStoreTABlob failed - SPID is not equal to %d for System TA", spid);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ memcpy(&uuid, &header20->uuid, sizeof(mcUuid_t));
+ break;
+ }
+ case SERVICE_TYPE_SP_TRUSTLET: {
+ // Check spid
+ if (spid >= MC_SPID_SYSTEM) {
+ LOG_E("RegistryStoreTABlob failed - SPID is equal to %u ", spid);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+
+ uuid_attestation *pUa = (uuid_attestation *) & ((uint8_t *)blob)[header24->attestationOffset];
+ // Check attestation size
+ if ((header24->attestationOffset > size) && (header24->attestationOffset + getAsUint32BE(&pUa->size) > size)) {
+ LOG_E("RegistryStoreTABlob failed - Attestation size is not correct");
+ return MC_DRV_ERR_TA_HEADER_ERROR;
+ }
+
+ // Check attestation size
+ if (getAsUint32BE(&pUa->size) < sizeof(uuid_attestation)) {
+ LOG_E("RegistryStoreTABlob failed - Attestation size is equal to %d and is less then %d", getAsUint32BE(&pUa->size), sizeof(uuid_attestation));
+ return MC_DRV_ERR_TA_ATTESTATION_ERROR;
+ }
+
+ // Check magic word
+ if (memcmp(pUa->magic, MAGIC, AT_MAGIC_SIZE)) {
+ LOG_E("RegistryStoreTABlob failed - Attestation magic word is not correct");
+ return MC_DRV_ERR_TA_ATTESTATION_ERROR;
+ }
+
+ // Check version
+ if (getAsUint32BE(&pUa->version) != AT_VERSION) {
+ LOG_E("RegistryStoreTABlob failed - Attestation version is equal to %08X. It has to be equal to %08X", getAsUint32BE(&pUa->version), AT_VERSION);
+ return MC_DRV_ERR_TA_ATTESTATION_ERROR;
+ }
+
+ memcpy(&uuid, &pUa->uuid, sizeof(mcUuid_t));
+ break;
+ }
+ default: {
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ }
+ const string tlBinFilePath = getTABinFilePath((mcUuid_t *)&uuid);
+
+ LOG_I("Store TA blob at: %s", tlBinFilePath.c_str());
+
+ FILE *fs = fopen(tlBinFilePath.c_str(), "wb");
+ if (!fs) {
+ LOG_E("RegistryStoreTABlob failed - TA blob file open error: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ fseek(fs, 0, SEEK_SET);
+ fwrite(blob, 1, size, fs);
+ fflush(fs);
+ fclose(fs);
+
+ if (header20->serviceType == SERVICE_TYPE_SP_TRUSTLET) {
+ const string taspidFilePath = getTASpidFilePath((mcUuid_t *)&uuid);
+
+ LOG_I("Store spid file at: %s", taspidFilePath.c_str());
+
+ FILE *fs = fopen(taspidFilePath.c_str(), "wb");
+ if (!fs) {
+ //TODO: shouldn't we delete TA blob file ?
+ LOG_E("RegistryStoreTABlob failed - TA blob file open error: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ fseek(fs, 0, SEEK_SET);
+ fwrite(&spid, 1, sizeof(mcSpid_t), fs);
+ fflush(fs);
+ fclose(fs);
+ }
+ return MC_DRV_OK;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryReadTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t *size)
+{
+ if ((uuid == NULL) || (so == NULL)) {
+ LOG_E("mcRegistry read So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ size_t readBytes;
+ const string &tlContFilePath = getTlContFilePath(uuid, spid);
+ LOG_I("read TLc: %s", tlContFilePath.c_str());
+
+ FILE *fs = fopen(tlContFilePath.c_str(), "rb");
+ if (!fs) {
+ LOG_E("mcRegistry read So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ fseek(fs, 0, SEEK_SET);
+ readBytes = fread((char *)so, 1, *size, fs);
+ fclose(fs);
+
+ if (readBytes > 0) {
+ *size = readBytes;
+ return MC_DRV_OK;
+ } else {
+ LOG_E("mcRegistry read So.TrustletCont(uuid) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryStoreData(void *so, uint32_t size)
+{
+ mcSoDataCont_t *dataCont = (mcSoDataCont_t *)so;
+
+ if (dataCont == NULL || size != sizeof(mcSoDataCont_t)) {
+ LOG_E("mcRegistry store So.Data failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ string pathname, filename;
+
+ switch (dataCont->cont.type) {
+ case CONT_TYPE_SPDATA:
+ LOG_E("SPDATA not supported");
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ break;
+ case CONT_TYPE_TLDATA:
+ pathname = getTlDataPath(&dataCont->cont.uuid);
+ filename = getTlDataFilePath(&dataCont->cont.uuid, dataCont->cont.pid);
+ break;
+ default:
+ LOG_E("mcRegistry store So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ if (mkdir(pathname.c_str(), 0777) < 0)
+ {
+ LOG_E("mcRegistry store So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+
+ LOG_I("store DT: %s", filename.c_str());
+
+ FILE *fs = fopen(filename.c_str(), "wb");
+ if (!fs) {
+ LOG_E("mcRegistry store So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ fseek(fs, 0, SEEK_SET);
+ fwrite((char *)dataCont, 1, MC_SO_SIZE(dataCont->soHeader.plainLen, dataCont->soHeader.encryptedLen), fs);
+ fflush(fs);
+ fclose(fs);
+
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryReadData(uint32_t context, const mcCid_t *cid, mcPid_t pid __unused,
+ mcSoDataCont_t *so, uint32_t maxLen)
+{
+
+ if ((NULL == cid) || (NULL == so)) {
+ LOG_E("mcRegistry read So.Data failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ string filename;
+ switch (context) {
+ case 0:
+ LOG_E("SPDATA not supported");
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ break;
+ case 1:
+ filename = getTlDataFilePath(&so->cont.uuid, so->cont.pid);
+ break;
+ default:
+ LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ LOG_I("read DT: %s", filename.c_str());
+
+ FILE *fs = fopen(filename.c_str(), "rb");
+ if (!fs) {
+ LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_DEVICE_FILE);
+ return MC_DRV_ERR_INVALID_DEVICE_FILE;
+ }
+ fseek(fs, 0, SEEK_END);
+ uint32_t filesize = ftell(fs);
+ if (maxLen < filesize) {
+ fclose(fs);
+ LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_OUT_OF_RESOURCES);
+ return MC_DRV_ERR_OUT_OF_RESOURCES;
+ }
+ fseek(fs, 0, SEEK_SET);
+ char *p = (char *) so;
+ if (fread(p, 1, sizeof(mcSoHeader_t), fs) != sizeof(mcSoHeader_t))
+ {
+ fclose(fs);
+ LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ p += sizeof(mcSoHeader_t);
+ if (fread(p, 1, MC_SO_SIZE(so->soHeader.plainLen,
+ so->soHeader.encryptedLen)
+ - sizeof(mcSoHeader_t), fs) !=
+ MC_SO_SIZE(so->soHeader.plainLen, so->soHeader.encryptedLen)
+ - sizeof(mcSoHeader_t))
+ {
+ fclose(fs);
+ LOG_E("mcRegistry read So.Data(cid/pid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ fclose(fs);
+
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+static size_t getFileContent(
+ const char *pPath,
+ uint8_t **ppContent)
+{
+ FILE *pStream;
+ long filesize;
+ uint8_t *content = NULL;
+
+ /* Open the file */
+ pStream = fopen(pPath, "rb");
+ if (pStream == NULL) {
+ LOG_E("Error: Cannot open file: %s.", pPath);
+ return 0;
+ }
+
+ if (fseek(pStream, 0L, SEEK_END) != 0) {
+ LOG_E("Error: Cannot read file: %s.", pPath);
+ goto error;
+ }
+
+ filesize = ftell(pStream);
+ if (filesize < 0) {
+ LOG_E("Error: Cannot get the file size: %s.", pPath);
+ goto error;
+ }
+
+ if (filesize == 0) {
+ LOG_E("Error: Empty file: %s.", pPath);
+ goto error;
+ }
+
+ /* Set the file pointer at the beginning of the file */
+ if (fseek(pStream, 0L, SEEK_SET) != 0) {
+ LOG_E("Error: Cannot read file: %s.", pPath);
+ goto error;
+ }
+
+ /* Allocate a buffer for the content */
+ content = (uint8_t *)malloc(filesize);
+ if (content == NULL) {
+ LOG_E("Error: Cannot read file: Out of memory.");
+ goto error;
+ }
+
+ /* Read data from the file into the buffer */
+ if (fread(content, (size_t)filesize, 1, pStream) != 1) {
+ LOG_E("Error: Cannot read file: %s.", pPath);
+ goto error;
+ }
+
+ /* Close the file */
+ fclose(pStream);
+ *ppContent = content;
+
+ /* Return number of bytes read */
+ return (size_t)filesize;
+
+error:
+ if (content != NULL) {
+ free(content);
+ }
+ fclose(pStream);
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+static bool mcCheckUuid(const mcUuid_t *uuid, const char *filename)
+{
+ uint8_t *pTAData = NULL;
+ uint32_t nTASize;
+ bool res;
+
+ nTASize = getFileContent(filename, &pTAData);
+ if (nTASize == 0) {
+ LOG_E("err: Trusted Application not found.");
+ return false;
+ }
+
+ // Check blob size
+ if (nTASize < sizeof(mclfHeaderV24_t)) {
+ free(pTAData);
+ LOG_E("RegistryStoreTABlob failed - TA blob length is less then header size");
+ return false;
+ }
+
+ mclfHeaderV2_t *header20 = (mclfHeaderV2_t *)pTAData;
+
+ // Check header version
+ if (header20->intro.version < MC_MAKE_VERSION(2, 4)) {
+ free(pTAData);
+ LOG_E("RegistryStoreTABlob failed - TA blob header version is less than 2.4");
+ return false;
+ }
+
+ // Check blob size
+ if (memcmp(uuid, &header20->uuid, sizeof(mcUuid_t)) == 0) {
+ res = true;
+ } else {
+ res = false;
+ }
+
+ free(pTAData);
+
+ return res;
+}
+
+//this function deletes all the files owned by a GP TA and stored in the tbase secure storage dir.
+//then it deletes GP TA folder.
+static int CleanupGPTAStorage(const char *basename)
+{
+ DIR *dp;
+ struct dirent *de;
+ int e;
+ string TAPath = getTlRegistryPath()+"/TbStorage/"+ basename;
+
+ if (NULL != (dp = opendir(TAPath.c_str()))) {
+ while (NULL != (de = readdir(dp))) {
+ if (de->d_name[0] != '.') {
+ string dname = TAPath + "/" + string (de->d_name);
+ LOG_I("delete DT: %s", dname.c_str());
+ if (0 != (e = remove(dname.c_str()))) {
+ LOG_E("remove UUID-files %s failed! error: %d", dname.c_str(), e);
+ }
+ }
+ }
+ if (dp) {
+ closedir(dp);
+ }
+ LOG_I("delete dir: %s", TAPath.c_str());
+ if (0 != (e = rmdir(TAPath.c_str()))) {
+ LOG_E("remove UUID-dir failed! errno: %d", e);
+ return e;
+ }
+ }
+ return MC_DRV_OK;
+}
+
+static void deleteSPTA(const mcUuid_t *uuid, const mcSpid_t spid, bool checkUuid)
+{
+ DIR *dp;
+ struct dirent *de;
+ int e;
+
+ // Delete TABIN and SPID files - we loop searching required spid file
+ string pathname = getRegistryPath();
+ if (NULL != (dp = opendir(pathname.c_str()))) {
+ while (NULL != (de = readdir(dp))) {
+ string spidFile;
+ string tabinFile;
+ string tabinUuid;
+ size_t pch_dot, pch_slash;
+ spidFile = pathname + '/' + string(de->d_name);
+ pch_dot = spidFile.find_last_of('.');
+ if (pch_dot == string::npos) continue;
+ pch_slash = spidFile.find_last_of('/');
+ if ((pch_slash != string::npos) && (pch_slash > pch_dot)) continue;
+ if (spidFile.substr(pch_dot).compare(GP_TA_SPID_FILE_EXT) != 0) continue;
+
+ mcSpid_t curSpid = 0;
+
+ int fd = open(spidFile.c_str(), O_RDONLY);
+ if (fd != -1) {
+ if (read(fd, &curSpid, sizeof(mcSpid_t))!=sizeof(mcSpid_t)) {
+ curSpid = 0;
+ }
+ close(fd);
+ }
+ if (spid == curSpid) {
+ tabinFile = spidFile.substr(0, pch_dot) + GP_TA_BIN_FILE_EXT;
+ if ((!checkUuid)||(mcCheckUuid(uuid, tabinFile.c_str()))) {
+ tabinUuid = spidFile.substr(0, pch_dot);
+ if (0 != (e = CleanupGPTAStorage(tabinUuid.c_str()))){
+ LOG_E("cleanup TA Storage dir failed! errno: %d", e);
+ //return MC_DRV_ERR_UNKNOWN;
+ }
+ if (0 != (e = remove(tabinFile.c_str()))) {
+ LOG_E("remove TA file failed! errno: %d", e);
+ //return MC_DRV_ERR_UNKNOWN;
+ }
+ if (0 != (e = remove(spidFile.c_str()))) {
+ LOG_E("remove SPID file failed! errno: %d", e);
+ //return MC_DRV_ERR_UNKNOWN;
+ }
+ if (checkUuid) break;
+ }
+ }
+ }
+ if (dp) {
+ closedir(dp);
+ }
+
+ }
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryCleanupTrustlet(const mcUuid_t *uuid, const mcSpid_t spid)
+{
+ DIR *dp;
+ struct dirent *de;
+ int e;
+
+ if (NULL == uuid) {
+ LOG_E("mcRegistry cleanupTrustlet(uuid) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+
+ // Delete all TA related data
+ string pathname = getTlDataPath(uuid);
+ if (NULL != (dp = opendir(pathname.c_str()))) {
+ while (NULL != (de = readdir(dp))) {
+ if (de->d_name[0] != '.') {
+ string dname = pathname + "/" + string (de->d_name);
+ LOG_I("delete DT: %s", dname.c_str());
+ if (0 != (e = remove(dname.c_str()))) {
+ LOG_E("remove UUID-data %s failed! error: %d", dname.c_str(), e);
+ }
+ }
+ }
+ if (dp) {
+ closedir(dp);
+ }
+ LOG_I("delete dir: %s", pathname.c_str());
+ if (0 != (e = rmdir(pathname.c_str()))) {
+ LOG_E("remove UUID-dir failed! errno: %d", e);
+ return MC_DRV_ERR_UNKNOWN;
+ }
+ }
+
+ // Delete TA binary with the name uuid.tlbin
+ string tlBinFilePath = getTlBinFilePath(uuid);
+ LOG_I("delete Tlb: %s", tlBinFilePath.c_str());
+ if (0 != (e = remove(tlBinFilePath.c_str()))) {
+ LOG_E("remove Tlb failed! errno: %d", e);
+// return MC_DRV_ERR_UNKNOWN; // a trustlet-binary must not be present ! (registered but not usable)
+ }
+
+ // Delete TABIN and SPID files - we loop searching required spid file
+ deleteSPTA(uuid,spid,true);
+
+ string tlContFilePath = getTlContFilePath(uuid, spid);
+ LOG_I("delete Tlc: %s", tlContFilePath.c_str());
+ if (0 != (e = remove(tlContFilePath.c_str()))) {
+ LOG_E("remove Tlc failed! errno: %d", e);
+ return MC_DRV_ERR_UNKNOWN;
+ }
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryCleanupSp(mcSpid_t spid)
+{
+ DIR *dp;
+ struct dirent *de;
+ mcResult_t ret;
+ mcSoSpCont_t data;
+ uint32_t i, len;
+ int e;
+
+ if (0 == spid) {
+ LOG_E("mcRegistry cleanupSP(SpId) failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+ len = sizeof(mcSoSpCont_t);
+ ret = mcRegistryReadSp(spid, &data, &len);
+ if (MC_DRV_OK != ret || len != sizeof(mcSoSpCont_t)) {
+ LOG_E("read SP->UUID aborted! Return code: %d", ret);
+ return ret;
+ }
+ for (i = 0; (i < MC_CONT_CHILDREN_COUNT) && (ret == MC_DRV_OK); i++) {
+ if (0 != strncmp((const char *) & (data.cont.children[i]), (const char *)&MC_UUID_FREE, sizeof(mcUuid_t))) {
+ ret = mcRegistryCleanupTrustlet(&(data.cont.children[i]), spid);
+ }
+ }
+ if (MC_DRV_OK != ret) {
+ LOG_E("delete SP->UUID failed! Return code: %d", ret);
+ return ret;
+ }
+
+ // Delete remaining TABIN and SPID files
+ deleteSPTA(NULL,spid,false);
+
+ string pathname = getSpDataPath(spid);
+
+ if (NULL != (dp = opendir(pathname.c_str()))) {
+ while (NULL != (de = readdir(dp))) {
+ if (de->d_name[0] != '.') {
+ string dname = pathname + "/" + string (de->d_name);
+ LOG_I("delete DT: %s", dname.c_str());
+ if (0 != (e = remove(dname.c_str()))) {
+ LOG_E("remove SPID-data %s failed! error: %d", dname.c_str(), e);
+ }
+ }
+ }
+ if (dp) {
+ closedir(dp);
+ }
+ LOG_I("delete dir: %s", pathname.c_str());
+ if (0 != (e = rmdir(pathname.c_str()))) {
+ LOG_E("remove SPID-dir failed! error: %d", e);
+ return MC_DRV_ERR_UNKNOWN;
+ }
+ }
+ string spContFilePath = getSpContFilePath(spid);
+ LOG_I("delete Sp: %s", spContFilePath.c_str());
+ if (0 != (e = remove(spContFilePath.c_str()))) {
+ LOG_E("remove SP failed! error: %d", e);
+ return MC_DRV_ERR_UNKNOWN;
+ }
+ return MC_DRV_OK;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryCleanupRoot(void)
+{
+ mcResult_t ret;
+ mcSoRootCont_t data;
+ uint32_t i, len;
+ int e;
+ len = sizeof(mcSoRootCont_t);
+ ret = mcRegistryReadRoot(&data, &len);
+ if (MC_DRV_OK != ret || len != sizeof(mcSoRootCont_t)) {
+ LOG_E("read Root aborted! Return code: %d", ret);
+ return ret;
+ }
+ for (i = 0; (i < MC_CONT_CHILDREN_COUNT) && (ret == MC_DRV_OK); i++) {
+ mcSpid_t spid = data.cont.children[i];
+ if (spid != MC_SPID_FREE) {
+ ret = mcRegistryCleanupSp(spid);
+ if (MC_DRV_OK != ret) {
+ LOG_E("Cleanup SP failed! Return code: %d", ret);
+ return ret;
+ }
+ }
+ }
+
+ string rootContFilePath = getRootContFilePath();
+ LOG_I("Delete root: %s", rootContFilePath.c_str());
+ if (0 != (e = remove(rootContFilePath.c_str()))) {
+ LOG_E("Delete root failed! error: %d", e);
+ return MC_DRV_ERR_UNKNOWN;
+ }
+ return MC_DRV_OK;
+}
+
+//------------------------------------------------------------------------------
+regObject_t *mcRegistryMemGetServiceBlob(mcSpid_t spid, void *trustlet, uint32_t tlSize)
+{
+ regObject_t *regobj = NULL;
+
+ // Ensure that a UUID is provided.
+ if (NULL == trustlet) {
+ LOG_E("No trustlet buffer given");
+ return NULL;
+ }
+
+ // Check service blob size.
+ if (tlSize > MAX_TL_SIZE ) {
+ LOG_E("mcRegistryMemGetServiceBlob() failed: service blob too big: %d", tlSize);
+ return NULL;
+ }
+
+ mclfIntro_t *pIntro = (mclfIntro_t *)trustlet;
+ // Check TL magic value.
+ if (pIntro->magic != MC_SERVICE_HEADER_MAGIC_BE) {
+ LOG_E("mcRegistryMemGetServiceBlob() failed: wrong header magic value: %d", pIntro->magic);
+ return NULL;
+ }
+
+ // Get service type.
+ mclfHeaderV2_t *pHeader = (mclfHeaderV2_t *)trustlet;
+#ifndef NDEBUG
+ {
+ const char *service_types[] = {
+ "illegal", "Driver", "Trustlet", "System Trustlet"
+ };
+ int serviceType_safe = pHeader->serviceType > SERVICE_TYPE_SYSTEM_TRUSTLET ? SERVICE_TYPE_ILLEGAL : pHeader->serviceType;
+ LOG_I(" Service is a %s (service type %d)", service_types[serviceType_safe], pHeader->serviceType);
+ }
+#endif
+
+ LOG_I(" Trustlet text %u data %u ", pHeader->text.len, pHeader->data.len);
+
+ // If loadable driver or system trustlet.
+ if (pHeader->serviceType == SERVICE_TYPE_DRIVER || pHeader->serviceType == SERVICE_TYPE_SYSTEM_TRUSTLET) {
+ // Take trustlet blob 'as is'.
+ if (NULL == (regobj = (regObject_t *) (malloc(sizeof(regObject_t) + tlSize)))) {
+ LOG_E("mcRegistryMemGetServiceBlob() failed: Out of memory");
+ return NULL;
+ }
+ regobj->len = tlSize;
+ regobj->tlStartOffset = 0;
+ memcpy((char *)regobj->value, trustlet, tlSize);
+ // If user trustlet.
+ } else if (pHeader->serviceType == SERVICE_TYPE_SP_TRUSTLET) {
+ // Take trustlet blob and append root, sp, and tl container.
+ size_t regObjValueSize = tlSize + sizeof(mcBlobLenInfo_t) + 3 * MAX_SO_CONT_SIZE;
+
+ // Prepare registry object.
+ if (NULL == (regobj = (regObject_t *) malloc(sizeof(regObject_t) + regObjValueSize))) {
+ LOG_E("mcRegistryMemGetServiceBlob() failed: Out of memory");
+ return NULL;
+ }
+ regobj->len = regObjValueSize;
+ regobj->tlStartOffset = sizeof(mcBlobLenInfo_t);
+ uint8_t *p = regobj->value;
+
+ // Reserve space for the blob length structure
+ mcBlobLenInfo_ptr lenInfo = (mcBlobLenInfo_ptr)p;
+ lenInfo->magic = MC_TLBLOBLEN_MAGIC;
+ p += sizeof(mcBlobLenInfo_t);
+ // Fill in trustlet blob after the len info
+ memcpy(p, trustlet, tlSize);
+ p += tlSize;
+
+ // Final registry object value looks like this:
+ //
+ // +---------------+---------------------------+-----------+---------+---------+
+ // | Blob Len Info | TL-Header TL-Code TL-Data | Root Cont | SP Cont | TL Cont |
+ // +---------------+---------------------------+-----------+-------------------+
+ // /------ Trustlet BLOB ------/
+ //
+ // /------------------ regobj->header.len -------------------------------------/
+
+ // start at the end of the trustlet blob
+ mcResult_t ret;
+ do {
+ uint32_t soTltContSize = MAX_SO_CONT_SIZE;
+ uint32_t len;
+
+ // Fill in root container.
+ len = sizeof(mcSoRootCont_t);
+ if (MC_DRV_OK != (ret = mcRegistryReadRoot(p, &len))) {
+ break;
+ }
+ lenInfo->rootContBlobSize = len;
+ p += len;
+
+ // Fill in SP container.
+ len = sizeof(mcSoSpCont_t);
+ if (MC_DRV_OK != (ret = mcRegistryReadSp(spid, p, &len))) {
+ break;
+ }
+ lenInfo->spContBlobSize = len;
+ p += len;
+
+ // Fill in TLT Container
+ // We know exactly how much space is left in the buffer
+ soTltContSize = regObjValueSize - tlSize + sizeof(mcBlobLenInfo_t)
+ - lenInfo->spContBlobSize - lenInfo->rootContBlobSize;
+ if (MC_DRV_OK != (ret = mcRegistryReadTrustletCon(&pHeader->uuid, spid, p, &soTltContSize))) {
+ break;
+ }
+ lenInfo->tlContBlobSize = soTltContSize;
+ LOG_I(" Trustlet container %u bytes loaded", soTltContSize);
+ // Depending on the trustlet container size we decide which structure to use
+ // Unfortunate design but it should have to do for now
+ if (soTltContSize == sizeof(mcSoTltCont_2_0_t)) {
+ LOG_I(" Using 2.0 trustlet container");
+ } else if (soTltContSize == sizeof(mcSoTltCont_2_1_t)) {
+ LOG_I(" Using 2.1 trustlet container");
+ } else {
+ LOG_E("Trustlet container has unknown size");
+ break;
+ }
+ } while (false);
+
+ if (MC_DRV_OK != ret) {
+ LOG_E("mcRegistryMemGetServiceBlob() failed: Error code: %d", ret);
+ free(regobj);
+ return NULL;
+ }
+ // Now we know the sizes for all containers so set the correct size
+ regobj->len = sizeof(mcBlobLenInfo_t) + tlSize +
+ lenInfo->rootContBlobSize +
+ lenInfo->spContBlobSize +
+ lenInfo->tlContBlobSize;
+ // Any other service type.
+ } else {
+ LOG_E("mcRegistryMemGetServiceBlob() failed: Unsupported service type %u", pHeader->serviceType);
+ }
+ return regobj;
+}
+
+
+//------------------------------------------------------------------------------
+regObject_t *mcRegistryFileGetServiceBlob(const char *trustlet, mcSpid_t spid)
+{
+ struct stat sb;
+ regObject_t *regobj = NULL;
+ void *buffer;
+
+ // Ensure that a file name is provided.
+ if (trustlet == NULL) {
+ LOG_E("No file given");
+ return NULL;
+ }
+
+ int fd = open(trustlet, O_RDONLY);
+ if (fd == -1) {
+ LOG_E("Cannot open %s", trustlet);
+ return NULL;
+ }
+
+ if (fstat(fd, &sb) == -1) {
+ LOG_E("mcRegistryFileGetServiceBlob() failed: Cound't get file size");
+ goto error;
+ }
+
+ buffer = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (buffer == MAP_FAILED) {
+ LOG_E("mcRegistryFileGetServiceBlob(): Failed to map file to memory");
+ goto error;
+ }
+
+ regobj = mcRegistryMemGetServiceBlob(spid, buffer, sb.st_size);
+
+ // We don't actually care if either of them fails but should still print warnings
+ if (munmap(buffer, sb.st_size)) {
+ LOG_E("mcRegistryFileGetServiceBlob(): Failed to unmap memory");
+ }
+
+error:
+ if (close(fd)) {
+ LOG_E("mcRegistryFileGetServiceBlob(): Failed to close file %s", trustlet);
+ }
+
+ return regobj;
+}
+
+
+//------------------------------------------------------------------------------
+regObject_t *mcRegistryGetServiceBlob(const mcUuid_t *uuid, bool isGpUuid)
+{
+ // Ensure that a UUID is provided.
+ if (NULL == uuid) {
+ LOG_E("No UUID given");
+ return NULL;
+ }
+
+ // Open service blob file.
+ string tlBinFilePath;
+ if (isGpUuid) {
+ tlBinFilePath = getTABinFilePath(uuid);
+ } else {
+ tlBinFilePath = getTlBinFilePath(uuid);
+ }
+ LOG_I("Loading %s", tlBinFilePath.c_str());
+
+ mcSpid_t spid = 0;
+ if (isGpUuid) {
+ string taspidFilePath = getTASpidFilePath(uuid);
+ int fd = open(taspidFilePath.c_str(), O_RDONLY);
+ if (fd == -1) {
+ // This can be ok for System TAs
+ //LOG_ERRNO("open");
+ //LOG_E("Cannot open %s", taspidFilePath.c_str());
+ //return NULL;
+ } else {
+ if (read(fd, &spid, sizeof(mcSpid_t))!=sizeof(mcSpid_t)) {
+ close(fd);
+ return NULL;
+ }
+ close(fd);
+ }
+ }
+
+ return mcRegistryFileGetServiceBlob(tlBinFilePath.c_str(), spid);
+}
+
+//------------------------------------------------------------------------------
+regObject_t *mcRegistryGetDriverBlob(const char *filename)
+{
+ regObject_t *regobj = mcRegistryFileGetServiceBlob(filename, 0);
+
+ if (regobj == NULL) {
+ LOG_E("mcRegistryGetDriverBlob() failed");
+ return NULL;
+ }
+
+ // Get service type.
+ mclfHeaderV2_t *pHeader = (mclfHeaderV2_t *)regobj->value;
+
+ // If file is not a driver we are not interested
+ if (pHeader->serviceType != SERVICE_TYPE_DRIVER) {
+ LOG_E("mcRegistryGetDriverBlob() failed: Unsupported service type %u", pHeader->serviceType);
+ pHeader = NULL;
+ free(regobj);
+ regobj = NULL;
+ }
+
+ return regobj;
+}
+
+/** @} */
--- /dev/null
+/**
+ * @addtogroup MCD_MCDIMPL_DAEMON_REG
+ * @{
+ * G&D MobiCore Registry Private implementation
+ *
+ * @file
+ * Mobicore Driver Registry.
+ */
+
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef MOBICORE_REGISTRY_H_
+#define MOBICORE_REGISTRY_H_
+
+#include "MobiCoreDriverApi.h"
+#include "mcContainer.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /**
+ * Registry object.
+ */
+ typedef struct {
+ uint32_t len;
+ uint32_t tlStartOffset;
+ uint8_t value[];
+ } regObject_t;
+
+//-----------------------------------------------------------------
+
+ /** Stores an authentication token in registry.
+ * @param so Authentication token secure object.
+ * @param size Authentication token secure object size.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryStoreAuthToken(void *so, uint32_t size);
+
+ /** Reads an authentication token from registry.
+ * @param[out] so Authentication token secure object.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryReadAuthToken(mcSoAuthTokenCont_t *so);
+
+ /** Deletes the authentication token secure object from the registry.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryDeleteAuthToken(void);
+
+ /** Stores a root container secure object in the registry.
+ * @param so Root container secure object.
+ * @param size Root container secure object size.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryStoreRoot(void *so, uint32_t size);
+
+ /** Reads a root container secure object from the registry.
+ * @param[out] so Root container secure object.
+ * @param[out] size Root container secure object size
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryReadRoot(void *so, uint32_t *size);
+
+ /** Stores a service provider container secure object in the registry.
+ * @param spid Service provider ID.
+ * @param so Service provider container secure object.
+ * @param size Service provider container secure object size.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryStoreSp(mcSpid_t spid, void *so, uint32_t size);
+
+ /** Reads a service provider container secure object from the registry.
+ * @param spid Service provider ID.
+ * @param[out] so Service provider container secure object.
+ * @param[out] size Service provider container secure object size
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryReadSp(mcSpid_t spid, void *so, uint32_t *size);
+
+ /** Deletes a service provider recursively, including all trustlets and
+ * data.
+ * @param spid Service provider ID.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryCleanupSp(mcSpid_t spid);
+
+ /** Stores a trustlet container secure object in the registry.
+ * @param uuid Trustlet UUID.
+ * @param so Trustlet container secure object.
+ * @param size Trustlet container secure object size
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t size);
+
+ /** Reads a trustlet container secure object from the registry.
+ * @param uuid Trustlet UUID.
+ * @param spid SPID of the trustlet container
+ * @param[out] so Trustlet container secure object.
+ * @param[out] size Trustlet container secure object size
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryReadTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t *size);
+
+ /** Deletes a trustlet container secure object and all of its associated data.
+ * @param uuid Trustlet UUID.
+ * @param spid Service provider ID
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryCleanupTrustlet(const mcUuid_t *uuid, const mcSpid_t spid);
+
+ /** Stores a data container secure object in the registry.
+ * @param so Data container secure object.
+ * @param size Data container secure object size
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryStoreData(void *so, uint32_t size);
+
+ /** Reads a data container secure object from the registry.
+ * @param context (service provider = 0; trustlet = 1).
+ * @param cid Service provider or UUID.
+ * @param pid Personalization data identifier.
+ * @param[out] so Data container secure object.
+ * @param maxLen Maximum size (in bytes) of the destination buffer (so).
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryReadData(
+ uint32_t context,
+ const mcCid_t *cid,
+ mcPid_t pid,
+ mcSoDataCont_t *so,
+ uint32_t maxLen);
+
+ /** Deletes the root container and all of its associated service provider
+ * containers.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryCleanupRoot(void);
+
+ /** Returns a registry object for a given service from memory
+ * @param spid Service provider ID(ignored for System TLs)
+ * @param trustlet buffer with trustlet binary
+ * @param tlSize buffer size
+ * @return Registry object.
+ * @note It is the responsibility of the caller to free the registry object
+ * allocated by this function.
+ */
+ regObject_t *mcRegistryMemGetServiceBlob(mcSpid_t spid, void *trustlet, uint32_t tlSize);
+
+ /** Returns a registry object for a given service.
+ * @param uuid service UUID
+ * @return Registry object.
+ * @note It is the responsibility of the caller to free the registry object
+ * allocated by this function.
+ */
+ regObject_t *mcRegistryGetServiceBlob(const mcUuid_t *uuid, bool isGpUuid);
+
+ /** Returns a registry object for a given service.
+ * @param uuid service GP UUID as mc uuid
+ * @return Registry object.
+ * @note It is the responsibility of the caller to free the registry object
+ * allocated by this function.
+ */
+ regObject_t *mcRegistryGetServiceBlobGP(const mcUuid_t *uuid);
+
+ /** Returns a registry object for a given service.
+ * @param driverFilename driver filename
+ * @return Registry object.
+ * @note It is the responsibility of the caller to free the registry object
+ * allocated by this function.
+ */
+ regObject_t *mcRegistryGetDriverBlob(const char *filename);
+
+ /** Stores a Trustlet Application blob in the registry.
+ * @param spid SPID of the trustlet container.
+ * @param blob Trustlet Application blob.
+ * @param size Trustlet Application blob size.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, void *blob, uint32_t size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MOBICORE_REGISTRY_H_
+
+/** @} */
--- /dev/null
+/**
+ * @addtogroup MCD_MCDIMPL_DAEMON_REG
+ * @{
+ * G&D MobiCore Registry
+ *
+ * @file
+ * Mobicore Driver Registry.
+ */
+
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef MOBICORE_REGISTRY_H_
+#define MOBICORE_REGISTRY_H_
+
+#include "MobiCoreDriverApi.h"
+#include "mcContainer.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /** Stores an authentication token in registry.
+ * @param so Authentication token secure object.
+ * @param size Authentication token object size
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryStoreAuthToken(void *so, uint32_t size);
+
+ /** Reads an authentication token from registry.
+ * @param[out] so Authentication token secure object.
+ * @param[out] size Authentication token secure object size
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryReadAuthToken(void *so, uint32_t *size);
+
+ /** Deletes the authentication token secure object from the registry.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryDeleteAuthToken(void);
+
+ /** Stores a root container secure object in the registry.
+ * @param so Root container secure object.
+ * @param size Root container secure object size
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryStoreRoot(void *so, uint32_t size);
+
+ /** Reads a root container secure object from the registry.
+ * @param[out] so Root container secure object.
+ * @param[out] size Root container secure object size
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryReadRoot(void *so, uint32_t *size);
+
+ /** Stores a service provider container secure object in the registry.
+ * @param spid Service provider ID.
+ * @param so Service provider container secure object.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryStoreSp(mcSpid_t spid, void *so, uint32_t size);
+
+ /** Reads a service provider container secure object from the registry.
+ * @param spid Service provider ID.
+ * @param[out] so Service provider container secure object.
+ * @param[out] size Service provider container secure object size
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryReadSp(mcSpid_t spid, void *so, uint32_t *size);
+
+ /** Deletes a service provider recursively, including all trustlets and
+ * data.
+ * @param spid Service provider ID.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryCleanupSp(mcSpid_t spid);
+
+ /** Stores a trustlet container secure object in the registry.
+ * @param uuid Trustlet UUID.
+ * @param spid SPID of the trustlet container.
+ * @param so Trustlet container secure object.
+ * @param size Trustlet container secure object size.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t size);
+
+ /** Reads a trustlet container secure object from the registry.
+ * @param uuid Trustlet UUID.
+ * @param spid SPID of the trustlet container
+ * @param[out] so Trustlet container secure object.
+ * @param[out] size Trustlet container secure object size
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryReadTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t *size);
+
+ /** Deletes a trustlet container secure object and all of its associated data.
+ * @param uuid Trustlet UUID.
+ * @param spid Service provider ID
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryCleanupTrustlet(const mcUuid_t *uuid, const mcSpid_t spid);
+
+ /** Deletes the root container and all of its associated service provider
+ * containers.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryCleanupRoot(void);
+
+ /** Stores a Trustlet Application blob in the registry.
+ * @param spid SPID of the trustlet container.
+ * @param blob Trustlet Application blob.
+ * @param size Trustlet Application blob size.
+ * @return MC_DRV_OK if successful, otherwise error code.
+ */
+ mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, void *blob, uint32_t size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MOBICORE_REGISTRY_H_
+
+/** @} */
--- /dev/null
+/** Mobicore Driver Registry Interface
+ *
+ * Implements the MobiCore registry interface for the ROOT-PA
+ *
+ * @file
+ * @ingroup MCD_MCDIMPL_DAEMON_REG
+ */
+
+/*
+ * Copyright (c) 2013 TRUSTONIC LIMITED
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <assert.h>
+#include <string>
+#include <cstring>
+#include <cstddef>
+#include "mcLoadFormat.h"
+#include "mcSpid.h"
+#include "mcVersionHelper.h"
+
+#include "log.h"
+
+#include "MobiCoreRegistry.h"
+#include "MobiCoreDriverCmd.h"
+
+#include "Connection.h"
+
+#define DAEMON_TIMEOUT 30000
+
+using namespace std;
+
+
+static mcResult_t writeBlobData(void *buff, uint32_t len)
+{
+ Connection con;
+mcDrvResponseHeader_t rsp = { .responseId =
+ MC_DRV_ERR_INVALID_PARAMETER
+ };
+ if (!con.connect(SOCK_PATH)) {
+ LOG_E("Failed to connect to daemon!");
+ return MC_DRV_ERR_DAEMON_SOCKET;
+ }
+
+ if (con.writeData(buff, len) <= 0) {
+ LOG_E("Failed to send daemon to data!");
+ return MC_DRV_ERR_DAEMON_SOCKET;
+ }
+
+ if (con.readData(&rsp, sizeof(rsp), DAEMON_TIMEOUT) <= 0) {
+ LOG_E("Failed to get answer from daemon!");
+ return MC_DRV_ERR_DAEMON_SOCKET;
+ }
+
+ return rsp.responseId;
+}
+
+static mcResult_t readBlobData(void *buff, uint32_t len, void *rbuff, uint32_t *rlen)
+{
+ Connection con;
+ int32_t size;
+mcDrvResponseHeader_t rsp = { .responseId =
+ MC_DRV_ERR_INVALID_PARAMETER
+ };
+ if (*rlen == 0) {
+ LOG_E("Invalid buffer length!");
+ return MC_DRV_ERR_DAEMON_SOCKET;
+ }
+
+ if (!con.connect(SOCK_PATH)) {
+ LOG_E("Failed to connect to daemon!");
+ return MC_DRV_ERR_DAEMON_SOCKET;
+ }
+
+ if (con.writeData(buff, len) <= 0) {
+ LOG_E("Failed to send daemon to data!");
+ return MC_DRV_ERR_DAEMON_SOCKET;
+ }
+
+ // First read the response
+ if (con.readData(&rsp, sizeof(rsp), DAEMON_TIMEOUT) <= 0) {
+ LOG_E("Failed to get answer from daemon!");
+ return MC_DRV_ERR_DAEMON_SOCKET;
+ }
+
+ //Then read the actual data
+ size = con.readData(rbuff, *rlen, DAEMON_TIMEOUT);
+ if (size <= 0) {
+ LOG_E("Failed to get answer from daemon!");
+ return MC_DRV_ERR_DAEMON_SOCKET;
+ }
+ // Return also the read buf size
+ *rlen = (uint32_t)size;
+
+ return rsp.responseId;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryStoreAuthToken(void *so, uint32_t size)
+{
+ typedef struct {
+ uint32_t commandId;
+ uint32_t soSize;
+ uint8_t so;
+ } storeCmd;
+
+ mcResult_t ret;
+ storeCmd *cmd = (storeCmd *)malloc(sizeof(storeCmd) + size - 1);
+ if (cmd == NULL) {
+ LOG_E("Allocation failure");
+ return MC_DRV_ERR_NO_FREE_MEMORY;
+ }
+
+ cmd->commandId = MC_DRV_REG_STORE_AUTH_TOKEN;
+ cmd->soSize = size;
+ memcpy(&cmd->so, so, size);
+ ret = writeBlobData(cmd, sizeof(storeCmd) + size - 1);
+ free(cmd);
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryReadAuthToken(void *so, uint32_t *size)
+{
+mcDrvCommandHeader_t cmd = { .commandId =
+ MC_DRV_REG_READ_AUTH_TOKEN
+ };
+ uint32_t rsize;
+ mcResult_t ret;
+ // we expect to max read what the user has allocated
+ rsize = *size;
+ ret = readBlobData(&cmd, sizeof(cmd), so, &rsize);
+ // return the actual read size
+ *size = rsize;
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryDeleteAuthToken(void)
+{
+mcDrvCommandHeader_t cmd = { .commandId =
+ MC_DRV_REG_DELETE_AUTH_TOKEN
+ };
+ return writeBlobData(&cmd, sizeof(cmd));
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryStoreRoot(void *so, uint32_t size)
+{
+ typedef struct {
+ uint32_t commandId;
+ uint32_t soSize;
+ uint8_t so;
+ } storeCmd;
+ mcResult_t ret;
+ storeCmd *cmd = (storeCmd *)malloc(sizeof(storeCmd) + size - 1);
+ if (cmd == NULL) {
+ LOG_E("Allocation failure");
+ return MC_DRV_ERR_NO_FREE_MEMORY;
+ }
+
+ cmd->commandId = MC_DRV_REG_WRITE_ROOT_CONT;
+ cmd->soSize = size;
+ memcpy(&cmd->so, so, size);
+ ret = writeBlobData(cmd, sizeof(storeCmd) + size - 1);
+ free(cmd);
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryReadRoot(void *so, uint32_t *size)
+{
+mcDrvCommandHeader_t cmd = { .commandId =
+ MC_DRV_REG_READ_ROOT_CONT
+ };
+ uint32_t rsize;
+ mcResult_t ret;
+
+ rsize = *size;
+ ret = readBlobData(&cmd, sizeof(cmd), so, &rsize);
+ *size = rsize;
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryCleanupRoot(void)
+{
+mcDrvCommandHeader_t cmd = { .commandId =
+ MC_DRV_REG_DELETE_ROOT_CONT
+ };
+ return writeBlobData(&cmd, sizeof(cmd));
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryStoreSp(mcSpid_t spid, void *so, uint32_t size)
+{
+ typedef struct {
+ uint32_t commandId;
+ uint32_t soSize;
+ mcSpid_t spid;
+ uint8_t so;
+ } storeCmd;
+
+ mcResult_t ret;
+ storeCmd *cmd = (storeCmd *)malloc(sizeof(storeCmd) + size - 1);
+ if (cmd == NULL) {
+ LOG_E("Allocation failure");
+ return MC_DRV_ERR_NO_FREE_MEMORY;
+ }
+
+ cmd->commandId = MC_DRV_REG_WRITE_SP_CONT;
+ cmd->soSize = size;
+ cmd->spid = spid;
+ memcpy(&cmd->so, so, size);
+
+ ret = writeBlobData(cmd, sizeof(storeCmd) + size - 1);
+ free(cmd);
+ return ret;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryReadSp(mcSpid_t spid, void *so, uint32_t *size)
+{
+ struct {
+ uint32_t commandId;
+ mcSpid_t spid;
+ } cmd;
+ uint32_t rsize;
+ mcResult_t ret;
+ cmd.commandId = MC_DRV_REG_READ_SP_CONT;
+ cmd.spid = spid;
+
+ rsize = *size;
+ ret = readBlobData(&cmd, sizeof(cmd), so, &rsize);
+ *size = rsize;
+
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryCleanupSp(mcSpid_t spid)
+{
+ struct {
+ uint32_t commandId;
+ mcSpid_t spid;
+ } cmd;
+
+ cmd.commandId = MC_DRV_REG_DELETE_SP_CONT;
+ cmd.spid = spid;
+
+ return writeBlobData(&cmd, sizeof(cmd));
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid, mcSpid_t spid, void *so, uint32_t size)
+{
+ typedef struct {
+ uint32_t commandId;
+ uint32_t soSize;
+ mcUuid_t uuid;
+ mcSpid_t spid;
+ uint8_t so;
+ } storeCmd;
+
+ mcResult_t ret;
+ storeCmd *cmd = (storeCmd *)malloc(sizeof(storeCmd) + size - 1);
+ if (cmd == NULL) {
+ LOG_E("Allocation failure");
+ return MC_DRV_ERR_NO_FREE_MEMORY;
+ }
+
+ cmd->commandId = MC_DRV_REG_WRITE_TL_CONT;
+ cmd->soSize = size;
+ cmd->spid = spid;
+ memcpy(&cmd->uuid, uuid, sizeof(mcUuid_t));
+ memcpy(&cmd->so, so, size);
+
+ ret = writeBlobData(cmd, sizeof(storeCmd) + size - 1);
+ free(cmd);
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, void *blob, uint32_t size)
+{
+ typedef struct {
+ uint32_t commandId;
+ uint32_t blobSize;
+ mcSpid_t spid;
+ uint8_t blob[];
+ } storeCmd;
+
+ mcResult_t ret;
+ storeCmd *cmd = (storeCmd *)malloc(sizeof(storeCmd) + size);
+ if (cmd == NULL) {
+ LOG_E("Allocation failure");
+ return MC_DRV_ERR_NO_FREE_MEMORY;
+ }
+
+ cmd->commandId = MC_DRV_REG_STORE_TA_BLOB;
+ cmd->blobSize = size;
+ cmd->spid = spid;
+ memcpy(&cmd->blob, blob, size);
+
+ ret = writeBlobData(cmd, sizeof(storeCmd) + size);
+ free(cmd);
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryReadTrustletCon(const mcUuid_t *uuid, mcSpid_t spid, void *so, uint32_t *size)
+{
+ struct {
+ uint32_t commandId;
+ mcUuid_t uuid;
+ mcSpid_t spid;
+ } cmd;
+ mcResult_t ret;
+ uint32_t rsize;
+ cmd.commandId = MC_DRV_REG_READ_TL_CONT;
+ cmd.spid = spid;
+ memcpy(&cmd.uuid, uuid, sizeof(mcUuid_t));
+
+ rsize = *size;
+ ret = readBlobData(&cmd, sizeof(cmd), so, &rsize);
+ *size = rsize;
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryCleanupTrustlet(const mcUuid_t *uuid, const mcSpid_t spid)
+{
+ struct {
+ uint32_t commandId;
+ mcUuid_t uuid;
+ mcSpid_t spid;
+ } cmd;
+
+ if (uuid == NULL) {
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
+
+ cmd.commandId = MC_DRV_REG_DELETE_TL_CONT;
+ cmd.spid = spid;
+ memcpy(&cmd.uuid, uuid, sizeof(mcUuid_t));
+
+ return writeBlobData(&cmd, sizeof(cmd));
+}
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryStoreData(void *so __unused, uint32_t size __unused)
+{
+ return MC_DRV_ERR_INVALID_PARAMETER;
+}
+
+
+//------------------------------------------------------------------------------
+mcResult_t mcRegistryReadData(uint32_t context __unused, const mcCid_t *cid __unused, mcPid_t pid __unused,
+ mcSoDataCont_t *so __unused, uint32_t maxLen __unused)
+{
+ return MC_DRV_ERR_INVALID_PARAMETER;
+}
+
+/** @} */
--- /dev/null
+#!/bin/bash
+
+source ../../../../setup.sh
+if [ $? -ne 0 ]; then
+ echo "Error: Could not source setup.sh!"
+ exit 1
+fi
+
+ROOT_PATH=$(dirname $(readlink -f $BASH_SOURCE))
+
+###
+### Android NDK path
+###
+PLATFORM=Generic
+MODE=debug
+
+echo "Building <t-base Daemon..."
+
+# run NDK build
+${NDK_BUILD} \
+ -B \
+ NDK_DEBUG=1 \
+ NDK_PROJECT_PATH=$ROOT_PATH \
+ NDK_APPLICATION_MK=$ROOT_PATH/Application.mk \
+ NDK_MODULE_PATH=. \
+ NDK_APP_OUT=$ROOT_PATH/Out/_build \
+ APP_BUILD_SCRIPT=$ROOT_PATH/Android.mk \
+ APP_OPTIM=$MODE
\ No newline at end of file
--- /dev/null
+/*
+ * <-- Copyright Trustonic Limited 2013 -->
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#define MOBICORE_COMPONENT_BUILD_TAG "*** t-base-300-Ares-2-Android-V001 ###"
--- /dev/null
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+/*
+ * The <t-base Driver Kernel Module is a Linux device driver, which represents
+ * the command proxy on the lowest layer to the secure world (Swd). Additional
+ * services like memory allocation via mmap and generation of a MMU tables for
+ * given virtual memory are also supported. IRQ functionality receives
+ * information from the SWd in the non secure world (NWd).
+ * As customary the driver is handled as Linux device driver with "open",
+ * "close" and "ioctl" commands. Access to the driver is possible after the
+ * devices "/dev/mobicore" and "/dev/mobicore-user" have been created.
+ */
+
+#ifndef _MC_LINUX_H_
+#define _MC_LINUX_H_
+
+#include "version.h"
+
+#ifndef __KERNEL__
+#include <stdint.h>
+#endif
+
+#define MC_ADMIN_DEVNODE "mobicore"
+#define MC_USER_DEVNODE "mobicore-user"
+
+/*
+ * Data exchange structure of the MC_DRV_MODULE_INIT ioctl command.
+ * INIT request data to SWD
+ */
+struct mc_ioctl_init {
+ /* length of notification queue */
+ uint32_t nq_length;
+ /* mcp buffer start/length [16:16] [start, length] */
+ uint32_t mcp_offset;
+ /* length of mcp buffer */
+ uint32_t mcp_length;
+};
+
+/*
+ * Data exchange structure of the MC_DRV_MODULE_INFO ioctl command.
+ * INFO request data to the SWD
+ */
+struct mc_ioctl_info {
+ uint32_t ext_info_id; /* extended info ID */
+ uint32_t state; /* state */
+ uint32_t ext_info; /* extended info */
+};
+
+/*
+ * Data exchange structure of the MC_IO_MAP_WSM and MC_IO_MAP_MCI commands.
+ *
+ * Allocate a contiguous memory buffer for a process.
+ * The physical address can be used as for later calls to mmap.
+ * The handle can be used to communicate about this buffer to the Daemon.
+ * For MC_IO_MAP_MCI command, the reused field indicates that MCI was set up
+ * already. I.e. Daemon was restarted.
+ */
+struct mc_ioctl_map {
+ uint32_t len; /* Buffer length */
+ uint32_t handle; /* WSM handle */
+ uint64_t phys_addr; /* physical address of WSM (or 0) */
+ uint32_t rfu;
+ bool reused; /* if WSM memory was reused, or new allocated */
+};
+
+/*
+ * Data exchange structure of the MC_IO_REG_WSM command.
+ *
+ * Allocates a physical MMU table and maps the buffer into this page.
+ * Returns the physical address of the MMU table.
+ * The page alignment will be created and the appropriated pSize and pOffsetMMU
+ * will be modified to the used values.
+ *
+ * We assume the 64 bit compatible one to be the default and the
+ * 32 bit one to be the compat one but we must serve both of them.
+ */
+struct mc_compat_ioctl_reg_wsm {
+ uint32_t buffer; /* base address of the virtual address */
+ uint32_t len; /* size of the virtual address space */
+ uint32_t pid; /* process id */
+ uint32_t handle; /* driver handle for locked memory */
+ uint64_t table_phys; /* physical address of the MMU table */
+};
+
+struct mc_ioctl_reg_wsm {
+ uint64_t buffer; /* base address of the virtual address */
+ uint32_t len; /* size of the virtual address space */
+ uint32_t pid; /* process id */
+ uint32_t handle; /* driver handle for locked memory */
+ uint64_t table_phys;/* physical address of the MMU table */
+};
+
+/*
+ * Data exchange structure of the MC_IO_RESOLVE_CONT_WSM ioctl command.
+ */
+struct mc_ioctl_resolv_cont_wsm {
+ /* driver handle for buffer */
+ uint32_t handle;
+ /* length memory */
+ uint32_t length;
+ /* base address of memory */
+ uint64_t phys;
+ /* fd to owner of the buffer */
+ int32_t fd;
+};
+
+/*
+ * Data exchange structure of the MC_IO_RESOLVE_WSM ioctl command.
+ */
+struct mc_ioctl_resolv_wsm {
+ /* driver handle for buffer */
+ uint32_t handle;
+ /* fd to owner of the buffer */
+ int32_t fd;
+ /* base address of memory */
+ uint64_t phys;
+};
+
+
+/*
+ * defines for the ioctl mobicore driver module function call from user space.
+ */
+/* MobiCore IOCTL magic number */
+#define MC_IOC_MAGIC 'M'
+
+#define MC_IO_INIT _IOWR(MC_IOC_MAGIC, 0, struct mc_ioctl_init)
+#define MC_IO_INFO _IOWR(MC_IOC_MAGIC, 1, struct mc_ioctl_info)
+#define MC_IO_VERSION _IOR(MC_IOC_MAGIC, 2, uint32_t)
+/*
+ * ioctl parameter to send the YIELD command to the SWD.
+ * Only possible in Privileged Mode.
+ * ioctl(fd, MC_DRV_MODULE_YIELD)
+ */
+#define MC_IO_YIELD _IO(MC_IOC_MAGIC, 3)
+/*
+ * ioctl parameter to send the NSIQ signal to the SWD.
+ * Only possible in Privileged Mode
+ * ioctl(fd, MC_DRV_MODULE_NSIQ)
+ */
+#define MC_IO_NSIQ _IO(MC_IOC_MAGIC, 4)
+/*
+ * Free's memory which is formerly allocated by the driver's mmap
+ * command. The parameter must be this mmaped address.
+ * The internal instance data regarding to this address are deleted as
+ * well as each according memory page and its appropriated reserved bit
+ * is cleared (ClearPageReserved).
+ * Usage: ioctl(fd, MC_DRV_MODULE_FREE, &address) with address being of
+ * type long address
+ */
+#define MC_IO_FREE _IO(MC_IOC_MAGIC, 5)
+/*
+ * Creates a MMU Table of the given base address and the size of the
+ * data.
+ * Parameter: mc_ioctl_reg_wsm
+ *
+ * Since the end ID is also based on the size of the structure it is
+ * safe to use the same ID(6) for both
+ */
+#define MC_IO_REG_WSM _IOWR(MC_IOC_MAGIC, 6, struct mc_ioctl_reg_wsm)
+#define MC_COMPAT_REG_WSM _IOWR(MC_IOC_MAGIC, 6, \
+ struct mc_compat_ioctl_reg_wsm)
+
+#define MC_IO_UNREG_WSM _IO(MC_IOC_MAGIC, 7)
+#define MC_IO_LOCK_WSM _IO(MC_IOC_MAGIC, 8)
+#define MC_IO_UNLOCK_WSM _IO(MC_IOC_MAGIC, 9)
+
+/*
+ * Allocate contiguous memory for a process for later mapping with mmap.
+ * MC_IO_MAP_WSM usual operation, pages are registered in
+ * device structure and freed later.
+ * MC_IO_MAP_MCI get Instance of MCI, allocates or mmaps
+ * the MCI to daemon
+ */
+#define MC_IO_MAP_WSM _IOWR(MC_IOC_MAGIC, 11, struct mc_ioctl_map)
+#define MC_IO_MAP_MCI _IOWR(MC_IOC_MAGIC, 12, struct mc_ioctl_map)
+
+/*
+ * Clean orphaned WSM buffers. Only available to the daemon and should
+ * only be carried out if the TLC crashes or otherwise calls exit() in
+ * an unexpected manner.
+ * The clean is needed together with the lock/unlock mechanism so the daemon
+ * has clear control of the mapped buffers so it can close a Trustlet before
+ * release all the WSM buffers, otherwise the Trustlet would be able to write
+ * to possibly kernel memory areas
+ */
+#define MC_IO_CLEAN_WSM _IO(MC_IOC_MAGIC, 14)
+
+/*
+ * Get MMU phys address of a buffer handle allocated to the user.
+ * Only available to the daemon.
+ */
+#define MC_IO_RESOLVE_WSM _IOWR(MC_IOC_MAGIC, 15, \
+ struct mc_ioctl_resolv_wsm)
+
+/*
+ * Get the phys address & length of a allocated contiguous buffer.
+ * Only available to the daemon */
+#define MC_IO_RESOLVE_CONT_WSM _IOWR(MC_IOC_MAGIC, 16, \
+ struct mc_ioctl_resolv_cont_wsm)
+
+/*
+ * Setup the mem traces when called.
+ * Only available to the daemon */
+#define MC_IO_LOG_SETUP _IO(MC_IOC_MAGIC, 17)
+
+#endif /* _MC_LINUX_H_ */
--- /dev/null
+/*
+ * <-- Copyright Giesecke & Devrient GmbH 2010-2012 -->
+ * <-- Copyright Trustonic Limited 2013 -->
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MC_DRV_VERSION_H_
+#define _MC_DRV_VERSION_H_
+
+#define MCDRVMODULEAPI_VERSION_MAJOR 1
+#define MCDRVMODULEAPI_VERSION_MINOR 1
+
+#endif /* _MC_DRV_VERSION_H_ */
--- /dev/null
+# =============================================================================
+#
+# Makefile pointing to all makefiles within the project.
+#
+# =============================================================================
+
+PROJECT_PATH := $(call my-dir)
+
+# adding the root folder to the search path appears to make absolute paths
+# work for import-module - lets see how long this works and what surprises
+# future developers get from this.
+$(call import-add-path,/)
+$(call import-module,$(COMP_PATH_MobiCoreDriverLib))
+
+# Include the Scripts
+include $(PROJECT_PATH)/jni/Android.mk
--- /dev/null
+# =============================================================================
+#
+# Main build file defining the project modules and their global variables.
+#
+# =============================================================================
+
+# Don't remove this - mandatory
+APP_PROJECT_PATH := $(call my-dir)
+
+# Don't optimize for better debugging
+APP_OPTIM := debug
+
+# Show all warnings
+#APP_CFLAGS := -Wall
+
+MC_INCLUDE_DIR := \
+ $(COMP_PATH_TlCm)/Public \
+ $(COMP_PATH_TlCm)/Public/TlCm \
+ $(COMP_PATH_TlCm)/Public/TlCm/2.0 \
+ $(COMP_PATH_MobiCoreDriverLib)/Public
+MC_DEBUG := _DEBUG
+SYSTEM_LIB_DIR=/system/lib
+GDM_PROVLIB_SHARED_LIBS=MobiCoreDriver
--- /dev/null
+/*
+ * <-- Copyright Trustonic Limited 2013 -->
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#define MOBICORE_COMPONENT_BUILD_TAG "*** t-base-300-Ares-2-Android-V001 ###"
--- /dev/null
+#ifndef _INC_GDMCDEVICEBINDING_H
+#define _INC_GDMCDEVICEBINDING_H
+
+#include <gdmcprovlib.h>
+#include <gdmcprovprotocol.h>
+#ifdef ARM
+#include <android/log.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _KSoCAuthSNTS KSoCAuthSNTS;
+
+struct _KSoCAuthSNTS
+{
+ mcSymmetricKey_t kSoCAuth;
+ _u64 serialNumber;
+ _u64 timeStamp;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef ARM
+
+extern "C" void GDPROVAPI GDMCLog ( int prio, const char *tag, const char *fmt, ... );
+
+#ifdef _DEBUG
+extern "C" void GDMCHexDump ( const unsigned char *data, int size );
+#endif
+
+#define LOG_TAG "GDMCProvLib"
+
+#ifdef _DEBUG
+#define LOG_d(...) do { GDMCLog(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__); } while(0)
+#else
+#define LOG_d(...) do { } while(0)
+#endif
+#define LOG_i(...) do { GDMCLog(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__); } while(0)
+#define LOG_w(...) do { GDMCLog(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__); } while(0)
+#define LOG_e(...) do { GDMCLog(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__); } while(0)
+
+#else
+
+#define LOG_d(...) do { } while(0)
+#define LOG_i(...) do { } while(0)
+#define LOG_w(...) do { } while(0)
+#define LOG_e(...) do { } while(0)
+
+#endif // ARM
+
+gderror GDMCComposeErrorMessage ( gdmcinst *inst,
+ gderror error,
+ _u8 *msgout,
+ _u32 *msgout_size,
+ _u32 initial_msgout_size,
+ const char *pszmsg, ... );
+
+gderror GDPROVAPI GDMCValidateProvMessage ( const _u8 *msg,
+ _u32 msgsize,
+ gdmc_msgheader **ppheader,
+ _u8 **ppbody,
+ gdmc_msgtrailer **pptrailer );
+
+gderror GDPROVAPI GDMCHandleGetSUID ( gdmcinst *inst,
+ _u8 *msgout,
+ _u32 *msgout_size,
+ _u32 initial_msgout_size );
+
+gderror GDPROVAPI GDMCHandleGenAuthToken ( gdmcinst *inst,
+ gdmc_actmsg_req *req,
+ _u8 *msgout,
+ _u32 *msgout_size,
+ _u32 initial_msgout_size );
+
+gderror GDPROVAPI GDMCHandleValidateAuthToken ( gdmcinst *inst,
+ gdmc_so_authtok *validateSoAuthTok,
+ _u8 *msgout,
+ _u32 *msgout_size,
+ _u32 initial_msgout_size );
+
+#define ERRMSG_0001 "Unable to access memory region at %p (size: %u byte(s)) for READ."
+#define ERRMSG_0002 "Unable to access memory region at %p (size: %u byte(s)) for WRITE."
+#define ERRMSG_0003 "First in-message must be empty."
+#define ERRMSG_0004 "Insufficient memory available."
+#define ERRMSG_0005 "Message output buffer too small (%u but %u required to store message)."
+#define ERRMSG_0006 "Message validation failed."
+#define ERRMSG_0007 "Unexpected message received. Cannot evaluate message (ignored)."
+#define ERRMSG_0008 "SUID of returned SO.AuthToken mismatches (my) internal SUID. SO.AuthToken discarded."
+#define ERRMSG_0009 "Unable to generate SD.Receipt."
+#define ERRMSG_000A "Expecting MC_GETSUID_REQ message from Production Station."
+#define ERRMSG_000B "Unable to retrieve SUID from SoC (MobiCore)."
+#define ERRMSG_000C "Unable to dump SO.AuthToken (MobiCore)."
+#define ERRMSG_000D "Unable to retrieve SUID from SoC."
+#define ERRMSG_000E "Unable to generate SO.AuthToken."
+#define ERRMSG_000F "Validation of SO.AuthToken failed because no SO.AuthToken available."
+
+#endif // _INC_GDMCDEVICEBINDING_H
--- /dev/null
+#ifndef _INC_GDMCINSTANCE_H
+#define _INC_GDMCINSTANCE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _gdmcinst gdmcinst;
+
+#define GDMC_STATE_INITIAL ((_u32)0) ///< initial state
+#define GDMC_STATE_HAVE_SUID ((_u32)1) ///< SUID retrieved from MobiCore
+#define GDMC_STATE_HAVE_AUTHTOK ((_u32)2) ///< SO.AuthToken generated by MobiCore
+
+#define MAX_RESEND_TRIES 64
+
+struct _gdmcinst
+{
+ _u32 state; ///< internal state of this instance
+ _u8 suid[SUID_LENGTH]; ///< SUID as retrieved from MobiCore
+ _u8 kSoCAuth[K_SOC_AUTH_LENGTH]; ///< the K.SoC.Auth delivered by KPH
+ gdmc_so_authtok authTok; ///< generated SO.AuthToken
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _INC_GDMCINSTANCE_H
--- /dev/null
+#ifndef _INC_GDMCPROVPROTOCOL_H_
+#define _INC_GDMCPROVPROTOCOL_H_
+
+#include <gdmcprovlib.h>
+#include <mobicore.h>
+
+#ifdef WIN32
+
+#pragma warning ( disable : 4200 )
+
+#pragma pack(push,1)
+
+#ifndef PACK_ATTR
+#define PACK_ATTR
+#endif // PACK_ATTR
+
+#else
+
+#ifndef PACK_ATTR
+#define PACK_ATTR __attribute__((packed))
+#endif // PACK_ATTR
+
+#define IsBadReadPtr(p,c) (NULL==p)
+#define IsBadWritePtr(p,c) (NULL==p)
+
+#endif
+
+#define AUTHENTICATION_TOKEN MC_SO_TYPE_REGULAR
+#define CONTEXT_SYSTEM MC_SO_CONTEXT_TLT
+#define SUID_LENGTH MC_SUID_LEN // 16
+#define K_SOC_AUTH_LENGTH MC_CONT_SYMMETRIC_KEY_SIZE // 32
+#define SHA256_HASH_LENGTH MC_SO_HASH_SIZE // 32
+
+#undef AES_BLOCK_SIZE
+
+#define AES_BLOCK_SIZE MC_SO_ENCRYPT_BLOCK_SIZE // 16
+
+typedef struct _gdmc_actmsg_req gdmc_actmsg_req;
+typedef struct _gdmc_actmsg_resp gdmc_actmsg_resp;
+typedef struct _gdmc_so_authtok gdmc_so_authtok;
+typedef struct _gdmc_error_msg gdmc_error_msg;
+
+#define MC_GETSUID_REQ ((_u32)0x0100434D)
+#define MC_GETSUID_RESP ((_u32)0x0200434D)
+#define MC_GENAUTHTOKEN_REQ ((_u32)0x0300434D)
+#define MC_GENAUTHTOKEN_RESP ((_u32)0x0400434D)
+#define MC_VALIDATEAUTHTOKEN_REQ ((_u32)0x0500434D)
+#define MC_ERROR ((_u32)0x0600434D)
+
+#ifndef CMP_GEN_AUTH_TOKEN_PSS_SIZE
+#define CMP_GEN_AUTH_TOKEN_PSS_SIZE 256
+#endif
+
+/// G&D MobiCore error message
+struct _gdmc_error_msg
+{
+ _u32 errorcode; ///< error code; you can safely cast this to gderror.
+ _u32 errmsg_length; ///< length of error message, may be 0
+ _u8 errmsg[]; ///< error message (variable)
+} PACK_ATTR;
+
+/// G&D MobiCore SO.AuthToken (authentication token)
+struct _gdmc_so_authtok
+{
+ // Header
+
+ _u32 type;
+ _u32 version;
+ _u32 context;
+ _u32 lifetime; // NEW2 -> ignore
+ _u32 producer_spid; // NEW2 -> ignore
+ _u8 producer_uuid[16]; // NEW2 -> ignore
+ _u32 plain_length; // OLD: 16 (SUID_LENGTH), NEW: 24 (two additional ints)
+ // NEW2: 28 (version is new)
+ _u32 encrypted_length; // here: K_SOC_AUTH_LENGTH
+
+ // Plaintext Data
+
+ _u32 contType; // NEW: contType_t = CONT_TYPE_SOC
+ _u32 contVersion; // NEW2: version
+ _u32 contState; // NEW: mcContainerState_t = MC_CONT_STATE_UNREGISTERED
+ _u8 suid[SUID_LENGTH];
+
+ // Encrypted Data (encrypted with K.Device.Ctxt)
+
+ _u8 kSoCAuth[K_SOC_AUTH_LENGTH];
+ _u8 md[SHA256_HASH_LENGTH];
+ _u8 padding[AES_BLOCK_SIZE];
+
+} PACK_ATTR;
+
+/// MobiCore activation message (request)
+struct _gdmc_actmsg_req
+{
+ _u32 msg_type; ///< type of message = MC_CMP_CMD_GENERATE_AUTH_TOKEN
+ _u8 suid[SUID_LENGTH]; ///< SoC SUID
+ _u8 kSoCAuth[K_SOC_AUTH_LENGTH]; ///< K.SoC.Auth (AES-256bit key)
+ _u32 kid; ///< NEW: key id (currently: 1)
+ //_u8 md[SHA256_HASH_LENGTH]; ///< SHA-256 hash
+ _u8 dsig[CMP_GEN_AUTH_TOKEN_PSS_SIZE]; ///< new: hash substituted by PSS-SIG
+} PACK_ATTR;
+
+/// MobiCore activation response
+struct _gdmc_actmsg_resp
+{
+ _u32 msg_type; ///< type of message = MC_CMP_CMD_GENERATE_AUTH_TOKEN | 0x80000000
+ _u32 retcode; ///< NEW: return code (status of operation)
+ gdmc_so_authtok authtok; ///< SO.AuthToken (124 bytes)
+} PACK_ATTR;
+
+#ifdef WIN32
+#pragma pack(pop)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_u32 GDPROVAPI CalcCRC32 ( const _u8 *data, _u32 length );
+
+void GDPROVAPI InitCRCTable ( void );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _INC_GDMCPROVPROTOCOL_H_
--- /dev/null
+/// @file mobicore.h
+/// @author secunet AG (IKU)
+///
+/// This file is a convenience header file (top-level) including
+/// all MobiCore-related and platform-specific stuff.
+
+#ifndef _INC_MOBICORE_H_
+#define _INC_MOBICORE_H_
+
+#if !defined(LINUX) && !defined(ANDROID_ARM) && !defined(WIN32)
+#error "You MUST define either LINUX or ANDROID_ARM or WIN32"
+#endif
+
+// standard C stuff...
+
+#if defined(__cplusplus) && !defined(ANDROID_ARM)
+#include <string>
+#include <vector>
+#include <map>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+#ifdef LINUX
+#include <safemem.h>
+#endif
+
+#if defined(WIN32) && defined(_DEBUG) // enable memory leak detection
+#define _CRTDBG_MAP_ALLOC
+#define _CRTDBG_MAP_ALLOC_NEW
+#include <windows.h>
+#include <crtdbg.h>
+#define MYDEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__)
+#define new MYDEBUG_NEW
+#endif
+
+#ifndef _NO_OPENSSL_INCLUDES
+
+// OpenSSL stuff...
+
+#include <openssl/rand.h>
+#include <openssl/sha.h>
+#include <openssl/aes.h>
+#include <openssl/rsa.h>
+#include <openssl/bn.h>
+#include <openssl/objects.h>
+#include <openssl/err.h>
+
+#endif
+
+#ifdef WIN32
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#pragma pack(push,4)
+
+#pragma warning ( disable : 4200 4996 )
+
+#define GDPUBLIC
+#define GDAPI __fastcall
+#define PACK_ATTR
+#define likely(cond) cond
+#define unlikely(cond) cond
+
+#define bad_read_ptr(_p,_c) IsBadReadPtr((const void *)(_p),(UINT_PTR)(_c))
+#define bad_write_ptr(_p,_c) IsBadWritePtr((void *)(_p),(UINT_PTR)(_c))
+
+#define PATH_SEPARATOR "\\"
+#define PATH_SEP_CHAR '\\'
+#define DYNLIB_PREFIX ""
+#define DYNLIB_EXTENSION ".dll"
+
+#else
+
+#define GDPUBLIC __attribute__((visibility("default")))
+#define GDAPI
+#define PACK_ATTR __attribute__((packed))
+#define likely(x) __builtin_expect((x),1)
+#define unlikely(x) __builtin_expect((x),0)
+
+#define bad_read_ptr(_p,_c) (NULL==(_p))
+#define bad_write_ptr(_p,_c) (NULL==(_p))
+
+#define PATH_SEPARATOR "/"
+#define PATH_SEP_CHAR '/'
+#define DYNLIB_PREFIX "lib"
+#define DYNLIB_EXTENSION ".so"
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <sched.h>
+#include <dlfcn.h>
+#include <signal.h>
+#include <ctype.h>
+#ifndef LINUX
+#include <android/log.h>
+#else
+#include <syslog.h>
+#endif
+
+#endif
+
+#include <stdbool.h>
+#include <stdint.h>
+
+// MobiCore stuff...
+
+#ifdef WIN32
+#undef UUID
+#undef uuid_t
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <MobiCoreDriverApi.h>
+#include <mcContainer.h>
+#include <tlCmApi.h>
+#include <tlCmUuid.h>
+#include <mcVersionHelper.h>
+#include <mcVersionInfo.h>
+
+enum _mcAuthState
+{
+ AUTH_NONE = 0,
+ AUTH_SOC,
+ AUTH_ROOT,
+ AUTH_SP
+};
+
+typedef enum _mcAuthState mcAuthState;
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef WIN32
+#pragma pack(pop)
+#endif
+
+#include <MobiCoreRegistry.h>
+
+#define IS_VALID_SPID(_x) ((0xFFFFFFFF!=(_x)) && (0xFFFFFFFE!=(_x)))
+#define IS_VALID_ROOTID(_x) IS_VALID_SPID(_x)
+#define IS_VALID_UUID(_x) ( ((_x).value[ 0]!=0xFF) && ((_x).value[ 1]!=0xFF) &&\
+ ((_x).value[ 2]!=0xFF) && ((_x).value[ 3]!=0xFF) &&\
+ ((_x).value[ 4]!=0xFF) && ((_x).value[ 5]!=0xFF) &&\
+ ((_x).value[ 6]!=0xFF) && ((_x).value[ 7]!=0xFF) &&\
+ ((_x).value[ 8]!=0xFF) && ((_x).value[ 9]!=0xFF) &&\
+ ((_x).value[10]!=0xFF) && ((_x).value[11]!=0xFF) &&\
+ ((_x).value[12]!=0xFF) && ((_x).value[13]!=0xFF) &&\
+ ((_x).value[14]!=0xFF) && ((_x).value[15]!=0xFF) && ((_x).value[15]!=0xFE) )
+
+#define MC_SO_PLAIN_SIZE(_struct) offsetof(_struct,co)
+#define MC_SO_ENC_SIZE(_struct) sizeof(_struct.co)
+
+#endif // _INC_MOBICORE_H_
+
--- /dev/null
+///
+/// @file gdmcprovlib.h
+/// @author Giesecke & Devrient GmbH, Munich, Germany
+///
+/// This header file declares simple data types and functions
+/// comprising the G&D Provisioning API.
+///
+
+#ifndef _INC_GDPROVLIB_H_
+#define _INC_GDPROVLIB_H_
+
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Check defines (macros)...
+
+#if !defined(WIN32) && !defined(LINUX) && !defined(ARM)
+#error "You MUST define one of WIN32, LINUX, and ARM (platform)."
+#endif
+
+#if !defined(_32BIT) && !defined(_64BIT)
+#error "You MUST define either _32BIT or _64BIT."
+#endif
+
+#if !defined(_LENDIAN) && !defined(_BENDIAN)
+#error "You MUST define either _LENDIAN or _BENDIAN."
+#endif
+
+// Declare simple signed and unsigned integer types
+
+/// a byte (octet), unsigned, 0..255
+typedef unsigned char _u8;
+
+/// a signed byte, -128..+127
+typedef signed char _i8;
+
+/// an unsigned 16bit integer, 0..65.535
+typedef unsigned short _u16;
+
+/// a signed 16bit integer, -32.768..+32.767
+typedef signed short _i16;
+
+/// an unsigned 32bit integer, 0..4.294.967.295
+typedef unsigned int _u32;
+
+/// a signed 32bit integer, -2.147.483.648..+2.147.483.647
+typedef signed int _i32;
+
+#ifdef WIN32
+
+#define GDPUBLIC
+#define GDPROVAPI __fastcall
+
+/// an unsigned 64bit integer, 0..18.446.744.073.709.551.615
+typedef unsigned __int64 _u64;
+
+/// a signed 64bit integer, -9.223.372.036.854.775.808..+9.223.372.036.854.775.807
+typedef signed __int64 _i64;
+
+#else
+
+#define GDPUBLIC __attribute__((visibility("default")))
+#define GDPROVAPI
+
+#ifdef _32BIT
+
+/// an unsigned 64bit integer, 0..18.446.744.073.709.551.615
+typedef unsigned long long _u64;
+
+/// a signed 64bit integer, -9.223.372.036.854.775.808..+9.223.372.036.854.775.807
+typedef signed long long _i64;
+
+#else // 64bit
+
+/// an unsigned 64bit integer, 0..18.446.744.073.709.551.615
+typedef unsigned long _u64;
+
+/// a signed 64bit integer, -9.223.372.036.854.775.808..+9.223.372.036.854.775.807
+typedef signed long _i64;
+
+#endif // _32BIT
+
+#endif // WIN32
+
+//////////////////////////////////////////////////////////////////////////////
+
+/// G&D error codes, which are unsigned 32bit integers
+typedef _u32 gderror;
+
+/// everything okay, operation successful
+#define GDERROR_OK ((gderror)0x00000000)
+
+/// one or more of the input parameters to a function is/are invalid
+#define GDERROR_PARAMETER ((gderror)0x00000001)
+
+/// connection problem occured, unable to establish a connection to the
+/// Key Provisioning Host (KPH)
+#define GDERROR_CONNECTION ((gderror)0x00000002)
+
+/// communication problem occured, unable to communicate with the
+/// Key Provisioning Host (KPH)
+#define GDERROR_COMMUNICATION ((gderror)0x00000003)
+
+/// GDMCProvShutdownLibrary was called without calling GDMCProvInitializeLibrary
+#define GDERROR_NOT_INITIALIZED ((gderror)0x00000004)
+
+/// GDMCProvBeginProvisioning called but no more handles available
+#define GDERROR_NO_MORE_HANDLES ((gderror)0x00000005)
+
+/// An unknown or invalid gdhandle was passed to a function
+#define GDERROR_INVALID_HANDLE ((gderror)0x00000006)
+
+/// A so called structured exception occured, which is a severe error
+/// (MS Windows only)
+#define GDERROR_CPU_EXCEPTION ((gderror)0x00000007)
+
+/// Unable to retrieve the SUID of the SoC
+#define GDERROR_CANT_GET_SUID ((gderror)0x00000008)
+
+/// Unable to generate the authentication token SO.AuthToken
+#define GDERROR_CANT_BUILD_AUTHTOKEN ((gderror)0x00000009)
+
+/// Unable to dump the authentication token SO.AuthToken
+#define GDERROR_CANT_DUMP_AUTHTOKEN ((gderror)0x0000000A)
+
+/// Unable to generate the receipt SD.Receipt
+#define GDERROR_CANT_BUILD_RECEIPT ((gderror)0x0000000B)
+
+/// (only product version): Authentication KPH Connector <-> Key Provisioning Host (KPH) failed
+#define GDERROR_AUTH_FAILED ((gderror)0x0000000C)
+
+/// validation of the device binding failed
+#define GDERROR_VALIDATION_FAILURE ((gderror)0x0000000D)
+
+/// insufficient memory available
+#define GDERROR_INSUFFICIENT_MEMORY ((gderror)0x0000000E)
+
+/// synchronization error occurred (thread concurrency)
+#define GDERROR_SYNCHRONIZATION ((gderror)0x0000000F)
+
+/// the Key Provisioning Host (KPH) was not able to generate a random key (TRNG)
+#define GDERROR_CANT_GENERATE_KEY ((gderror)0x00000010)
+
+/// the received cryptographic message format is erroneous
+#define GDERROR_MESSAGE_FORMAT ((gderror)0x00000011)
+
+/// CRC32 checksum error
+#define GDERROR_CRC32 ((gderror)0x00000012)
+
+/// Hash value (message digest) validation error
+#define GDERROR_MESSAGE_DIGEST ((gderror)0x00000013)
+
+/// SUID comparison failed
+#define GDERROR_SUID_MISMATCH ((gderror)0x00000014)
+
+/// the Device could not generate the authentication token SO.AuthToken for any reason
+#define GDERROR_GENAUTHTOK_FAILED ((gderror)0x00000015)
+
+/// the Device could not wrap the authentication token in a secure object (SO)
+#define GDERROR_WRAPOBJECT_FAILED ((gderror)0x00000016)
+
+/// the Device could not store SO.AuthToken for any reason
+#define GDERROR_STORE_SO_FAILED ((gderror)0x00000017)
+
+/// the Key Provisioning Host (KPH) could not generate the receipt SD.Receipt for any reason
+#define GDERROR_GENRECEIPT_FAILED ((gderror)0x00000018)
+
+/// the Key Provisioning Host (KPH) triggered a SO.AuthToken validation in the Device but no SO.AuthToken is available
+#define GDERROR_NO_AUTHTOK_AVAILABLE ((gderror)0x00000019)
+
+/// the Device could not perform a read-back of the recently stored SO.AuthToken
+#define GDERROR_AUTHTOK_RB_FAILED ((gderror)0x0000001A)
+
+/// the called API function is not implemented
+#define GDERROR_NOT_IMPLEMENTED ((gderror)0x0000001B)
+
+/// generic (unspecified) error
+#define GDERROR_UNKNOWN ((gderror)0x0000001C)
+
+/// MobiCore library initialization or cleanup failed
+#define GDERROR_MOBICORE_LIBRARY ((gderror)0x0000001D)
+
+/// supplied (output) buffer too small
+#define GDERROR_BUFFER_TOO_SMALL ((gderror)0x0000001E)
+
+/// cryptographic-related error occured, e.g. loading of RSA keys, etc.
+#define GDERROR_CRYPTO_FAILURE ((gderror)0x0000001F)
+
+/// no error code: device binding completed successfully
+#define GDERROR_PROVISIONING_DONE ((gderror)0x10000001)
+
+//////////////////////////////////////////////////////////////////////////////
+
+/// G&D handle (to one instance of the Provisioning API)
+typedef _u32 gdhandle;
+
+/// Returns the current version of the Provisioning API.
+///
+/// @return an unsigned 32bit integer consisting of four bytes aa|bb|cc|dd
+/// with major version (aa), minor version (bb), patch level (cc), and
+/// OEM (dd), which denotes the numeric ID of an OEM.
+GDPUBLIC _u32 GDPROVAPI GDMCProvGetVersion ( void );
+
+/// [PRODUCTION STATION ONLY] Formats an error message for an error code,
+/// possibly containing more detailed information about the error. This function
+/// is NOT implemented in the ARM version of the library because no diagnostic
+/// messages can be displayed during the production.
+///
+/// @param[in] provhandle the handle returned by GDMCProvBeginProvisioning;
+/// can be null (0) to format a message for a global
+/// error code (not context-specific)
+/// @param[in] errorcode the G&D error code
+/// @param[in/out] msgbuf pointer to buffer receiving the UTF-8 encoded
+/// error message (in), buffer filled with error
+/// message (out)
+/// @param[in/out] size size of buffer pointed to by msgbuf specified
+/// as wide characters (in), number of wide
+/// characters copied into msgbuf (out)
+///
+/// @return result code (e.g. buffer too small)
+GDPUBLIC gderror GDPROVAPI GDMCProvFormatErrorMessage ( gdhandle provhandle,
+ gderror errorcode,
+ char *msgbuf,
+ _u32 *size );
+
+/// Initializes the G&D Provisioning API (library) globally. If called
+/// by the Production Software Station, then a TLS-secured channel to
+/// the Key Provisioning Host (KPH) is established.
+/// In a multithreaded environment, this function has to be called from
+/// the primary thread (LWP 0).
+///
+/// @return G&D error code
+GDPUBLIC gderror GDPROVAPI GDMCProvInitializeLibrary ( void );
+
+/// Performs a global shutdown of the G&D Provisioning API (library).
+/// After this call, all resources are cleaned up and all handles are
+/// closed. No functions except for GDMCProvInitializeLibrary may be
+/// called anymore.
+/// In a multithread environment, this function has to be called from
+/// the primary thread (LWP 0).
+///
+/// @return G&D error code
+GDPUBLIC gderror GDPROVAPI GDMCProvShutdownLibrary ( void );
+
+/// Creates one instance of the key provisioning (aka "device binding")
+///
+/// @param[in/out] provhandle pointer to memory location receiving the
+/// handle (in), the handle or 0 (out)
+///
+/// @return G&D error code
+GDPUBLIC gderror GDPROVAPI GDMCProvBeginProvisioning ( gdhandle *provhandle );
+
+/// Destroys one instance of the key provisioning (aka "device binding")
+///
+/// @param[in] provhandle the handle returned by GDMCProvBeginProvisioning
+///
+/// @return G&D error code
+GDPUBLIC gderror GDPROVAPI GDMCProvEndProvisioning ( gdhandle provhandle );
+
+/// Executes one provisioning step of the full sequence. The caller has to
+/// call this function in a loop until either an error is reported or the
+/// error code GDERROR_PROVISIONING_DONE is returned (meaning successful
+/// provisioning). Please refer to the MobiCore Provisioning API documentation
+/// for details.
+///
+/// @param[in] provhandle the handle returned by
+/// GDMCProvBeginProvisioning
+/// @param[in] msgin pointer to buffer containing the
+/// input message; may be NULL if no message
+/// available
+/// @param[in] msgin_size size of buffer pointed to by msgin in bytes
+/// @param[in/out] msgout pointer to buffer receiving the output
+/// message (in); output message (out)
+/// @param[in/out] msgout_size size of buffer pointed to by msgout in
+/// bytes (in); number of bytes copied to msgout
+/// (out)
+///
+/// @return G&D error code; GDERROR_PROVISIONING_DONE
+/// if provisioning successfully completed.
+GDPUBLIC gderror GDPROVAPI GDMCProvExecuteProvisioningStep (
+ gdhandle provhandle,
+ const _u8 *msgin,
+ _u32 msgin_size,
+ _u8 *msgout,
+ _u32 *msgout_size );
+
+/// [PRODUCTION STATION ONLY] Convenience function to format an SD.Receipt
+///
+/// @param[in] receipt pointer to buffer containing the
+/// binary SD.Receipt
+/// @param[in] receipt_size size of binary data pointed to by
+/// receipt in bytes
+/// @param[in/out] fmt_receipt pointer to buffer receiving the receipt as
+/// a BASE64-encoded string (in); the string (out)
+/// @param[in/out] fmt_receipt_size size of buffer pointed to by fmt_receipt in
+/// bytes (in); number of bytes copied to
+/// fmt_receipt (out)
+///
+/// @return G&D error code
+GDPUBLIC gderror GDPROVAPI GDMCProvFormatReceipt (
+ const _u8 *receipt,
+ _u32 receipt_size,
+ _u8 *fmt_receipt,
+ _u32 *fmt_receipt_size );
+
+/// [PRODUCTION STATION ONLY] Convenience function to query the SUID of
+/// the currently provisioned device (e.g. can be used as primary key in
+/// a production database)
+///
+/// @param[in] provhandle the handle returned by
+/// GDMCProvBeginProvisioning
+/// @param[in/out] suid pointer to buffer (16 octets, in) receiving the
+/// SUID of the current mobile device (out)
+///
+/// @return G&D error code
+GDPUBLIC gderror GDPROVAPI GDMCProvGetSUID (
+ gdhandle provhandle,
+ _u8 *suid );
+
+/// [DEVICE ONLY] Callback function called by the Provisioning API when
+/// GDMCProvExecuteProvisioningStep is executed in the Device. This function
+/// shall store the authentication token SO.AuthToken in a secure location.
+///
+/// @param[in] authtok pointer to buffer containing SO.AuthToken
+/// @param[in] authtok_size size of buffer pointed to be authtok;
+/// shall be 124 octets
+///
+/// @return G&D error code
+typedef gderror (*authtok_writecb)( const _u8 *authtok,
+ _u32 authtok_size );
+
+/// [DEVICE ONLY] Callback function called by the Provisioning API when
+/// GDMCProvExecuteValidationStep is executed in the Device. This function
+/// shall perform a read-back of the stored authentication token SO.AuthToken
+///
+/// @param[in/out] authtok pointer to buffer receiving SO.AuthToken
+/// (in); buffer filled with SO.AuthToken (out)
+/// @param[in/out] authtok_size size of buffer pointed to be authtok (in);
+/// number of bytes copied to authtok (out);
+/// shall be 124 octets
+///
+/// @return G&D error code
+typedef gderror (*authtok_readcb)( _u8 *authtok,
+ _u32 *authtok_size );
+
+/// [DEVICE ONLY] The OEM must provide two hook functions (callbacks) for the
+/// reading and writing of the authentication token SO.AuthToken in the device.
+///
+/// @param[in] writefunc callback function called by the Provisioning API
+/// when an authentication token SO.AuthToken has to be
+/// stored
+/// @param[in] readfunc callback function called by the Provisioning API
+/// when an authentication token SO.AuthToken has to be
+/// read back (for validation purposes)
+///
+/// @return G&D error code
+GDPUBLIC gderror GDPROVAPI GDMCProvSetAuthTokenCallbacks (
+ authtok_writecb writefunc,
+ authtok_readcb readfunc );
+
+/// [PRODUCTION STATION ONLY] The configuration of the provisioning library
+/// can be patched into the library binary file. If the OEM decided to perform
+/// the configuration e.g. by providing the configuration information via the
+/// production database, then this function can be called to configure the
+/// provisioning library.
+///
+/// @param[in] config_string a zero-terminated configuration string containing
+/// the entire configuration information in a format
+/// that will be defined by G&D; the exact format of
+/// this configuration information can be OEM-specific
+/// and will be specified in a separate document
+///
+/// @return G&D error code
+GDPUBLIC gderror GDPROVAPI GDMCProvSetConfigurationString (
+ const char *config_string );
+
+//////////////////////////////////////////////////////////////////////////////
+// Declaration of message header and trailer
+//////////////////////////////////////////////////////////////////////////////
+
+#ifdef WIN32
+
+#pragma warning ( disable : 4200 )
+
+#pragma pack(push,1)
+
+#define PACK_ATTR
+
+#else // Linux
+
+#define PACK_ATTR __attribute__((packed))
+
+#endif
+
+typedef struct _gdmc_msgheader gdmc_msgheader;
+typedef struct _gdmc_msgtrailer gdmc_msgtrailer;
+
+/// the G&D MobiCore message header
+struct _gdmc_msgheader
+{
+ _u32 msg_type; ///< message type
+ _u32 body_size; ///< size of body (may be 0)
+} PACK_ATTR;
+
+/// the G&D MobiCore message trailer
+struct _gdmc_msgtrailer
+{
+ _u32 magic; /// message type (one's complement)
+ _u32 crc32; /// CRC32 checksum
+} PACK_ATTR;
+
+#ifdef WIN32
+#pragma pack(pop)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _INC_GDPROVLIB_H_
+
--- /dev/null
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libgdmcprov
+LOCAL_MODULE_TAGS := debug eng optional
+
+LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/../inc_private \
+ $(LOCAL_PATH)/../inc_public \
+ $(MC_INCLUDE_DIR)
+
+LOCAL_SRC_FILES := ../src/gdmcprovlib.cpp \
+ ../src/crc32.c \
+ ../src/mobicore.c \
+ ../src/gdmcdevicebinding.cpp
+
+LOCAL_CFLAGS := -O2 -Wall -fomit-frame-pointer -DANDROID_ARM -DARM -D_LENDIAN -D_32BIT \
+ -fvisibility=hidden -I$(OPENSSL_INC_DIR) \
+ -DGDMCPROVLIB_VERSION=0x01000001 -D$(MC_DEBUG) \
+ -D_NO_OPENSSL_INCLUDES
+
+LOCAL_CXXFLAGS := -O2 -Wall -fomit-frame-pointer -DANDROID_ARM -DARM -D_LENDIAN -D_32BIT \
+ -fvisibility-inlines-hidden -fvisibility=hidden \
+ -DGDMCPROVLIB_VERSION=0x01000001 -D$(MC_DEBUG)
+
+LOCAL_CPPFLAGS := -O2 -Wall -fomit-frame-pointer -DANDROID_ARM -DARM -D_LENDIAN -D_32BIT \
+ -fvisibility-inlines-hidden -fvisibility=hidden \
+ -DGDMCPROVLIB_VERSION=0x01000001 -D$(MC_DEBUG)
+
+LOCAL_LDFLAGS := -Wl,-rpath-link,$(SYSTEM_LIB_DIR) \
+ -L$(SYSTEM_LIB_DIR) -llog
+
+LOCAL_SHARED_LIBRARIES := $(GDM_PROVLIB_SHARED_LIBS)
+
+include $(BUILD_SHARED_LIBRARY)
--- /dev/null
+#include <gdmcprovlib.h>
+#include <string.h>
+
+static _u32 crctable[256];
+
+_u32 GDPROVAPI CalcCRC32 ( const _u8 *data, _u32 length )
+{
+ _u32 crc = 0xFFFFFFFF;
+
+ while (length--)
+ crc = (crc>>8) ^ crctable[(crc&0xFF) ^ *data++];
+
+ return crc ^ 0xFFFFFFFF;
+}
+
+static _u32 GDPROVAPI reflect ( _u32 refl, _u8 c )
+{
+ int i;
+ _u32 value = 0;
+
+ // Swap bit 0 for bit 7, bit 1 For bit 6, etc....
+ for (i = 1; i < (c + 1); i++)
+ {
+ if (refl & 1)
+ value |= (1 << (c - i));
+ refl >>= 1;
+ }
+
+ return value;
+}
+
+void GDPROVAPI InitCRCTable ( void )
+{
+ int i,j;
+
+ memset(crctable,0,sizeof(crctable));
+
+ for (i = 0; i <= 0xFF; i++)
+ {
+ crctable[i] = reflect(i, 8) << 24;
+
+ for (j = 0; j < 8; j++)
+ crctable[i] = (crctable[i] << 1)
+ ^ ((crctable[i] & (1 << 31)) ? 0x04C11DB7 : 0);
+
+ crctable[i] = reflect(crctable[i], 32);
+ }
+}
+
--- /dev/null
+///
+/// @file gdmcdevicebinding.cpp
+/// @author Giesecke & Devrient GmbH, Munich, Germany
+///
+/// Implementation of the (internal) device binding
+///
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <gdmcprovlib.h>
+#include <gdmcprovprotocol.h>
+#include <gdmcinstance.h>
+
+extern "C"
+{
+ gderror MCGetSUID ( _u8 *suid );
+
+ gderror MCGenerateAuthToken ( gdmcinst *inst, const gdmc_actmsg_req *req, gdmc_so_authtok *authtok );
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// MS Windows-specific includes
+//////////////////////////////////////////////////////////////////////////////
+
+#if defined(WIN32)
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#ifdef _DEBUG
+#include <crtdbg.h>
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+// Linux-specific includes
+//////////////////////////////////////////////////////////////////////////////
+
+#elif defined(LINUX)
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <syslog.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+
+//////////////////////////////////////////////////////////////////////////////
+// ARM-specific includes
+//////////////////////////////////////////////////////////////////////////////
+
+#else // ARM
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+
+#endif
+
+#include <gdmcprovprotocol.h>
+#include <gdmcinstance.h>
+#include <gdmcdevicebinding.h>
+
+#define MAX_MSGSIZE 4096
+
+extern authtok_writecb g_authtok_writecb;
+extern authtok_readcb g_authtok_readcb;
+
+#ifdef WIN32
+#define vsnprintf _vsnprintf
+
+#pragma warning ( disable : 4996 )
+
+#endif
+
+#ifdef ARM
+
+extern "C" void GDMCLog ( int prio, const char *tag, const char *fmt, ... )
+{
+ va_list ap;
+
+ va_start(ap,fmt);
+#if defined(WIN32) || defined(LINUX)
+ {
+ char buffer[1024];
+ FILE *f = fopen("libMcClient.log","at");
+ if (likely(NULL!=f))
+ {
+ vsprintf(buffer,fmt,ap);
+ fprintf(f,"[%i][%s] %s\n",prio,tag,buffer);
+ fclose(f);
+ }
+ }
+#else
+ __android_log_vprint(prio,tag,fmt,ap);
+#endif
+ va_end(ap);
+}
+
+#ifdef _DEBUG
+extern "C" void GDMCHexDump ( const unsigned char *data, int size )
+{
+ static char szHexLine[80], szHex[12];
+ unsigned char x, h, l;
+ int i,j;
+
+ if (!size)
+ return;
+
+ while (size>0)
+ {
+ memset(szHexLine,0x20,sizeof(szHexLine));
+ szHexLine[77] = 0x00;
+ szHexLine[78] = 0x00;
+ if (size>8)
+ szHexLine[34] = '-';
+
+ snprintf(szHex, 8 + 1, "%08X",(uintptr_t)data);
+ memcpy(szHexLine,szHex,8);
+
+ i=0;j=0;
+ while (size>0)
+ {
+ x = *(data++);
+ size--;
+ h = (x>>4)+0x30;
+ l = (x&15)+0x30;
+ if (h>0x39) h+=7;
+ if (l>0x39) l+=7;
+ szHexLine[i*3+10+j] = (char)h;
+ szHexLine[i*3+11+j] = (char)l;
+
+ if ((x<32) || (x>=127)) x = '.';
+
+ szHexLine[i+61] = (char)x;
+
+ i++;
+ if (8==i)
+ j = 2;
+ if (16==i)
+ break;
+ }
+
+ LOG_d("%s",szHexLine);
+ }
+}
+
+#endif // _DEBUG
+
+#endif // ARM
+
+gderror GDMCComposeErrorMessage ( gdmcinst *inst __unused, gderror error, _u8 *msgout, _u32 *msgout_size, _u32 initial_msgout_size, const char *pszmsg, ... )
+{
+ _u32 msgsize = 0;
+ gdmc_msgheader *header;
+ gdmc_error_msg *body;
+ gdmc_msgtrailer *trailer;
+ va_list ap;
+ char *buffer = NULL;
+ _u32 errmsgsize = 0;
+ _u32 errmsgsize_aligned;
+
+ if (NULL!=pszmsg)
+ {
+ buffer = (char*)malloc(MAX_MSGSIZE);
+
+ if (NULL!=buffer)
+ {
+ memset(buffer,0,MAX_MSGSIZE);
+ va_start(ap,pszmsg);
+ vsnprintf(buffer,MAX_MSGSIZE,pszmsg,ap);
+ va_end(ap);
+
+ errmsgsize = ((_u32)strlen(buffer))+1;
+ if (1==errmsgsize)
+ errmsgsize--; // if empty message, then do not send anything
+ }
+ }
+
+ errmsgsize_aligned = (errmsgsize+3)&(~3);
+
+ // compose MC_ERROR message
+
+ msgsize = sizeof(gdmc_msgheader)+sizeof(gdmc_error_msg)+errmsgsize_aligned+sizeof(gdmc_msgtrailer);
+
+ if (msgsize>initial_msgout_size)
+ {
+ if (NULL!=buffer)
+ free(buffer);
+ return GDERROR_BUFFER_TOO_SMALL;
+ }
+
+ header = (gdmc_msgheader*)msgout;
+ body = (gdmc_error_msg*)(msgout+sizeof(gdmc_msgheader));
+ trailer = (gdmc_msgtrailer*)(msgout+sizeof(gdmc_msgheader)+sizeof(gdmc_error_msg)+errmsgsize_aligned);
+
+ header->msg_type = MC_ERROR;
+ header->body_size = sizeof(gdmc_error_msg)+errmsgsize;
+
+ body->errorcode = error;
+ body->errmsg_length = errmsgsize_aligned;
+
+ if ((NULL!=buffer) && (0!=errmsgsize))
+ {
+ memset(body->errmsg,0,errmsgsize_aligned);
+ memcpy(body->errmsg,buffer,errmsgsize);
+ }
+
+ if (NULL!=buffer)
+ free(buffer);
+
+ trailer->magic = ~MC_ERROR;
+ trailer->crc32 = CalcCRC32(msgout,msgsize-sizeof(_u32));
+
+ *msgout_size = msgsize;
+
+ return GDERROR_OK;
+}
+
+gderror GDPROVAPI GDMCValidateProvMessage ( const _u8 *msg,
+ _u32 msgsize,
+ gdmc_msgheader **ppheader,
+ _u8 **ppbody,
+ gdmc_msgtrailer **pptrailer )
+{
+ _u32 expected_msgsize, aligned_body_size;
+ _u32 crc32;
+ gdmc_error_msg *errmsg;
+ gdmc_actmsg_resp *actmsg;
+
+ *ppheader = NULL;
+ *ppbody = NULL;
+ *pptrailer = NULL;
+
+ if (msgsize<(sizeof(gdmc_msgheader)+sizeof(gdmc_msgtrailer)))
+ return GDERROR_MESSAGE_FORMAT;
+
+ if (msgsize&3)
+ return GDERROR_MESSAGE_FORMAT;
+
+ if (IsBadReadPtr(msg,sizeof(gdmc_msgheader)+sizeof(gdmc_msgtrailer)))
+ return GDERROR_PARAMETER;
+
+ *ppheader = (gdmc_msgheader*)msg;
+
+ aligned_body_size = ((*ppheader)->body_size+3)&(~3);
+
+ expected_msgsize = sizeof(gdmc_msgheader)+sizeof(gdmc_msgtrailer)+aligned_body_size;
+
+ if (msgsize!=expected_msgsize)
+ return GDERROR_MESSAGE_FORMAT;
+
+ if (IsBadReadPtr(msg,expected_msgsize))
+ return GDERROR_PARAMETER;
+
+ *ppbody = (_u8*)(msg+sizeof(gdmc_msgheader));
+ *pptrailer = (gdmc_msgtrailer*)((*ppbody)+aligned_body_size);
+
+ if ( (*ppheader)->msg_type != (~((*pptrailer)->magic)) )
+ return GDERROR_MESSAGE_FORMAT;
+
+ crc32 = CalcCRC32(msg,msgsize-sizeof(_u32));
+
+ if ( crc32 != (*pptrailer)->crc32 )
+ return GDERROR_CRC32;
+
+ switch((*ppheader)->msg_type)
+ {
+ case MC_GETSUID_REQ:
+ if ( 0!=(*ppheader)->body_size)
+ return GDERROR_MESSAGE_FORMAT;
+ break;
+
+ case MC_GETSUID_RESP:
+ if ( SUID_LENGTH!=(*ppheader)->body_size)
+ return GDERROR_MESSAGE_FORMAT;
+ break;
+
+ case MC_GENAUTHTOKEN_REQ:
+ if ( sizeof(gdmc_actmsg_req)!=(*ppheader)->body_size)
+ return GDERROR_MESSAGE_FORMAT;
+ if ( MC_CMP_CMD_GENERATE_AUTH_TOKEN != ((gdmc_actmsg_req*)(*ppbody))->msg_type )
+ return GDERROR_MESSAGE_FORMAT;
+ break;
+
+ case MC_GENAUTHTOKEN_RESP:
+ if ( sizeof(gdmc_actmsg_resp)!=(*ppheader)->body_size)
+ return GDERROR_MESSAGE_FORMAT;
+ actmsg = (gdmc_actmsg_resp*)*ppbody;
+ if ( (MC_CMP_CMD_GENERATE_AUTH_TOKEN|0x80000000) != actmsg->msg_type )
+ return GDERROR_MESSAGE_FORMAT;
+ if ( (SUID_LENGTH+(sizeof(_u32)*3)) != actmsg->authtok.plain_length)
+ return GDERROR_MESSAGE_FORMAT;
+ if ( (K_SOC_AUTH_LENGTH/*+SHA256_HASH_LENGTH+AES_BLOCK_SIZE*/) != actmsg->authtok.encrypted_length )
+ return GDERROR_MESSAGE_FORMAT;
+ if ( AUTHENTICATION_TOKEN != actmsg->authtok.type )
+ return GDERROR_MESSAGE_FORMAT;
+ if ( CONTEXT_SYSTEM != actmsg->authtok.context )
+ return GDERROR_MESSAGE_FORMAT;
+ if ( CONT_TYPE_SOC != actmsg->authtok.contType )
+ return GDERROR_MESSAGE_FORMAT;
+ if ( MC_CONT_STATE_ACTIVATED != actmsg->authtok.contState )
+ return GDERROR_MESSAGE_FORMAT;
+ break;
+
+ case MC_VALIDATEAUTHTOKEN_REQ:
+ if ( sizeof(gdmc_so_authtok)!=(*ppheader)->body_size)
+ return GDERROR_MESSAGE_FORMAT;
+ break;
+
+ case MC_ERROR:
+ if ( (*ppheader)->body_size<sizeof(gdmc_error_msg))
+ return GDERROR_MESSAGE_FORMAT;
+ errmsg = (gdmc_error_msg*)*ppbody;
+ if ( (*ppheader)->body_size!=(errmsg->errmsg_length+sizeof(gdmc_error_msg)) )
+ return GDERROR_MESSAGE_FORMAT;
+ break;
+
+ default:
+ return GDERROR_MESSAGE_FORMAT;
+ }
+
+ return GDERROR_OK;
+}
+
+gderror GDPROVAPI GDMCHandleGetSUID ( gdmcinst *inst,
+ _u8 *msgout,
+ _u32 *msgout_size,
+ _u32 initial_msgout_size )
+{
+ _u32 msgsize = sizeof(gdmc_msgheader)+SUID_LENGTH+sizeof(gdmc_msgtrailer);
+ gdmc_msgheader *header = (gdmc_msgheader*)msgout;
+ _u8 *body = msgout+sizeof(gdmc_msgheader);
+ gdmc_msgtrailer *trailer = (gdmc_msgtrailer*)(msgout+sizeof(gdmc_msgheader)+SUID_LENGTH);
+ gderror error;
+
+ if (msgsize>initial_msgout_size)
+ return GDMCComposeErrorMessage(inst,GDERROR_BUFFER_TOO_SMALL,msgout,msgout_size,initial_msgout_size,
+ ERRMSG_0005,initial_msgout_size,msgsize);
+
+ if (inst->state<GDMC_STATE_HAVE_SUID) // request SUID from MobiCore
+ {
+ error = MCGetSUID(inst->suid);
+
+ if (GDERROR_OK!=error)
+ return GDMCComposeErrorMessage(inst,error,msgout,msgout_size,initial_msgout_size,
+ ERRMSG_000D);
+
+ inst->state = GDMC_STATE_HAVE_SUID;
+ }
+
+ // We have the SUID, so return the message to the caller
+
+ header->msg_type = MC_GETSUID_RESP;
+ header->body_size = SUID_LENGTH;
+
+ memcpy(body,inst->suid,SUID_LENGTH);
+
+ trailer->magic = ~MC_GETSUID_RESP;
+ trailer->crc32 = CalcCRC32(msgout,msgsize-sizeof(_u32));
+
+ *msgout_size = msgsize;
+
+ return GDERROR_OK;
+}
+
+gderror GDPROVAPI GDMCHandleGenAuthToken ( gdmcinst *inst,
+ gdmc_actmsg_req *req,
+ _u8 *msgout,
+ _u32 *msgout_size,
+ _u32 initial_msgout_size )
+{
+ _u32 msgsize = sizeof(gdmc_msgheader)+sizeof(gdmc_actmsg_resp)+sizeof(gdmc_msgtrailer);
+ gdmc_msgheader *header = (gdmc_msgheader*)msgout;
+ gdmc_actmsg_resp *body = (gdmc_actmsg_resp*)(msgout+sizeof(gdmc_msgheader));
+ gdmc_msgtrailer *trailer = (gdmc_msgtrailer*)(msgout+sizeof(gdmc_msgheader)+sizeof(gdmc_actmsg_resp));
+ gderror error;
+
+ if (msgsize>initial_msgout_size)
+ return GDMCComposeErrorMessage(inst,GDERROR_BUFFER_TOO_SMALL,msgout,msgout_size,initial_msgout_size,
+ ERRMSG_0005,initial_msgout_size,msgsize);
+
+ switch(inst->state)
+ {
+ case GDMC_STATE_INITIAL: // We do not have the SUID, so get it...
+ error = GDMCHandleGetSUID(inst,msgout,msgout_size,initial_msgout_size);
+ if (GDERROR_OK!=error)
+ return error;
+
+ // discard this message...
+
+ memset(msgout,0,initial_msgout_size);
+ *msgout_size = 0;
+
+ // fall through...
+
+ case GDMC_STATE_HAVE_SUID: // We have the SUID but no SO.AuthToken (yet)
+
+ GenerateAuthToken:
+
+ memcpy(inst->kSoCAuth,req->kSoCAuth,sizeof(inst->kSoCAuth)); // save K.SoC.Auth
+
+ error = MCGenerateAuthToken(inst,req,&inst->authTok);
+
+ if (GDERROR_OK!=error)
+ return GDMCComposeErrorMessage(inst,error,msgout,msgout_size,initial_msgout_size,ERRMSG_000E);
+
+ if (NULL!=g_authtok_writecb)
+ {
+ error = g_authtok_writecb((const _u8 *)&inst->authTok,sizeof(gdmc_so_authtok));
+ if (GDERROR_OK!=error)
+ return GDMCComposeErrorMessage(inst,error,msgout,msgout_size,initial_msgout_size,ERRMSG_000C);
+ }
+
+ header->msg_type = MC_GENAUTHTOKEN_RESP;
+ header->body_size = sizeof(gdmc_actmsg_resp);
+
+ body->msg_type = MC_CMP_CMD_GENERATE_AUTH_TOKEN|0x80000000;
+ memcpy(&body->authtok,&inst->authTok,sizeof(gdmc_so_authtok));
+
+ trailer->magic = ~MC_GENAUTHTOKEN_RESP;
+ trailer->crc32 = CalcCRC32(msgout,msgsize-sizeof(_u32));
+
+ *msgout_size = msgsize;
+
+ if (inst->state<GDMC_STATE_HAVE_AUTHTOK)
+ inst->state = GDMC_STATE_HAVE_AUTHTOK;
+
+ return GDERROR_OK;
+
+ default: //case GDMC_STATE_HAVE_AUTHTOK: -> We have already the SO.AuthTok, check if K.SoC.Auth still matches!!!
+
+ if (memcmp(inst->kSoCAuth,req->kSoCAuth,sizeof(inst->kSoCAuth)))
+ {
+ // Oh oh... the KPH generated a new K.SoC.Auth and our SO.AuthToken is invalid now... (generate new one)
+
+ memset(&inst->authTok,0,sizeof(inst->authTok));
+ inst->state = GDMC_STATE_HAVE_SUID;
+ goto GenerateAuthToken;
+ }
+
+ // Okay, K.SoC.Auth still matches and we still have the SO.AuthToken
+
+ header->msg_type = MC_GENAUTHTOKEN_RESP;
+ header->body_size = sizeof(gdmc_actmsg_resp);
+
+ body->msg_type = MC_CMP_CMD_GENERATE_AUTH_TOKEN|0x80000000;
+ memcpy(&body->authtok,&inst->authTok,sizeof(gdmc_so_authtok));
+
+ trailer->magic = ~MC_GENAUTHTOKEN_RESP;
+ trailer->crc32 = CalcCRC32(msgout,msgsize-sizeof(_u32));
+
+ *msgout_size = msgsize;
+
+ return GDERROR_OK;
+ }
+}
+
+gderror GDPROVAPI GDMCHandleValidateAuthToken ( gdmcinst *inst,
+ gdmc_so_authtok *validateSoAuthTok,
+ _u8 *msgout,
+ _u32 *msgout_size,
+ _u32 initial_msgout_size )
+{
+ _u32 msgsize = sizeof(gdmc_msgheader)+sizeof(gdmc_error_msg)+sizeof(gdmc_msgtrailer);
+ gdmc_msgheader *header = (gdmc_msgheader*)msgout;
+ gdmc_error_msg *body = (gdmc_error_msg*)(msgout+sizeof(gdmc_msgheader));
+ gdmc_msgtrailer *trailer = (gdmc_msgtrailer*)(msgout+sizeof(gdmc_msgheader)+sizeof(gdmc_error_msg));
+ gderror error;
+ gdmc_so_authtok rb_authtok;
+ _u32 rb_authtok_size;
+
+ if (msgsize>initial_msgout_size)
+ return GDMCComposeErrorMessage(inst,GDERROR_BUFFER_TOO_SMALL,msgout,msgout_size,initial_msgout_size,
+ ERRMSG_0005,initial_msgout_size,msgsize);
+
+ if (GDMC_STATE_HAVE_AUTHTOK!=inst->state) // Too early call: We do not have an SO.AuthToken to be validated!
+ return GDMCComposeErrorMessage(inst,GDERROR_VALIDATION_FAILURE,msgout,msgout_size,initial_msgout_size,
+ ERRMSG_000F,initial_msgout_size,msgsize);
+
+ header->msg_type = MC_ERROR;
+ header->body_size = sizeof(gdmc_error_msg);
+
+ body->errorcode = GDERROR_PROVISIONING_DONE;
+
+ // 1.) First of all, compare the delivered SO.AuthToken with the one we have stored in our instance
+
+ if (memcmp(validateSoAuthTok,&inst->authTok,sizeof(gdmc_so_authtok)))
+ {
+ body->errorcode = GDERROR_VALIDATION_FAILURE;
+ }
+ else
+ {
+ // 2.) Perform readback (if available) and re-check auth token
+
+ if (NULL!=g_authtok_readcb)
+ {
+ rb_authtok_size = sizeof(rb_authtok);
+
+ error = g_authtok_readcb((_u8*)&rb_authtok,&rb_authtok_size);
+
+ if (GDERROR_OK!=error)
+ body->errorcode = error;
+ else
+ {
+ if ( (rb_authtok_size!=sizeof(gdmc_so_authtok)) ||
+ (memcmp(validateSoAuthTok,&rb_authtok,sizeof(gdmc_so_authtok))) )
+ body->errorcode = GDERROR_VALIDATION_FAILURE;
+ }
+ }
+ }
+
+ trailer->magic = ~MC_ERROR;
+ trailer->crc32 = CalcCRC32(msgout,msgsize-sizeof(_u32));
+
+ *msgout_size = msgsize;
+
+ return GDERROR_PROVISIONING_DONE;
+}
--- /dev/null
+///
+/// @file gdmcprovlib.cpp
+/// @author Giesecke & Devrient GmbH, Munich, Germany
+///
+/// Implementation of the API functions (Provisioning
+/// Library)
+///
+
+#include <gdmcprovlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+
+//////////////////////////////////////////////////////////////////////////////
+// MS Windows-specific includes
+//////////////////////////////////////////////////////////////////////////////
+
+#if defined(WIN32)
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+static HMODULE g_hInstance = NULL;
+
+//////////////////////////////////////////////////////////////////////////////
+// Linux-specific includes
+//////////////////////////////////////////////////////////////////////////////
+
+#elif defined(LINUX)
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <syslog.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+
+//////////////////////////////////////////////////////////////////////////////
+// ARM-specific includes
+//////////////////////////////////////////////////////////////////////////////
+
+#else // ARM
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+
+#endif
+
+#include <gdmcprovprotocol.h>
+#include <gdmcinstance.h>
+#include <gdmcdevicebinding.h>
+
+extern "C" {
+extern bool mccmOpen ( void );
+extern void mccmClose ( void );
+}
+
+authtok_writecb g_authtok_writecb = NULL;
+authtok_readcb g_authtok_readcb = NULL;
+
+//////////////////////////////////////////////////////////////////////////////
+// API functions (implementation)
+//////////////////////////////////////////////////////////////////////////////
+
+// this API function is not available on ARM
+static gderror GDPROVAPI _GDMCProvFormatErrorMessage (
+ gdhandle provhandle __unused,
+ gderror errorcode __unused,
+ char *msgbuf __unused,
+ _u32 *size __unused )
+{
+ LOG_d("++++ ENTERED GDMCProvFormatErrorMessage: NOT IMPLEMENTED.");
+ return GDERROR_NOT_IMPLEMENTED;
+}
+
+static gderror GDPROVAPI _GDMCProvInitializeLibrary ( void )
+{
+ LOG_d("++++ ENTERED GDMCProvInitializeLibrary.");
+
+ if (unlikely( !mccmOpen() ))
+ {
+ LOG_e("CMTL open FAILED.");
+ LOG_d("++++ LEFT GDMCProvInitializeLibrary.");
+ return GDERROR_MOBICORE_LIBRARY;
+ }
+
+ LOG_i("CMTL open successful.");
+
+ LOG_d("++++ LEFT GDMCProvInitializeLibrary.");
+
+ return GDERROR_OK;
+}
+
+static gderror GDPROVAPI _GDMCProvShutdownLibrary ( void )
+{
+ mccmClose();
+ return GDERROR_OK;
+}
+
+static gderror GDPROVAPI _GDMCProvBeginProvisioning ( gdhandle *provhandle )
+{
+ gdmcinst *inst;
+
+ if (IsBadWritePtr(provhandle,sizeof(gdhandle)))
+ return GDERROR_PARAMETER;
+
+ inst = (gdmcinst*)malloc(sizeof(gdmcinst));
+
+ if (NULL==inst)
+ {
+ *provhandle = 0;
+ return GDERROR_INSUFFICIENT_MEMORY;
+ }
+
+ memset(inst,0,sizeof(gdmcinst));
+
+ *provhandle = (gdhandle)(uintptr_t)inst;
+
+ return GDERROR_OK;
+}
+
+static gderror GDPROVAPI _GDMCProvEndProvisioning ( gdhandle provhandle )
+{
+ gdmcinst *inst = (gdmcinst*)(uintptr_t)provhandle;
+
+ if (IsBadWritePtr(inst,sizeof(gdmcinst)))
+ return GDERROR_PARAMETER;
+
+ free(inst);
+
+ return GDERROR_OK;
+}
+
+static gderror GDPROVAPI _GDMCProvExecuteProvisioningStep (
+ gdhandle provhandle,
+ const _u8 *msgin,
+ _u32 msgin_size,
+ _u8 *msgout,
+ _u32 *msgout_size )
+{
+ gderror error = GDERROR_OK;
+ gdmcinst *inst = (gdmcinst*)(uintptr_t)provhandle;
+ gdmc_msgheader *header = NULL;
+ _u8 *body = NULL;
+ gdmc_msgtrailer *trailer = NULL;
+ _u32 initial_msgout_size;
+
+ // 1.) Prolog: Check parameters...
+
+ if (IsBadWritePtr(inst,sizeof(gdmcinst)))
+ return GDERROR_PARAMETER;
+
+ if ((0!=msgin_size) && (IsBadReadPtr(msgin,msgin_size)))
+ return GDERROR_PARAMETER;
+
+ if (IsBadWritePtr(msgout_size,sizeof(_u32)))
+ return GDERROR_PARAMETER;
+
+ initial_msgout_size = *msgout_size;
+
+ if (0!=*msgout_size)
+ {
+ if (IsBadWritePtr(msgout,*msgout_size))
+ return GDERROR_PARAMETER;
+ memset(msgout,0,*msgout_size);
+ }
+
+ *msgout_size = 0;
+
+ // 2.) Evaluate the message that has been received
+
+ error = GDMCValidateProvMessage(msgin,msgin_size,&header,&body,&trailer);
+
+ if (GDERROR_OK!=error) // something is wrong with the received message
+ return GDMCComposeErrorMessage(inst,error,msgout,msgout_size,initial_msgout_size,ERRMSG_0006);
+
+ // 3.) Check which message has been received
+
+ switch(header->msg_type)
+ {
+ case MC_GETSUID_REQ:
+ return GDMCHandleGetSUID(inst,msgout,msgout_size,initial_msgout_size);
+
+ case MC_GENAUTHTOKEN_REQ:
+ return GDMCHandleGenAuthToken(inst,(gdmc_actmsg_req*)body,msgout,msgout_size,initial_msgout_size);
+
+ case MC_VALIDATEAUTHTOKEN_REQ:
+ return GDMCHandleValidateAuthToken(inst,(gdmc_so_authtok*)body,msgout,msgout_size,initial_msgout_size);
+
+ default:
+ return GDMCComposeErrorMessage(inst,GDERROR_UNKNOWN,msgout,msgout_size,initial_msgout_size,ERRMSG_0007);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Structured Exception Handling (Windows only)
+//////////////////////////////////////////////////////////////////////////////
+
+#if defined(WIN32) && !defined(_NO_STRUCTURED_EXCEPTIONS)
+
+static DWORD GDPROVAPI HandleStructuredException ( DWORD dwExcepCode )
+{
+#ifndef _DEBUG
+ return EXCEPTION_EXECUTE_HANDLER;
+#else // _DEBUG
+ switch(dwExcepCode)
+ {
+ case EXCEPTION_BREAKPOINT:
+ case EXCEPTION_SINGLE_STEP:
+ return EXCEPTION_CONTINUE_SEARCH;
+ default:
+ return EXCEPTION_EXECUTE_HANDLER;
+ }
+#endif
+}
+
+#define SE_TRY __try {
+#define SE_CATCH } __except(HandleStructuredException(GetExceptionCode())) { return GDERROR_CPU_EXCEPTION; }
+
+#else // !WIN32 || _NO_STRUCTURED_EXCEPTIONS
+
+#define SE_TRY
+#define SE_CATCH
+
+#endif // WIN32
+
+//////////////////////////////////////////////////////////////////////////////
+// API functions (exported)
+//////////////////////////////////////////////////////////////////////////////
+
+extern "C" _u32 GDPROVAPI GDMCProvGetVersion ( void )
+{
+ return GDMCPROVLIB_VERSION;
+}
+
+extern "C" gderror GDPROVAPI GDMCProvFormatErrorMessage (
+ gdhandle provhandle,
+ gderror errorcode,
+ char *msgbuf,
+ _u32 *size )
+{
+ SE_TRY // MUST BE FIRST INSTRUCTION ////////////////////////////////////////
+
+ return _GDMCProvFormatErrorMessage(provhandle,errorcode,msgbuf,size);
+
+ SE_CATCH // MUST BE LAST INSTRUCTION ///////////////////////////////////////
+}
+
+extern "C" gderror GDPROVAPI GDMCProvInitializeLibrary ( void )
+{
+ SE_TRY // MUST BE FIRST INSTRUCTION ////////////////////////////////////////
+
+ return _GDMCProvInitializeLibrary();
+
+ SE_CATCH // MUST BE LAST INSTRUCTION ///////////////////////////////////////
+}
+
+extern "C" gderror GDPROVAPI GDMCProvShutdownLibrary ( void )
+{
+ SE_TRY // MUST BE FIRST INSTRUCTION ////////////////////////////////////////
+
+ return _GDMCProvShutdownLibrary();
+
+ SE_CATCH // MUST BE LAST INSTRUCTION ///////////////////////////////////////
+}
+
+extern "C" gderror GDPROVAPI GDMCProvBeginProvisioning ( gdhandle *provhandle )
+{
+ SE_TRY // MUST BE FIRST INSTRUCTION ////////////////////////////////////////
+
+ return _GDMCProvBeginProvisioning(provhandle);
+
+ SE_CATCH // MUST BE LAST INSTRUCTION ///////////////////////////////////////
+}
+
+extern "C" gderror GDPROVAPI GDMCProvEndProvisioning ( gdhandle provhandle )
+{
+ SE_TRY // MUST BE FIRST INSTRUCTION ////////////////////////////////////////
+
+ return _GDMCProvEndProvisioning(provhandle);
+
+ SE_CATCH // MUST BE LAST INSTRUCTION ///////////////////////////////////////
+}
+
+extern "C" gderror GDPROVAPI GDMCProvExecuteProvisioningStep (
+ gdhandle provhandle,
+ const _u8 *msgin,
+ _u32 msgin_size,
+ _u8 *msgout,
+ _u32 *msgout_size )
+{
+ SE_TRY // MUST BE FIRST INSTRUCTION ////////////////////////////////////////
+
+ return _GDMCProvExecuteProvisioningStep(provhandle,msgin,msgin_size,
+ msgout,msgout_size);
+
+ SE_CATCH // MUST BE LAST INSTRUCTION ///////////////////////////////////////
+}
+
+extern "C" gderror GDPROVAPI GDMCProvFormatReceipt (
+ const _u8 *receipt __unused,
+ _u32 receipt_size __unused,
+ _u8 *fmt_receipt __unused,
+ _u32 *fmt_receipt_size __unused )
+{
+ return GDERROR_NOT_IMPLEMENTED;
+}
+
+extern "C" gderror GDPROVAPI GDMCProvGetSUID (
+ gdhandle provhandle __unused,
+ _u8 *suid __unused )
+{
+ return GDERROR_NOT_IMPLEMENTED;
+}
+
+extern "C" gderror GDPROVAPI GDMCProvSetAuthTokenCallbacks (
+ authtok_writecb writefunc,
+ authtok_readcb readfunc )
+{
+ g_authtok_writecb = writefunc;
+ g_authtok_readcb = readfunc;
+
+ return GDERROR_OK;
+}
+
+extern "C" gderror GDPROVAPI GDMCProvSetConfigurationString (
+ const char *config_string __unused )
+{
+#ifdef ARM
+
+ return GDERROR_NOT_IMPLEMENTED;
+
+#else
+
+ SE_TRY // MUST BE FIRST INSTRUCTION ////////////////////////////////////////
+
+ return GDERROR_OK;
+
+ SE_CATCH // MUST BE LAST INSTRUCTION ///////////////////////////////////////
+
+#endif
+}
+
+#ifdef WIN32
+
+/// DLL main function required by MS Windows DLLs
+///
+/// @param[in] hinstDLL instance handle (module)
+/// @param[in] fdwReason reason for calling (attach, detach, ...)
+/// @param[in] lpvReserved reserved
+///
+/// @return TRUE if DLL loading/unloading successful, FALSE otherwise
+BOOL WINAPI DllMain ( HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved )
+{
+ switch(fdwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ // We don't need additional calls with DLL_THREAD_ATTACH.
+ g_hInstance = (HMODULE)hinstDLL;
+ DisableThreadLibraryCalls(hinstDLL);
+ InitCRCTable();
+ return TRUE;
+ case DLL_PROCESS_DETACH: // fall through
+ case DLL_THREAD_ATTACH: // fall through
+ case DLL_THREAD_DETACH:
+ return TRUE;
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+#else // library initialization and cleanup (Linux/ARM)
+
+void gdmcprovlib_init ( void ) __attribute__((constructor));
+void gdmcprovlib_fini ( void ) __attribute__((destructor));
+
+/// shared object global initialization function; gets automatically
+/// called when library is loaded
+void gdmcprovlib_init ( void )
+{
+ InitCRCTable();
+}
+
+/// shared object global cleanup function; gets automatically
+/// called when library is unloaded
+void gdmcprovlib_fini ( void )
+{
+
+}
+
+#endif // WIN32
--- /dev/null
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <gdmcprovlib.h>
+#include <gdmcprovprotocol.h>
+#include <gdmcinstance.h>
+
+typedef struct tagMCCM MCCM;
+
+struct tagMCCM
+{
+ cmp_t *cmp; ///< World Shared Memory (WSM) to the TCI buffer
+ mcSessionHandle_t sess; ///< session handle
+ mcResult_t lasterror; ///< last MC driver error
+ cmpReturnCode_t lastcmperr; ///< last Content Management Protocol error
+ uint32_t lastmccmerr; ///< error code from MCCM (MobiCore Content Management) library
+};
+
+static MCCM g_mccm;
+
+#ifdef ARM
+
+extern void GDMCLog ( int prio, const char *tag, const char *fmt, ... );
+
+#ifdef _DEBUG
+extern void GDMCHexDump ( const unsigned char *data, int size );
+#else
+#define GDMCHexDump(...) do { } while(0)
+#endif
+
+#define LOG_TAG "GDMCProvLib"
+
+#ifdef _DEBUG
+#define LOG_d(...) do { GDMCLog(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__); } while(0)
+#else
+#define LOG_d(...) do { } while(0)
+#endif
+#define LOG_i(...) do { GDMCLog(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__); } while(0)
+#define LOG_w(...) do { GDMCLog(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__); } while(0)
+#define LOG_e(...) do { GDMCLog(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__); } while(0)
+
+#else
+
+#define LOG_d(...) do { } while(0)
+#define LOG_i(...) do { } while(0)
+#define LOG_w(...) do { } while(0)
+#define LOG_e(...) do { } while(0)
+
+#endif // ARM
+
+static void dumpErrorInformation ( const char *function, mcResult_t result )
+{
+ int32_t lastErr = -1;
+
+ LOG_e("%s returned error %u (0x%08X)",function,result,result);
+
+ if (MC_DRV_OK==mcGetSessionErrorCode(&g_mccm.sess,&lastErr))
+ {
+ LOG_e("mcGetSessionErrorCode for %s returned %i (0x%08X)",function,lastErr,lastErr);
+ }
+ else
+ {
+ LOG_i("No additional error code for %s from mcGetSessionErrorCode available.",function);
+ }
+}
+
+// Copied from MCCM library not to have this additional dependency!
+
+// returns 1 if successful, 0 otherwise
+bool mccmOpen ( void )
+{
+ const mcUuid_t UUID = TL_CM_UUID;
+ mcResult_t result;
+
+ LOG_d("++++ ENTERED mccmOpen.");
+
+ memset(&g_mccm,0,sizeof(MCCM));
+
+ result = mcOpenDevice(MC_DEVICE_ID_DEFAULT);
+
+ if (MC_DRV_OK != result)
+ {
+ LOG_e("mcOpenDevice returned error %u",result);
+ LOG_d("++++ LEFT mccmOpen.");
+ return false;
+ }
+
+ result = mcMallocWsm(MC_DEVICE_ID_DEFAULT, 0, sizeof(cmp_t), (uint8_t **)&g_mccm.cmp, 0);
+ if (MC_DRV_OK != result)
+ {
+ LOG_e("mcMallocWsm returned error %u",result);
+ mcCloseDevice(MC_DEVICE_ID_DEFAULT);
+ LOG_d("++++ LEFT mccmOpen.");
+ return false;
+ }
+
+ result = mcOpenSession(&g_mccm.sess,(const mcUuid_t *)&UUID,(uint8_t *)g_mccm.cmp,(uint32_t)sizeof(cmp_t));
+ if (MC_DRV_OK != result)
+ {
+ LOG_e("mcOpenSession returned error %u",result);
+ mcFreeWsm(MC_DEVICE_ID_DEFAULT,(uint8_t*)g_mccm.cmp);
+ mcCloseDevice(MC_DEVICE_ID_DEFAULT);
+ LOG_d("++++ LEFT mccmOpen.");
+ return false;
+ }
+
+ LOG_d("++++ LEFT mccmOpen.");
+ return true;
+}
+
+void mccmClose ( void )
+{
+ mcResult_t result;
+ LOG_d("++++ ENTERED mccmClose.");
+
+ result = mcCloseSession(&g_mccm.sess);
+ if (MC_DRV_OK != result)
+ {
+ LOG_e("mcCloseSession returned error %u",result);
+ }
+
+ if (NULL!=g_mccm.cmp)
+ mcFreeWsm(MC_DEVICE_ID_DEFAULT,(uint8_t*)g_mccm.cmp);
+
+ mcCloseDevice(MC_DEVICE_ID_DEFAULT);
+
+ memset(&g_mccm,0,sizeof(MCCM));
+
+ LOG_d("++++ LEFT mccmClose.");
+}
+
+static bool mccmTransmit ( int32_t timeout )
+{
+ LOG_d("++++ ENTERED mccmTransmit.");
+
+ // Send CMP message to content management trustlet.
+
+ g_mccm.lasterror = mcNotify(&g_mccm.sess);
+
+ if (unlikely( MC_DRV_OK!=g_mccm.lasterror ))
+ {
+ dumpErrorInformation("mcNotify",g_mccm.lasterror);
+ LOG_d("++++ LEFT mccmTransmit.");
+ return false;
+ }
+
+ // Wait for trustlet response.
+
+ g_mccm.lasterror = mcWaitNotification(&g_mccm.sess, timeout);
+
+ if (unlikely( MC_DRV_OK!=g_mccm.lasterror ))
+ {
+ dumpErrorInformation("mcWaitNotification",g_mccm.lasterror);
+ LOG_d("++++ LEFT mccmTransmit.");
+ return false;
+ }
+
+ LOG_d("++++ LEFT mccmTransmit.");
+
+ return true;
+}
+
+static bool mccmGetSuid ( mcSuid_t *suid )
+{
+ LOG_d("++++ ENTERED mccmGetSuid.");
+
+ g_mccm.lastcmperr = SUCCESSFUL;
+
+ memset(g_mccm.cmp,0,sizeof(cmp_t));
+ g_mccm.cmp->msg.cmpCmdGetSuid.cmdHeader.commandId = MC_CMP_CMD_GET_SUID;
+
+ if (unlikely( !mccmTransmit(MC_INFINITE_TIMEOUT) ))
+ {
+ LOG_d("++++ LEFT mccmGetSuid.");
+ return false;
+ }
+
+ if (unlikely( (MC_CMP_CMD_GET_SUID|RSP_ID_MASK)!=g_mccm.cmp->msg.cmpRspGetSuid.rspHeader.responseId ))
+ {
+ LOG_e("Bad response ID of GET_SUID response.");
+ g_mccm.lasterror = MC_DRV_ERR_UNKNOWN;
+ LOG_d("++++ LEFT mccmGetSuid.");
+ return false;
+ }
+
+ g_mccm.lastcmperr = g_mccm.cmp->msg.cmpRspGetSuid.rspHeader.returnCode;
+
+ if (unlikely( SUCCESSFUL!=g_mccm.lastcmperr ))
+ {
+ LOG_e("CMP error occurred, code: %u (0x%08X).",g_mccm.lastcmperr,g_mccm.lastcmperr);
+ g_mccm.lasterror = MC_DRV_ERR_UNKNOWN;
+ LOG_d("++++ LEFT mccmGetSuid.");
+ return false;
+ }
+
+ memcpy(suid,&g_mccm.cmp->msg.cmpRspGetSuid.suid,sizeof(mcSuid_t));
+
+#ifdef _DEBUG
+ LOG_d("SUID returned is:");
+ GDMCHexDump((const unsigned char*)suid,sizeof(*suid));
+#endif
+
+ LOG_d("++++ LEFT mccmGetSuid.");
+ return true;
+}
+
+static bool mccmGenerateAuthToken (
+ const cmpCmdGenAuthToken_t *cmd,
+ cmpRspGenAuthToken_t *rsp )
+{
+ LOG_d("++++ ENTERED mccmGenerateAuthToken.");
+
+#ifdef _DEBUG
+ LOG_d("CMP request is (hexdump):");
+ GDMCHexDump((const unsigned char*)cmd,sizeof(*cmd));
+#endif
+
+ g_mccm.lastcmperr = SUCCESSFUL;
+
+ memset(g_mccm.cmp,0,sizeof(cmp_t));
+
+ memcpy(g_mccm.cmp,cmd,sizeof(*cmd));
+
+ if (unlikely( !mccmTransmit(MC_INFINITE_TIMEOUT) ))
+ {
+ LOG_d("++++ LEFT mccmGenerateAuthToken.");
+ return false;
+ }
+
+ if (unlikely( (cmd->cmd.sdata.cmdHeader.commandId|RSP_ID_MASK)!=g_mccm.cmp->msg.cmpRspGenAuthToken.rsp.rspHeader.responseId ))
+ {
+ LOG_e("Bad response ID of GENERATE_AUTH_TOKEN response.");
+ g_mccm.lasterror = MC_DRV_ERR_UNKNOWN;
+ LOG_d("++++ LEFT mccmGenerateAuthToken.");
+ return false;
+ }
+
+ g_mccm.lastcmperr = g_mccm.cmp->msg.cmpRspGenAuthToken.rsp.rspHeader.returnCode;
+
+ if (unlikely( SUCCESSFUL!=g_mccm.lastcmperr ))
+ {
+ LOG_e("CMP error occurred, code: %u (0x%08X).",g_mccm.lastcmperr,g_mccm.lastcmperr);
+ g_mccm.lasterror = MC_DRV_ERR_UNKNOWN;
+ LOG_d("++++ LEFT mccmGenerateAuthToken.");
+ return false;
+ }
+
+ memcpy(rsp,g_mccm.cmp,sizeof(*rsp));
+
+#ifdef _DEBUG
+ LOG_d("CMP response is (hexdump):");
+ GDMCHexDump((const unsigned char*)rsp,sizeof(*rsp));
+#endif
+
+ LOG_d("++++ LEFT mccmGenerateAuthToken.");
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////
+// Convenience functions
+///////////////////////////////////////////////////////////////////////////////////////////
+
+gderror MCGetSUID ( _u8 *suid )
+{
+ if (unlikely( NULL==suid ))
+ return GDERROR_PARAMETER;
+
+ memset(suid,0,SUID_LENGTH);
+
+ if (!mccmGetSuid((mcSuid_t*)suid))
+ return GDERROR_CANT_GET_SUID;
+
+ return GDERROR_OK;
+}
+
+gderror MCGenerateAuthToken ( gdmcinst *inst, const gdmc_actmsg_req *req, gdmc_so_authtok *authtok )
+{
+ cmpRspGenAuthToken_t rsp;
+
+ if (unlikely( NULL==inst || NULL==req || NULL==authtok ))
+ return GDERROR_PARAMETER;
+
+ memset(authtok,0,sizeof(gdmc_so_authtok));
+
+ if (MC_CMP_CMD_GENERATE_AUTH_TOKEN!=req->msg_type)
+ return GDERROR_MESSAGE_FORMAT;
+
+ if (!mccmGenerateAuthToken((const cmpCmdGenAuthToken_t *)req,&rsp))
+ return GDERROR_CANT_BUILD_AUTHTOKEN;
+
+ memcpy(authtok,&rsp.soAuthCont,sizeof(*authtok));
+
+ return GDERROR_OK;
+}
+++ /dev/null
-LOCAL_ROOT_PATH := $(call my-dir)
-
-MOBICORE_DIR_INC := $(LOCAL_ROOT_PATH)/../curl/include
-include $(LOCAL_ROOT_PATH)/Code/Common/Android.mk
-include $(LOCAL_ROOT_PATH)/Code/Android/app/jni/Android.mk
-include $(LOCAL_ROOT_PATH)/Code/Android/lib/Android.mk
-include $(LOCAL_ROOT_PATH)/Code/Android/app/Android.mk
\ No newline at end of file
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_PACKAGE_NAME := RootPA
-LOCAL_MODULE_TAGS := debug eng optional
+LOCAL_MODULE_TAGS := eng optional
LOCAL_CERTIFICATE := platform
LOCAL_PROGUARD_FLAGS := -include $(LOCAL_PATH)/proguard-project.txt
-APP_PIE := true
-LOCAL_32_BIT_ONLY := true
-LOCAL_DEX_PREOPT := false
-
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
android:versionName="@string/name" >
<uses-sdk android:minSdkVersion="14"
- android:targetSdkVersion="23" />
+ android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
- android:maxSdkVersion="22" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<permission android:name="com.gd.mobicore.pa.permission.OEM_PERMISSION"
android:label="remove installed secure services"
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
out.dir=out
-java.compilerargs="-Xlint:unchecked"
\ No newline at end of file
+java.compilerargs="-Xlint:unchecked"
+
+debug.key.store=../../../Build/google_certificate.keystore
+debug.key.alias=platform
+debug.key.store.password=android
+debug.key.alias.password=android
\ No newline at end of file
-->
<property file="ant.properties" />
-<!-- All the build information will be stored in a seperate logfile
- including a timestamp. -->
-<target name="log">
-<tstamp><format property="timestamp" pattern="yyyy-MM-dd_HH-mm-ss"/></tstamp>
-<property name="build.log.dir" location="${basedir}/buildlogs"/>
-<mkdir dir="${build.log.dir}"/>
-<property name="build.log.filename" value="build_${timestamp}.log"/>
-<record name="${build.log.dir}/${build.log.filename}" loglevel="verbose" append="false"/>
-<echo message="Build logged to ${build.log.filename}"/>
-</target>
-
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
-<condition property="ndk.dir" value="${env.NDK_HOME}">
- <isset property="env.NDK_HOME" />
-</condition>
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
-<!--
--Update android project
--Running ndk-build to compile native android sources-->
-
-<target name="windows">
-
-<exec executable="cmd"
- failonerror="true">
- <arg value="/c"/>
- <arg value="${env.ANDROID_HOME}/tools/android update project --path ./"/>
-</exec>
-
-<exec executable="${env.NDK_BUILD}/ndk-build.cmd"/>
-
-<antcall target="copy_libs"/>
-
-</target>
-
-<target name="linux">
-
-<exec
- executable="${env.ANDROID_HOME}/tools/android"
- failonerror="true">
- <arg value="update"/>
- <arg value="project"/>
- <arg value="-p"/>
- <arg value="."/>
-</exec>
-
-<exec executable="${env.NDK_BUILD}/ndk-build"/>
-</target>
-
-
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
-<!-- quick check on ndk.dir -->
-
-<fail message="ndk.dir is missing. Make sure that the local.properties file defines it."
- unless="ndk.dir" />
-
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
# (including RootPA/Common) checked out in order to sucessfully
# complete te build
#
-APP_PIE := true
-LOCAL_32_BIT_ONLY := true
+
include $(call all-subdir-makefiles)
--- /dev/null
+#
+# Copyright © Trustonic Limited 2013
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# 3. Neither the name of the Trustonic Limited nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+# OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+
+#
+# makefile for building the provisioning agent Common part for android. build the code by executing
+# $NDK_ROOT/ndk-build in the folder where this file resides
+#
+# naturally the right way to build is to use build script under Build folder. It then uses this file.
+#
+
+
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS += -DANDROID_ARM=1
+LOCAL_CFLAGS += -DANDROID
+LOCAL_CFLAGS += \
+ -Wno-unused-parameter \
+ -Wno-sign-compare \
+ -Wno-unused-const-variable \
+ -fstack-protector
+ifeq ($(DEBUG), 1)
+ LOCAL_CFLAGS += -D__DEBUG=1
+endif
+
+LOCAL_SRC_FILES += ../../../../Common/commandhandler.c
+LOCAL_SRC_FILES += ../../../../Common/pacmp3.c
+LOCAL_SRC_FILES += ../../../../Common/pacmtl.c
+LOCAL_SRC_FILES += ../../../../Common/trustletchannel.c
+LOCAL_SRC_FILES += ../../../../Common/registry.c
+LOCAL_SRC_FILES += ../../../../Common/seclient.c
+LOCAL_SRC_FILES += ../../../../Common/base64.c
+LOCAL_SRC_FILES += ../../../../Common/xmlmessagehandler.c
+LOCAL_SRC_FILES += ../../../../Common/provisioningengine.c
+LOCAL_SRC_FILES += ../../../../Common/contentmanager.c
+
+LOCAL_C_INCLUDES += $(MOBICORE_DIR_INC)
+LOCAL_C_INCLUDES += $(MOBICORE_DIR_INC)/TlCm
+LOCAL_C_INCLUDES += $(MOBICOREDRIVER_DIR_INC)
+LOCAL_C_INCLUDES += $(MOBICOREDRIVER_DIR_INC2)
+LOCAL_C_INCLUDES += external/curl/include
+LOCAL_C_INCLUDES += external/libxml2/include
+LOCAL_C_INCLUDES += external/icu/icu4c/source/common
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../Common
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../Common/include
+
+# Build for the first architecture (64-bit)
+LOCAL_MULTILIB := first
+
+ifeq ($(ROOTPA_MODULE_TEST), 1)
+ LOCAL_STATIC_LIBRARIES += McStub
+ LOCAL_MODULE := provisioningagent_test
+else
+ LOCAL_MODULE := provisioningagent
+endif
+
+LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+LOCAL_MODULE_TAGS := eng optional
+
+include $(BUILD_STATIC_LIBRARY)
#
# All rights reserved.
#
-# Redistribution and use in source and binary forms, with or without modification,
+# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
-# 1. Redistributions of source code must retain the above copyright notice, this
+# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
-# 2. Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
-# 3. Neither the name of the Trustonic Limited nor the names of its contributors
-# may be used to endorse or promote products derived from this software
+# 3. Neither the name of the Trustonic Limited nor the names of its contributors
+# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.
#
include $(CLEAR_VARS)
LOCAL_CFLAGS += -DANDROID_ARM=1
-LOCAL_CFLAGS +=-fstack-protector
+LOCAL_CFLAGS += \
+ -Wno-unused-parameter \
+ -Wno-unused-variable \
+ -Wno-reorder \
+ -Wno-format \
+ -fstack-protector
ifeq ($(DEBUG), 1)
LOCAL_CFLAGS += -D__DEBUG=1
-endif
+endif
+
+# Build for the first arch (64-bit)
+LOCAL_MULTILIB := first
+
+LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_SRC_FILES += commonwrapper.cpp
LOCAL_SRC_FILES += JniHelpers.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../Common/include
LOCAL_MODULE := libcommonpawrapper
-LOCAL_MODULE_TAGS := debug eng optional
+LOCAL_MODULE_TAGS := eng optional
ifeq ($(ROOTPA_MODULE_TEST), 1)
LOCAL_STATIC_LIBRARIES += provisioningagent_test
- LOCAL_STATIC_LIBRARIES += McStub
+ LOCAL_STATIC_LIBRARIES += McStub
else
LOCAL_STATIC_LIBRARIES += provisioningagent
- LOCAL_STATIC_LIBRARIES += MobiCoreTlcm
- LOCAL_SHARED_LIBRARIES += libMcClient
- LOCAL_SHARED_LIBRARIES += libMcRegistry
+
+ LOCAL_SHARED_LIBRARIES += libMcClient
+ LOCAL_SHARED_LIBRARIES += libMcRegistry
endif
#LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib
LOCAL_STATIC_LIBRARIES += libxml2
LOCAL_SHARED_LIBRARIES += libicuuc
-APP_PIE := true
-LOCAL_32_BIT_ONLY := true
include $(BUILD_SHARED_LIBRARY)
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include "logging.h"
#include "CmpBase.h"
CmpBase::CmpBase(JNIEnv* env, jobject msgs): env_(env),
msgs_(msgs),
cls_(NULL),
+ broken_(false),
objectCls_(NULL),
- numberOfElements_(0),
- broken_(false)
+ numberOfElements_(0)
{
if((env_ != NULL) && (msgs_ != NULL))
{
}
return numberOfElements_;
}
-
-
-
-
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef CMPBASE_H
#define CMPBASE_H
CmpBase(JNIEnv* env, jobject msgs);
virtual ~CmpBase();
int numberOfElements();
- private:
+ private:
CmpBase();
CmpBase(CmpBase&);
protected:
JNIEnv* env_;
- jobject msgs_;
+ jobject msgs_;
jclass cls_;
jclass objectCls_;
int numberOfElements_;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include "logging.h"
#include "CmpCommands.h"
#include "JniHelpers.h"
{
if(!broken_)
{
- createObjectArray();
+ createObjectArray();
}
}
{
if(NULL==objectCls_)
{
- objectCls_ = env_->FindClass("com/gd/mobicore/pa/ifc/CmpCommand"); // element in array
+ objectCls_ = env_->FindClass("com/gd/mobicore/pa/ifc/CmpCommand"); // element in array
}
if(objectCls_ != NULL)
{
jmethodID midToByteArray=env_->GetMethodID(objectCls_, "toByteArray", "()[B");
if(NULL==midToByteArray){
- LOGE("<<CmpCommands::getCommands returning false, method toByteArray not found");
+ LOGE("<<CmpCommands::getCommands returning false, method toByteArray not found");
return false;
}
jmethodID midIgnoreError=env_->GetMethodID(objectCls_, "ignoreError", "()Z");
if(NULL==midIgnoreError){
- LOGE("<<CmpCommands::getCommands returning false, method ignoreError not found");
+ LOGE("<<CmpCommands::getCommands returning false, method ignoreError not found");
return false;
}
-
- jbyteArray jba=NULL;
+
+ jbyteArray jba=NULL;
jobject arrayElement=NULL;
for(int i=0; i<numberOfElements(); i++)
{
jba = (jbyteArray) env_->CallObjectMethod(arrayElement, midToByteArray);
JniHelpers helper(env_);
- objectArray[i].contentP=helper.jByteArrayToCByteArray(jba, &(objectArray[i].length));
+ objectArray[i].contentP=helper.jByteArrayToCByteArray(jba, &(objectArray[i].length));
objectArray[i].hdr.ignoreError=(JNI_TRUE==env_->CallBooleanMethod(arrayElement, midIgnoreError));
env_->DeleteLocalRef(jba);
env_->DeleteLocalRef(arrayElement);
/*
*/
-void CmpCommands::createObjectArray()
+void CmpCommands::createObjectArray()
{
if(broken_) return;
jmethodID mid = env_->GetMethodID(cls_, "toArray", "()[Ljava/lang/Object;");
- if (mid != 0)
+ if (mid != 0)
{
jObjectArray_ = (jobjectArray) env_->CallObjectMethod(msgs_, mid);
if(NULL==jObjectArray_)
{
LOGE("error in getting jObjectArray_");
- broken_= true;
+ broken_= true;
}
- }
- else
+ }
+ else
{
LOGE("Sorry, but the method toArray()[Ljava/lang/Object cannot be found!");
broken_= true;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef CMPCOMMANDS_H
#define CMPCOMMANDS_H
this trusts that the caller has reserved long enough array
*/
bool getCommands(CmpMessage* objectArray);
- private:
+ private:
CmpCommands();
CmpCommands(CmpMessage&);
void createObjectArray();
private:
- jobjectArray jObjectArray_;
+ jobjectArray jObjectArray_;
};
#endif // CMPCOMMANDS_H
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <stdlib.h>
#include "JniHelpers.h"
#include "CmpResponses.h"
}
else
{
- LOGE("CmpResponses::CmpResponses: Sorry, but the method clear()V cannot be found!");
+ LOGE("CmpResponses::CmpResponses: Sorry, but the method clear()V cannot be found!");
}
}
}
if(NULL==newObject)
{
- LOGE("CmpResponses::createCmpResponseObject creating new object failed %p %p", objectCls_, constructor);
+ LOGE("CmpResponses::createCmpResponseObject creating new object failed %d %d", objectCls_, constructor);
}
}
return newObject;
}
-
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef CMPRESPONSES_H
#define CMPRESPONSES_H
CmpResponses(JNIEnv* env, jobject responses);
virtual ~CmpResponses();
int update(CmpMessage* responses, int numberOfResponses);
- private:
+ private:
CmpResponses();
CmpResponses(CmpResponses&);
- jobject createCmpResponseObject(CmpMessage msg);
+ jobject createCmpResponseObject(CmpMessage msg);
};
#endif // CMPRESPONSES_H
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include <string.h>
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include "JniHelpers.h"
#include "rootpaErrors.h"
+#include <string.h>
JniHelpers::JniHelpers(JNIEnv* envP):broken_(false),
envP_(envP),
}
return cBytes;
}
-
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef JNIHELPERS_H
#define JNIHELPERS_H
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
JNIEXPORT void JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmentVariable
(JNIEnv *, jobject, jbyteArray, jbyteArray);
-
-JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_storeTA
- (JNIEnv *, jobject, jint, jbyteArray, jbyteArray);
-
-
#ifdef __cplusplus
}
#endif
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <string.h>
#include "com_gd_mobicore_pa_jni_CommonPAWrapper.h"
JavaVM* jvmP_ = NULL;
const jint VERSION=JNI_VERSION_1_2;
-/* Original params list : (JavaVM* jvm, void* reserved)*/
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* jvm, void*)
+
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* jvm, void* reserved)
{
// remember JVM pointer:
jvmP_ = jvm;
closeSessionToCmtl();
}
-/* Original params list : (JNIEnv* env, jobject, jint uid, jobject inCommands, jobject outResults)*/
JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_executeCmpCommands
- (JNIEnv* env, jobject, jint, jobject inCommands, jobject outResults)
+ (JNIEnv* env, jobject, jint uid, jobject inCommands, jobject outResults)
{
LOGD(">>Java_com_gd_mobicore_pa_jni_CommonPAWrapper_executeCmpCommands\n");
int ret=ROOTPA_OK;
}
else
{
- envP->CallVoidMethod(obj_, provisioningStateCallback_, ERROR_STATE, ROOTPA_ERROR_INTERNAL);
+ envP->CallVoidMethod(obj_, provisioningStateCallback_, ERROR, ROOTPA_ERROR_INTERNAL);
}
}
else
{
const char* tmp=envP->GetStringUTFChars(source, NULL);
*target=(char*)malloc(strlen(tmp)+1);
- if(*target!=NULL)
- {
- strcpy(*target, tmp);
- }
+ strcpy(*target, tmp);
envP->ReleaseStringUTFChars(source, tmp);
}
else
return ret;
}
-/* Original params list : (JNIEnv* envP, jobject obj, jint uid, jint spid, jbyteArray seAddress)*/
JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_doProvisioning
- (JNIEnv* envP, jobject obj, jint, jint spid, jbyteArray seAddress)
+ (JNIEnv* envP, jobject obj, jint uid, jint spid, jbyteArray seAddress)
{
LOGD(">>Java_com_gd_mobicore_pa_jni_CommonPAWrapper_doProvisioning %ld %ld\n", (long int) stateUpdateCallback, (long int) getSystemInfoCallback);
setFilesPath(envP, obj);
return newVP;
}
-/* Original params list : (JNIEnv* envP, jobject obj, jbyteArray variable_name, jbyteArray value)*/
-JNIEXPORT void JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmentVariable(JNIEnv* envP, jobject, jbyteArray variable_name, jbyteArray value)
+JNIEXPORT void JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmentVariable(JNIEnv* envP, jobject obj, jbyteArray variable_name, jbyteArray value)
{
LOGD(">>Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmentVariable");
JniHelpers jniHelp(envP);
delete[] envValP;
LOGD("<<Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmentVariable");
}
-
-/* Original params list : (JNIEnv* envP, jobject obj, jint spid, jbyteArray uuid, jbyteArray taBin)*/
-JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_storeTA(JNIEnv* envP, jobject, jint spid, jbyteArray uuid, jbyteArray taBin)
-{
- LOGD(">>Java_com_gd_mobicore_pa_jni_CommonPAWrapper_storeTA");
- int ret=ROOTPA_OK;
- JniHelpers jniHelp(envP);
-
- uint32_t uuidLength=0;
- uint8_t* uuidP=(uint8_t*) jniHelp.jByteArrayToCByteArray(uuid, &uuidLength);
-
- if(UUID_LENGTH != uuidLength){
- LOGD("<<Java_com_gd_mobicore_pa_jni_CommonPAWrapper_storeTA, wrong uuidLength %d, not installing\n", uuidLength);
- free(uuidP);
- return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
- }
- mcUuid_t mcUuid;
- memcpy(mcUuid.value, uuidP, UUID_LENGTH);
- free(uuidP);
-
- uint32_t taBinLength=0;
- uint8_t* taBinP=(uint8_t*) jniHelp.jByteArrayToCByteArray(taBin, &taBinLength);
- if(0==taBinLength){
- LOGD("<<Java_com_gd_mobicore_pa_jni_CommonPAWrapper_storeTA, no taBin\n", taBinLength);
- free(taBinP);
- return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
- }
-
- ret=storeTA((mcSpid_t)spid, &mcUuid, taBinP, taBinLength);
- free(taBinP);
-
- LOGD("<<Java_com_gd_mobicore_pa_jni_CommonPAWrapper_storeTA %d", ret);
- return ret;
-}
-
LOCAL_C_INCLUDES += $(MOBICORE_DIR_INC)/TlCm
LOCAL_C_INCLUDES += $(MOBICOREDRIVER_DIR_INC)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../Common/include
- APP_PIE := true
- LOCAL_32_BIT_ONLY := true
-
+
include $(BUILD_STATIC_LIBRARY)
endif
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
<?xml version="1.0" encoding="utf-8"?>
<resources>
-<string name="name">3.96</string>
-<integer name="code">0x30060</integer>
+ <string name="name">2.0068 (46860)</string>
+ <integer name="code">0x20044</integer>
</resources>
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
//
// Wrapper class for common C part of the Root Provisioning Agent, the C
int flags,
byte[] seAddress);
public native int unregisterRootContainer(byte[] seAddress);
- public native int storeTA(int spid, byte[] uuid, byte[] taBinary);
public native void setEnvironmentVariable(byte[] variable, byte[] value);
static{
Log.d(TAG,"CommonPAWrapper.java: static");
- try {
+ try {
System.loadLibrary("commonpawrapper");
- } catch (Throwable e) {
+ } catch (Throwable e) {
Log.d(TAG,"loading common wrapper failed, trying to load test");
System.loadLibrary("commonpawrapper_test");
}
public String[] getSystemInfo(){
Log.d(TAG,">>CommonPAWrapper.getSystemInfo");
String[] response= new String[RESPONSE_ARRAY_SIZE];
- response[IMEI_ESN_INDEX]="";
- response[MNO_INDEX]="";
+ TelephonyManager telephonyManager = (TelephonyManager)service_.getSystemService(Context.TELEPHONY_SERVICE);
+ if(telephonyManager!=null){
+ response[IMEI_ESN_INDEX]=telephonyManager.getDeviceId();
+ response[MNO_INDEX]=telephonyManager.getSimOperatorName();
+ }
response[BRAND_INDEX]=Build.BRAND;
response[MANUFACTURER_INDEX]=Build.MANUFACTURER;
response[HARDWARE_INDEX]=Build.HARDWARE;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.service;
import android.net.NetworkInfo;
import android.net.ConnectivityManager;
-import java.io.File;
import java.net.URI;
import java.net.Proxy;
import java.net.Proxy.Type;
import java.net.ProxySelector;
+
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
*/
private static final int LOCK_FREE=0;
private static final AtomicInteger lock_= new AtomicInteger(LOCK_FREE);
- private static final int LOCK_TIMEOUT_MS=300000; //5 mins in ms
+ private static final int LOCK_TIMEOUT_MS=60000;
private TimerTask timerTask_=null;
private Timer timer_=null;
This method is called from the C code to get the path for files directory
*/
public String getFilesDirPath(){
- File file = this.getFilesDir();
- if (null != file){
- return file.getAbsolutePath();
- } else {
- return null;
- }
+ return this.getFilesDir().getAbsolutePath();
}
/**
return res;
}
-}
+}
\ No newline at end of file
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.service;
return START_STICKY;
}
}
-
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.service;
public class Log {
- private static int level_=android.util.Log.INFO;
-
+ private static int level_=android.util.Log.INFO;
+
/**
Set level of logging
*/
level_=level;
}
}
-
+
/**
Send a DEBUG log message.
*/
public static int d(String tag, String msg){
if(level_<=android.util.Log.DEBUG) return android.util.Log.d(tag, msg);
return 0;
- }
+ }
/**
Send a DEBUG log message and log the exception.
*/
public static int d(String tag, String msg, Throwable tr){
if(level_<=android.util.Log.DEBUG) return android.util.Log.d(tag, msg, tr);
- return 0;
- }
+ return 0;
+ }
/**
Send an ERROR log message.
*/
public static int e(String tag, String msg){
if(level_<=android.util.Log.ERROR) return android.util.Log.e(tag, msg);
- return 0;
+ return 0;
}
/**
Send a ERROR log message and log the exception.
- */
+ */
public static int e(String tag, String msg, Throwable tr){
if(level_<=android.util.Log.ERROR) return android.util.Log.e(tag, msg, tr);
- return 0;
+ return 0;
}
/**
- Send an INFO log message.
- */
+ Send an INFO log message.
+ */
public static int i(String tag, String msg){
if(level_<=android.util.Log.INFO) return android.util.Log.i(tag, msg);
- return 0;
+ return 0;
}
/**
*/
public static int i(String tag, String msg, Throwable tr){
if(level_<=android.util.Log.INFO) return android.util.Log.i(tag, msg, tr);
- return 0;
+ return 0;
}
/**
public static String getStackTraceString(Throwable tr){
return android.util.Log.getStackTraceString(tr);
}
-
+
/**
Checks to see whether or not a log for the specified tag is loggable at the specified level.
*/
return android.util.Log.isLoggable(tag, level);
}
- /**
+ /**
Low-level logging call.
*/
public static int println(int priority, String tag, String msg){
*/
public static int v(String tag, String msg){
if(level_<=android.util.Log.VERBOSE) return android.util.Log.v(tag, msg);
- return 0;
+ return 0;
}
/**
*/
public static int v(String tag, String msg, Throwable tr){
if(level_<=android.util.Log.VERBOSE) return android.util.Log.v(tag, msg, tr);
- return 0;
+ return 0;
}
/**
public static int w(String tag, Throwable tr){
if(level_>=android.util.Log.WARN) return android.util.Log.w(tag, tr);
- return 0;
+ return 0;
}
/**
*/
public static int w(String tag, String msg, Throwable tr){
if(level_<=android.util.Log.WARN) return android.util.Log.w(tag, msg, tr);
- return 0;
+ return 0;
}
/**
*/
public static int w(String tag, String msg){
if(level_<=android.util.Log.WARN) return android.util.Log.w(tag, msg);
- return 0;
+ return 0;
}
/**
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.service;
try{
setupProxy();
- ret=commonPAWrapper().unregisterRootContainer(se_);
+ ret=commonPAWrapper().unregisterRootContainer(se_);
}catch(Exception e){
Log.e(TAG,"CommonPAWrapper().unregisterRootContainer exception: ", e);
ret=CommandResult.ROOTPA_ERROR_INTERNAL;
return START_STICKY;
}
}
-
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.service;
if(ret==CommandResult.ROOTPA_OK){
SPContainerState s=mapSpContainerState(ints[CONTAINER_STATE_IDX]);
- cs.setState(s);
+ cs.setState(s);
if (s == SPContainerState.UNDEFINED){
ret=CommandResult.ROOTPA_ERROR_INTERNAL;
}
}
}else if (ret==CommandResult.ROOTPA_ERROR_INTERNAL_NO_CONTAINER){
- cs.setState(SPContainerState.DOES_NOT_EXIST);
+ cs.setState(SPContainerState.DOES_NOT_EXIST);
ret=CommandResult.ROOTPA_OK;
}
if(ret==CommandResult.ROOTPA_OK){
SPContainerState s=mapSpContainerState(containerState[0]);
- state.setEnumeratedValue(s);
+ state.setEnumeratedValue(s);
if (s == SPContainerState.UNDEFINED){
ret=CommandResult.ROOTPA_ERROR_INTERNAL;
}
}else if (ret==CommandResult.ROOTPA_ERROR_INTERNAL_NO_CONTAINER){
- state.setEnumeratedValue(SPContainerState.DOES_NOT_EXIST);
+ state.setEnumeratedValue(SPContainerState.DOES_NOT_EXIST);
ret=CommandResult.ROOTPA_OK;
}
return new CommandResult(ret);
}
- public CommandResult storeTA(SPID spid, byte[] uuid, byte[] taBinary){
- Log.d(TAG,">>RootPAServiceIfc.Stub.storeTA");
- if(spid==null||uuid==null||taBinary==null|| taBinary.length == 0 || spid.spid()==0){ // having null out variable leads to null pointer exception in the client, however we still want to do checking so that there is not unncessary execution of the following code
- return new CommandResult(CommandResult.ROOTPA_ERROR_ILLEGAL_ARGUMENT);
- }
-
- int ret=CommandResult.ROOTPA_OK;
- try{
- ret=commonPAWrapper().storeTA(spid.spid(), uuid, taBinary);
- }catch(Exception e){
- Log.e(TAG,"CommonPAWrapper().storeTA exception: ", e);
- ret=CommandResult.ROOTPA_ERROR_INTERNAL;
- }
-
- Log.d(TAG,"<<RootPAServiceIfc.Stub.storeTA");
- return new CommandResult(ret);
- }
-
private final static int MC_CONT_STATE_UNREGISTERED=0;
private final static int MC_CONT_STATE_REGISTERED=1;
private final static int MC_CONT_STATE_ACTIVATED=2;
state=TrustletContainerState.ACTIVATED;
break;
case MC_CONT_STATE_SP_LOCKED:
- state=TrustletContainerState.SP_LOCKED;
+ state=TrustletContainerState.SP_LOCKED;
break;
default:
Log.e(TAG,"mapTltContainerState returning undefined: "+ containerState);
- state=TrustletContainerState.UNDEFINED;
+ state=TrustletContainerState.UNDEFINED;
break;
}
return state;
state=SPContainerState.ACTIVATED;
break;
case MC_CONT_STATE_ROOT_LOCKED:
- state=SPContainerState.ROOT_LOCKED;
+ state=SPContainerState.ROOT_LOCKED;
break;
case MC_CONT_STATE_SP_LOCKED:
- state=SPContainerState.SP_LOCKED;
+ state=SPContainerState.SP_LOCKED;
break;
case MC_CONT_STATE_ROOT_SP_LOCKED:
- state=SPContainerState.ROOT_SP_LOCKED;
+ state=SPContainerState.ROOT_SP_LOCKED;
break;
default:
Log.e(TAG,"mapSpContainerState returning undefined: "+ containerState);
- state=SPContainerState.UNDEFINED;
+ state=SPContainerState.UNDEFINED;
break;
}
return state;
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SRC_FILES += src/com/gd/mobicore/pa/ifc/RootPAServiceIfc.aidl \
src/com/gd/mobicore/pa/ifc/RootPADeveloperIfc.aidl \
- src/com/gd/mobicore/pa/ifc/RootPAOemIfc.aidl
+ src/com/gd/mobicore/pa/ifc/RootPAOemIfc.aidl
LOCAL_MODULE := rootpa_interface
-LOCAL_MODULE_TAGS := debug eng optional
-
-APP_PIE := true
-LOCAL_32_BIT_ONLY := true
+LOCAL_MODULE_TAGS := eng optional
include $(BUILD_STATIC_JAVA_LIBRARY)
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/**
Class that contains content management protocol command. The class inherits is parcelable.
- @see CmpMsg
- @see CmpResponse
+ @see CmpMsg
+ @see CmpResponse
*/
public class CmpCommand extends CmpMsg{
public static final int COMMAND_LENGTH_IDX=4;
private static final int COMMAND_RESERVED_IDX=8;
/**
- This is not directly tied to the content of the command but to execution of
- multiple commands. If ignoreError is set, the execution continues even if
+ This is not directly tied to the content of the command but to execution of
+ multiple commands. If ignoreError is set, the execution continues even if
this command returns an error. By default ignoreError is false.
@return boolean value telling whether the error should be ignored
*/
}
/**
- This is not directly tied to the content of the command but to execution of
- multiple commands. If ignoreError is set, the execution continues even if
+ This is not directly tied to the content of the command but to execution of
+ multiple commands. If ignoreError is set, the execution continues even if
this command returns an error. By default ignoreError is false.
@param ignore boolean value telling whether the error should be ignored
*/
public void setLength(int length)
{
// MC_CMP_CMD_GET_VERSION, MC_CMP_CMD_GENERATE_AUTH_TOKEN and MC_CMP_CMD_GET_SUID do not have length field for legacy reasons
- if(msgId()!=MC_CMP_CMD_GET_VERSION
+ if(msgId()!=MC_CMP_CMD_GET_VERSION
&& msgId()!=MC_CMP_CMD_GENERATE_AUTH_TOKEN
&& msgId()!=MC_CMP_CMD_GET_SUID
&& length > 4) // not setting length for messages that only have id
/**
Constructor
- @param commandId see possible values from CmpMsg
+ @param commandId see possible values from CmpMsg
*/
public CmpCommand(int commandId){
super();
public CmpCommand(Parcel in){
super(in);
}
-
+
public static final Parcelable.Creator<CmpCommand> CREATOR = new Parcelable.Creator<CmpCommand>(){
public CmpCommand createFromParcel(Parcel in){
return new CmpCommand(in);
}
-
+
public CmpCommand[] newArray(int size){
return null;
}
};
- @Override
+ @Override
public void writeToParcel(Parcel out, int flags){
out.writeByte((byte)((ignoreError_==true)?1:0));
super.writeToParcel(out, flags);
ignoreError_=(in.readByte()==1);
super.readFromParcel(in);
}
-
+
}
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
import android.os.Parcel;
/**
Base class for content management protocol commands and responses
@see CmpCommand
- @see CmpResponse
+ @see CmpResponse
*/
public abstract class CmpMsg implements Parcelable{
-// CMP message ID's
+// CMP message ID's
public static final int MC_CMP_CMD_AUTHENTICATE=0;
public static final int MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION=1;
public static final int MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION=2;
public static final int MC_CMP_CMD_BEGIN_SP_AUTHENTICATION=3;
public static final int MC_CMP_CMD_GENERATE_AUTH_TOKEN=4;
public static final int MC_CMP_CMD_GET_VERSION=5;
-
+
public static final int MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT=7;
public static final int MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE=9;
// indices and masks
public static final int MSG_ID_IDX=0;
- public static final int INT_LENGTH=4;
+ public static final int INT_LENGTH=4;
public static final int RSP_ID_MASK=(1 << 31);
/**
return content_;
}
-
+
protected int msgId()
{
return getInt(MSG_ID_IDX);
}
-
+
protected void setMsgId(int id)
{
setInt(MSG_ID_IDX, id);
private void createEmptyContentIfNeeded(int index, int size){
if(content_==null){
- content_=new byte[size];
+ content_=new byte[size];
setLength(content_.length); // we keep the length field automatically up to date
}else if(content_.length<(index+size)){
- byte[] newarray=new byte[index+size];
+ byte[] newarray=new byte[index+size];
System.arraycopy(content_, 0, newarray, 0, content_.length);
content_=newarray;
setLength(content_.length); // we keep the length field automatically up to date
{
createEmptyContentIfNeeded(index, INT_LENGTH);
content_[index+0]=(byte) (value & 0xFF);
- content_[index+1]=(byte)((value >> 8) & 0xFF);
- content_[index+2]=(byte) ((value >> 16) & 0xFF);
- content_[index+3]=(byte) ((value >> 24) & 0xFF);
+ content_[index+1]=(byte)((value >> 8) & 0xFF);
+ content_[index+2]=(byte) ((value >> 16) & 0xFF);
+ content_[index+3]=(byte) ((value >> 24) & 0xFF);
}
*/
public int getInt(int index) throws ArrayIndexOutOfBoundsException
{
- return (content_[index] & 0xFF) +
- ((content_[index+1] & 0xFF) << 8) +
- ((content_[index+2] & 0xFF) << 16) +
+ return (content_[index] & 0xFF) +
+ ((content_[index+1] & 0xFF) << 8) +
+ ((content_[index+2] & 0xFF) << 16) +
((content_[index+3] & 0xFF) << 24);
}
*/
public byte[] getByteArray(int index, int length) throws ArrayIndexOutOfBoundsException
{
- byte[] newarray=new byte[length];
+ byte[] newarray=new byte[length];
System.arraycopy(content_, index, newarray, 0, length);
- return newarray;
+ return newarray;
}
// data ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
private byte[] content_;
- boolean ignoreError_=false; // this is moved from CmpCommand since
- // for some reason it is always false
- // if CmpCommand.ignoreError() called
- // with JNI CallBooleanMethod but if
+ boolean ignoreError_=false; // this is moved from CmpCommand since
+ // for some reason it is always false
+ // if CmpCommand.ignoreError() called
+ // with JNI CallBooleanMethod but if
// this is here it works
// stuff related to parcelable ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
@Override
- public int describeContents() {
- return 0;
- }
+ public int describeContents() {
+ return 0;
+ }
- @Override
+ @Override
public void writeToParcel(Parcel out, int flags){
out.writeByteArray(content_);
}
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
parcelable CmpResponse;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
import android.os.Parcel;
/**
Class that contains content management protocol response. The class inherits parcelable.
- @see CmpMsg
- @see CmpCommand
+ @see CmpMsg
+ @see CmpCommand
*/
public class CmpResponse extends CmpMsg{
private static final int RETURN_CODE_IDX=4;
public int responseId(){
return msgId();
}
-
+
/**
@param id respose id of the message
*/
/**
@return returnCode
- */
+ */
public int returnCode(){
return getInt(RETURN_CODE_IDX);
}
-
+
/**
@param ret return code for the message
- */
+ */
public void setReturnCode(int ret){
setInt(RETURN_CODE_IDX, ret);
}
public void setLength(int length)
{
// MC_CMP_CMD_GET_VERSION and MC_CMP_CMD_GET_SUID do not have length field for legacy reasons
- if(responseId()!=responseIdToCommandId(MC_CMP_CMD_GET_VERSION)
+ if(responseId()!=responseIdToCommandId(MC_CMP_CMD_GET_VERSION)
&& responseId()!=responseIdToCommandId(MC_CMP_CMD_GENERATE_AUTH_TOKEN)
&& responseId()!=responseIdToCommandId(MC_CMP_CMD_GET_SUID)
& length > 0) // not setting length for messages that only have id
}
}
-
+
/**
Default constructor
- */
+ */
public CmpResponse(){
super();
}
public CmpResponse(byte[] content){
super(content);
}
-
+
/**
Constructor required by parcelable
- */
+ */
public CmpResponse(Parcel in){
super(in);
}
public CmpResponse createFromParcel(Parcel in){
return new CmpResponse(in);
}
-
+
public CmpResponse[] newArray(int size){
return null;
}
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
parcelable CommandResult;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
/** @addtogroup ROOTPA
*/
public class IfcVersion{
- public final static int ROOTPA_ANDROID_API_VERSION_MAJOR=1;
- public final static int ROOTPA_ANDROID_API_VERSION_MINOR=1;
+ public final static int ROOTPA_ANDROID_API_VERSION_MAJOR = 1;
+ public final static int ROOTPA_ANDROID_API_VERSION_MINOR=0;
};
-
--- /dev/null
+r remaining input */
+ memcpy(&context->buffer[bufindex], &input[i], inputLen-i);
+}
+
+/* MD4 padding. */
+static void MD4Pad(MD4_CTX *context)
+{
+ unsigned char bits[8];
+ unsigned int bufindex, padLen;
+
+ /* Save number of bits */
+ Encode (bits, context->count, 8);
+
+ /* Pad out to 56 mod 64.
+ */
+ bufindex = (unsigned int)((context->count[0] >> 3) & 0x3f);
+ padLen = (bufindex < 56) ? (56 - bufindex) : (120 - bufindex);
+ MD4Update (context, PADDING, padLen);
+
+ /* Append length (before padding) */
+ MD4Update (context, bits, 8);
+}
+
+/* MD4 finalization. Ends an MD4 message-digest operation, writing the
+ the message digest and zeroizing the context.
+ */
+static void MD4Final (unsigned char digest[16], MD4_CTX *context)
+{
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
/** \addtogroup ROOTPA AIDL Interfaces
* @{
/**
* This API contains method(s) that are intended to be used for developer
- * TA installation. Note that this API may be removed in the future when the
- * developer TA installation is handled by a service manager and installation of
+ * trustlet installation. Note that this API may be removed in the future when the
+ * developer trustlet installation is handled by a service manager and installation of
* all trutlets follow the same architecture for RootPA point of view.
*
* The service is started by sending intent com.gd.mobicore.pa.service.DEVELOPER_SERVICE in binding.
interface RootPADeveloperIfc{
/**
- * This method can be used for installing "developer TA" that is not tied to any
+ * This method can be used for installing "developer trustlet" that is not tied to any
* service provider and/or service manager. It contacts Service Enabler and asks it to
* perform the tasks, so the device has to be connected to network in order for this to
* succeed.
* The service progress is informed with the same Intents as is progress of the
* @ref RootPAServiceIfc#doProvisioning, however there is an additional
* Intent com.gd.mobicore.pa.service.INSTALL_TRUSTLET for returning the encrypted
- * TA binary (in case of dynamic installation where taBinary is given
+ * trustlet binary (in case of dynamic installation where trustletBinary is given
* as a parameter).
*
* There are constants related to the intents in @ref RootPAProvisioningIntents
*
* @param spid service provider id
- * @param uuid uuid of the TA in hex, without dashes. Needs to be correct length.
- * @param taBinary TA binary to be encrypted with and returned back.
+ * @param uuid uuid of the trustlet in hex, without dashes. Needs to be correct length.
+ * @param trustletBinary trustlet binary to be encrypted with and returned back.
* If the binary is already encrypted, this array must be empty. The binary
- * has to be encrypted for transfer. Note that only either taBinary
+ * has to be encrypted for transfer. Note that only either trustletBinary
* or key can be given. There are sperate instructions on how the binary is to
- * be encrypted and packaged. Key and taBinary are exclusive, only one of
+ * be encrypted and packaged. Key and trustletBinary are exclusive, only one of
* them can be given. This methods uses default values for memoryType (2),
- * numberOfInstances (1) and flags (0) when TA binary is installed.
- * @param key a key that has been used to encrypt the TA binary in case when
- * the TA binary is not given as a parameter. This key has to be
+ * numberOfInstances (1) and flags (0) when trustlet binary is installed.
+ * @param key a key that has been used to encrypt the trustlet binary in case when
+ * the trustlet binary is not given as a parameter. This key has to be
* encrypted for transfer. There are sperate instructions on how the key is to
- * be encrypted and packaged. Key and taBinary are exclusive, only one of
+ * be encrypted and packaged. Key and trustletBinary are exclusive, only one of
* them can be given.
- * @param minTltVersion minimum version of the TA
+ * @param minTltVersion minimum version of the trustlet
* @param tltPukHash this field is not used at the moment, null is fine here.
*
* @return indication of successful start of provisioning thread (ROOTPA_OK) or an error code
*/
CommandResult installTrustletOrKey(in int spid,
in byte[] uuid,
- in byte[] taBinary,
+ in byte[] trustletBinary,
in byte[] key,
in int minTltVersion,
in byte[] tltPukHash);
/**
- * This method can be used for installing "developer TA" that is not tied to any
+ * This method can be used for installing "developer trustlet" that is not tied to any
* service provider and/or service manager. It contacts Service Enabler and asks it to
* perform the tasks, so the device has to be connected to network in order for this to
* succeed.
* The service progress is informed with the same Intents as is progress of the
* @ref RootPAServiceIfc#doProvisioning, however there is an additional
* Intent com.gd.mobicore.pa.service.INSTALL_TRUSTLET for returning the encrypted
- * TA binary.
+ * trustlet binary.
*
* There are constants related to the intents in @ref RootPAProvisioningIntents
*
* @param spid service provider id
- * @param uuid uuid of the TA in hex, without dashes. Needs to be correct length.
- * @param taBinary TA binary to be encrypted with and returned back.
+ * @param uuid uuid of the trustlet in hex, without dashes. Needs to be correct length.
+ * @param trustletBinary trustlet binary to be encrypted with and returned back.
* If the binary is already encrypted, this array must be empty. The binary
- * has to be encrypted for transfer. Note that only either taBinary
+ * has to be encrypted for transfer. Note that only either trustletBinary
* or key can be given. There are sperate instructions on how the binary is to
* be encrypted and packaged.
- * @param minTltVersion minimum version of the TA
+ * @param minTltVersion minimum version of the trustlet
* @param tltPukHash this field is not used at the moment, null is fine here.
- * @param memoryType memory where the TA is to be loaded and executed: 0 - if enough space is available,
- load the TA into the internal memory, otherwise into the external memory, 1 - internal memory,
+ * @param memoryType memory where the trustlet is to be loaded and executed: 0 - if enough space is available,
+ load the Trustlet into the internal memory, otherwise into the external memory, 1 - internal memory,
2 - external memory
- * @param numberOfInstances indicates how many instances of a TA can be installed (run) in parallel
+ * @param numberOfInstances indicates how many instances of a trustlet can be installed (run) in parallel
* @param flags current flags are: 1 - permanent, 2 - service has no WSW control interface, 4 - debuggable
*
* @return indication of successful start of provisioning thread (ROOTPA_OK) or an error code
*/
CommandResult installTrustlet(in int spid,
in byte[] uuid,
- in byte[] taBinary,
+ in byte[] trustletBinary,
in int minTltVersion,
in byte[] tltPukHash,
in int memoryType,
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
/** \addtogroup ROOTPA AIDL Interfaces
* @{
import com.gd.mobicore.pa.ifc.CommandResult;
-/**
+/**
* RootPAOemIfc is intended to be used by OEM only. It provides means to initiate unregistering root container.
*
-* The service is started by sending intent com.gd.mobicore.pa.service.OEM_SERVICE in binding. The service is
+* The service is started by sending intent com.gd.mobicore.pa.service.OEM_SERVICE in binding. The service is
* protected by permission com.gd.mobicore.pa.permission.OEM_PERMISSION with protectionLevel "signatureOrSystem"
*/
interface RootPAOemIfc{
/**
- * For OEM testing purposes only. Contacts Service Enabler and requests it to unregister the root container,
- * so the device has to be connected to network for the call to succeed. The command returns almost immediately
- * and executes in a separate thread, the same status Intents and values as are returned with
+ * For OEM testing purposes only. Contacts Service Enabler and requests it to unregister the root container,
+ * so the device has to be connected to network for the call to succeed. The command returns almost immediately
+ * and executes in a separate thread, the same status Intents and values as are returned with
* @ref RootPAServiceIfc#doProvisioning can be returned when calling this methods. With the addition of value:
* <ul>
* <li>UNREGISTERING_ROOT_CONTAINER (id 3000)</li>
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
/** \addtogroup ROOTPA AIDL Interfaces
* @{
import com.gd.mobicore.pa.ifc.SPContainerStateParcel;
/**
-* RootPAServiceIfc is intended for SP.PA use at the time of installing new TA. It provides means
-* to communicate with content management TA (using CMP version 3), request SE to perform provisioning
-* of root container and TA container and means to obtain some information on the MobiCore and its registry.
+* RootPAServiceIfc is intended for SP.PA use at the time of installing new trustlet. It provides means
+* to communicate with content management trustlet (using CMP version 3), request SE to perform provisioning
+* of root container and trustlet container and means to obtain some information on the MobiCore and its registry.
*
* The service is started by sending intent com.gd.mobicore.pa.service.PROVISIONING_SERVICE in binding.
*/
* acquired while this method runs.
*
* @param spid provides [in] the id of the SP (SPCont)
- * @param cs [out] state of the sp container and a list of installed TA containers for the given SP
+ * @param cs [out] state of the sp container and a list of installed trustlet containers for the given SP
* @return indication of successful completion
*/
CommandResult getSPContainerStructure(in SPID spid, out SPContainerStructure cs);
*/
CommandResult getSPContainerState(in SPID spid, out SPContainerStateParcel state);
-
- /**
- * Stores the actual TA binary to registry.
- *
- * @param spid [in] service provider id
- * @param uuid [in] unique UUID of the TA
- * @param taBinary [in] the actual TA to be stored
- * @return indication of successful completion
- */
- CommandResult storeTA(in SPID spid, in byte[] uuid, in byte[] taBinary);
}
/**@}*/
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
package com.gd.mobicore.pa.ifc;
@Override
public void writeToParcel(Parcel out, int flags) {
if(productId_!=null){
- out.writeString(productId_);
+ out.writeString(productId_);
}
if(version_!=null){
out.writeBundle(version_);
+++ /dev/null
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(LIBDIR "${PREFIX}/lib")
-SET(RESOURCEDIR "${CMAKE_CURRENT_SOURCE_DIR}/resource")
-
-set(CMAKE_VERBOSE_MAKEFILE ON)
-
-pkg_check_modules(rpkgs REQUIRED libxml2)
-pkg_check_modules(rpkgs REQUIRED libxml2-devel)
-pkg_check_modules(rpkgs REQUIRED libwbxml2)
-pkg_check_modules(rpkgs REQUIRED libcurl-devel)
-pkg_check_modules(rpkgs REQUIRED openssl-devel)
-add_definitions(${rpkgs_CFLAGS})
-
-SET(SRCS
- Common/base64.c
- Common/commandhandler.c
- Common/contentmanager.c
- Common/pacmp3.c
- Common/pacmtl.c
- Common/provisioningengine.c
- Common/registry.c
- Common/seclient.c
- Common/trustletchannel.c
- Common/xmlmessagehandler.c
-)
-
-INCLUDE_DIRECTORIES(Common/include)
-INCLUDE_DIRECTORIES(Common)
-INCLUDE_DIRECTORIES(/usr/include/libxml2)
-
-FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -Wconversion-null -Werror=strict-aliasing")
-ENDFOREACH(flag)
-
-ADD_DEFINITIONS("-DLINUX -DARM -D_32BIT -DANDROID_ARM=1 -DTIZEN")
-
-# Rules for LIBPROVISIONINGAGENT
-SET(LIBPROVISIONINGAGENT_SO "provisioningagent")
-ADD_LIBRARY(${LIBPROVISIONINGAGENT_SO} SHARED ${SRCS})
-TARGET_LINK_LIBRARIES(${LIBPROVISIONINGAGENT_SO} ${rpkgs_LDFLAGS} ${LIBCLIENT_SO} ${LIBREGISTRY_SO} -lssl -lcrypto -lz -lxml2 -lcurl)
-
-INSTALL(TARGETS ${LIBPROVISIONINGAGENT_SO} DESTINATION ${LIBDIR})
-INSTALL(DIRECTORY Common/include/ DESTINATION /usr/include FILES_MATCHING PATTERN "*.h")
+++ /dev/null
-#
-# Copyright © Trustonic Limited 2013
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without modification,
-# are permitted provided that the following conditions are met:
-#
-# 1. Redistributions of source code must retain the above copyright notice, this
-# list of conditions and the following disclaimer.
-#
-# 2. Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#
-# 3. Neither the name of the Trustonic Limited nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-# OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-
-#
-# makefile for building the provisioning agent Common part for android. build the code by executing
-# $NDK_ROOT/ndk-build in the folder where this file resides
-#
-# naturally the right way to build is to use build script under Build folder. It then uses this file.
-#
-
-
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_CFLAGS += -DANDROID_ARM=1
-LOCAL_CFLAGS += -DANDROID
-LOCAL_CFLAGS +=-fstack-protector
-ifeq ($(DEBUG), 1)
- LOCAL_CFLAGS += -D__DEBUG=1
-endif
-
-
-LOCAL_SRC_FILES += pacmp3.c
-LOCAL_SRC_FILES += pacmtl.c
-LOCAL_SRC_FILES += trustletchannel.c
-LOCAL_SRC_FILES += registry.c
-LOCAL_SRC_FILES += seclient.c
-LOCAL_SRC_FILES += base64.c
-LOCAL_SRC_FILES += xmlmessagehandler.c
-LOCAL_SRC_FILES += provisioningengine.c
-LOCAL_SRC_FILES += contentmanager.c
-LOCAL_SRC_FILES += commandhandler.c
-
-
-LOCAL_C_INCLUDES += $(MOBICORE_DIR_INC)
-LOCAL_C_INCLUDES += external/curl/include
-LOCAL_C_INCLUDES += external/icu/icu4c/source/common
-LOCAL_C_INCLUDES += external/icu4c/common
-LOCAL_C_INCLUDES += external/libxml2/include
-LOCAL_C_INCLUDES += .
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
-
-ifeq ($(ROOTPA_MODULE_TEST), 1)
- LOCAL_STATIC_LIBRARIES += McStub
- LOCAL_MODULE := provisioningagent_test
-else
- LOCAL_MODULE := provisioningagent
-endif
-
-LOCAL_MODULE_TAGS := debug eng optional
-
-LOCAL_STATIC_LIBRARIES = MobiCoreTlcm
-LOCAL_SHARED_LIBRARIES = libMcClient libMcRegistry
-
-APP_PIE := true
-LOCAL_32_BIT_ONLY := true
-include $(BUILD_STATIC_LIBRARY)
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
/*
-The content of this file is copied from b64.c (http://base64.sourceforge.net)
+The content of this file is copied from b64.c (http://base64.sourceforge.net)
and modified to work with memory buffers instead of files.
The linebreak addition has been removed from the encoding part
static void decodeblock( unsigned char *in, unsigned char *out )
-{
+{
out[ 0 ] = (unsigned char ) (in[0] << 2 | in[1] >> 4);
out[ 1 ] = (unsigned char ) (in[1] << 4 | in[2] >> 2);
out[ 2 ] = (unsigned char ) (((in[2] << 6) & 0xc0) | in[3]);
*/
size_t base64DecodeStringRemoveEndZero(const char* toBeDecoded, char** resultP)
{
- size_t inSize;
- size_t outSize;
-
- unsigned char in[ENCODEDSIZE];
- unsigned char out[PLAINSIZE];
- int v;
- int i, len;
- size_t inIndex=0;
- int outIndex=0;
-
LOGD(">> base64DecodeStringRemoveEndZero");
if(NULL==toBeDecoded) return 0;
- inSize=strlen(toBeDecoded);
- outSize=((inSize*PLAINSIZE)/ENCODEDSIZE)+((inSize*PLAINSIZE)%ENCODEDSIZE);
- *resultP=(char *)malloc(outSize);
+ size_t inSize=strlen(toBeDecoded);
+ size_t outSize=((inSize*PLAINSIZE)/ENCODEDSIZE)+((inSize*PLAINSIZE)%ENCODEDSIZE);
+ *resultP=malloc(outSize);
if((*resultP)==NULL) return 0;
-
+
LOGD("in %d out %d", (int) inSize, (int) outSize);
+ unsigned char in[ENCODEDSIZE];
+ unsigned char out[PLAINSIZE];
+ int v;
+ int i, len;
+
*in = (unsigned char) 0;
*out = (unsigned char) 0;
-
-
- while( inIndex < inSize )
+
+ int inIndex=0;
+ int outIndex=0;
+ while( inIndex < inSize )
{
- for( len = 0, i = 0; i < ENCODEDSIZE && inIndex < inSize; i++ )
+ for( len = 0, i = 0; i < ENCODEDSIZE && inIndex < inSize; i++ )
{
v = 0;
// skip characters that do not belong to decoded base64 and set v
- while( inIndex < inSize && 0 == v )
+ while( inIndex < inSize && 0 == v )
{
v = toBeDecoded[ inIndex++ ];
v = ((v < FIRSTB64ASCII || v > LASTB64ASCII) ? 0 : (int) cd64[ v - FIRSTB64ASCII ]);
- if( v != 0 )
+ if( v != 0 )
{
v = ((v == (int)'$') ? 0 : v - 61);
}
}
-
+
// set the character to in buffer, but only if it is not 0 (last character in toBeDecoded illegal)
if( inIndex <= inSize )
{
}
}
- if( len > 0 )
+ if( len > 0 )
{
decodeblock( in, out );
- for( i = 0; i < (len - 1); i++ )
+ for( i = 0; i < (len - 1); i++ )
{
(*resultP)[outIndex++]=out[i];
}
}
/**
-base64encode data to a NULL terminated string.
+base64encode data to a NULL terminated string.
@param toBeEncoded the buffer to be encoded
@param length length of the buffer to be encoded
*/
char* base64EncodeAddEndZero(const char* toBeEncoded, size_t length)
{
- size_t outSize;
- char* resultP;
-
- unsigned char in[PLAINSIZE];
- unsigned char out[ENCODEDSIZE];
- int i, len;
- size_t inIndex=0;
- int outIndex=0;
-
LOGD(">> base64EncodeAddEndZero %d %s", (int) length, ((toBeEncoded!=NULL)?"ptr ok":"NULL"));
if(NULL==toBeEncoded) return NULL;
- outSize=(length/PLAINSIZE + ((length%PLAINSIZE>0)?1:0))*ENCODEDSIZE+1;
+ size_t outSize=(length/PLAINSIZE + ((length%PLAINSIZE>0)?1:0))*ENCODEDSIZE+1;
// outSize+=(outsize/LINESIZE)*2; // crlf after each full line
- resultP=(char *) malloc(outSize);
+ char* resultP=malloc(outSize);
if(resultP==NULL) return NULL;
resultP[outSize-1]=0;
- LOGD("in %d out %d", (int) length, (int) outSize);
+ unsigned char in[PLAINSIZE];
+ unsigned char out[ENCODEDSIZE];
+ int i, len;
+ LOGD("in %d out %d", (int) length, (int) outSize);
+
*in = (unsigned char) 0;
*out = (unsigned char) 0;
- while( inIndex < length )
+ int inIndex=0;
+ int outIndex=0;
+ while( inIndex < length )
{
len = 0;
- for( i = 0; i < PLAINSIZE; i++ )
+ for( i = 0; i < PLAINSIZE; i++ )
{
- if( inIndex < length )
+ if( inIndex < length )
{
in[i] = toBeEncoded[inIndex];
len++;
}
- else
+ else
{
in[i] = (unsigned char) 0;
}
inIndex++;
}
-
- if( len > 0 )
+
+ if( len > 0 )
{
encodeblock( in, out, len );
- for( i = 0; i < ENCODEDSIZE; i++ )
+ for( i = 0; i < ENCODEDSIZE; i++ )
{
resultP[outIndex++]=out[i];
}
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef BASE64_H
#define BASE64_H
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef CACERTS_H
#define CACERTS_H
4BnqNQubr5XROBOlwdkrHTveN4Y9pA==\n\
-----END CERTIFICATE-----\n\
\n\
-Apache2 vHost CA\n\
+Self signed certificate for 10.0.2.2 for RootPA testing purposes\n\
================================================================\n\
-----BEGIN CERTIFICATE-----\n\
-MIIHGzCCBQOgAwIBAgIJAOoMGzaC8DnTMA0GCSqGSIb3DQEBBQUAMIGiMQswCQYD\n\
-VQQGEwJGSTEQMA4GA1UECBMHRmlubGFuZDERMA8GA1UEBxMISGVsc2lua2kxEjAQ\n\
-BgNVBAoTCVRydXN0b25pYzEWMBQGA1UECxMNVHJ1c3RvbmljIFBLSTEaMBgGA1UE\n\
-AxMRVHJ1c3RvbmljIFJvb3QgQ0ExJjAkBgkqhkiG9w0BCQEWF3dlYm1hc3RlckB0\n\
-cnVzdG9uaWMuY29tMB4XDTEzMDIwNzA5MjgxM1oXDTMzMDIwMjA5MjgxM1owgaIx\n\
-CzAJBgNVBAYTAkZJMRAwDgYDVQQIEwdGaW5sYW5kMREwDwYDVQQHEwhIZWxzaW5r\n\
-aTESMBAGA1UEChMJVHJ1c3RvbmljMRYwFAYDVQQLEw1UcnVzdG9uaWMgUEtJMRow\n\
-GAYDVQQDExFUcnVzdG9uaWMgUm9vdCBDQTEmMCQGCSqGSIb3DQEJARYXd2VibWFz\n\
-dGVyQHRydXN0b25pYy5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC\n\
-AQDVo+0b8pUmMQZtCMs23qQJFGMAGoeeDw0h7YL/IQsXdWVldyMi+dJKibQY+sK0\n\
-7kg/1EyqAzSm0XQd1WPoPrbz11jHjfNXCXn3UVrVaccO/SUznC7BQ7BGLQC5A/ll\n\
-hJ65Eg2V+N/nAqfdN2Dto+3Eq9Kveqoxl6+hDrGtg44NyKI1bByTy32ZeQ9SL64E\n\
-MJmN6FTAdfW9ngiQ+lijooQ1Rv+Z/bgIw2Pz1wqUHDic7HPuVt1DO2aBmfXH9/Wr\n\
-sVCZu2+lXOaveU7zGcI/tSQijWTIAqE9EvvIl30TUt4AnyFShApyoVYTxNtkDoMz\n\
-XyrIXTsKIEVWSkpmQin8Q17R8URrluWOIN7Fr6JS64Rs6ZuBFi1/Ly3a1JleXV72\n\
-y4gM5AaAA216ntppX7B9cvjbjuW20bcmwJJ7nTikaA0D90J9kHGBCmOKNxI+baiy\n\
-IUPH4l9TaGykuqQ6GCLNMjpeKpo5pnRYZQxIzKmvWWAo96wRYZ+5P3ViUhSfNn6f\n\
-5AhAOwyAiAIiC/3Vuc2dDS4cE/IaWLTfva9IxSdW5fW6oURTsft9dLPGM9vkFTjO\n\
-ODs00hM4Q6a6WsmeIoaH/WgVD+MVlIO3o8+fUhdiQJyZIgtt/cquAlkr4/xBaARZ\n\
-0NMMKOZmiQJ27xqO8F0YoGmIks5wsN9AMV7BwlDs+rVffwIDAQABo4IBUDCCAUww\n\
-MAYJYIZIAYb4QgENBCMWIVtSb290IGNlcnRpZmljYXRpb24gYXV0aG9yaXR5XSBD\n\
-QTAdBgNVHQ4EFgQUWE1tsuTxDUQ4e+C8KJR6Y1Icn30wgdcGA1UdIwSBzzCBzIAU\n\
-WE1tsuTxDUQ4e+C8KJR6Y1Icn32hgaikgaUwgaIxCzAJBgNVBAYTAkZJMRAwDgYD\n\
-VQQIEwdGaW5sYW5kMREwDwYDVQQHEwhIZWxzaW5raTESMBAGA1UEChMJVHJ1c3Rv\n\
-bmljMRYwFAYDVQQLEw1UcnVzdG9uaWMgUEtJMRowGAYDVQQDExFUcnVzdG9uaWMg\n\
-Um9vdCBDQTEmMCQGCSqGSIb3DQEJARYXd2VibWFzdGVyQHRydXN0b25pYy5jb22C\n\
-CQDqDBs2gvA50zASBgNVHRMBAf8ECDAGAQH/AgEAMAsGA1UdDwQEAwIBBjANBgkq\n\
-hkiG9w0BAQUFAAOCAgEAJfOt6/wv8CMV5eP6191m68N3Ig0FypzqQlsYbLmKlOmj\n\
-80lVydHqp2nJGaqnCwmwzf8G+TkhvGqF9V+sABkoh+d1vOZAz486gmZNtx4yTIXm\n\
-0/n/RmrDf6jRx1RP7nNa+vNHjhGAdcXnWkYSbD/vWqSU9ujRPRWghAczOX35zfF1\n\
-JwCSzwNHXkQ98YitO9vB00yUCnoczSA9Dn2ffJtHzeWU0gbouN5Lbb65yB0F+SFY\n\
-zmDXXk2RiBKOF5NJZMX2XfxubgeU+CVE9Upe/mt8aoYzovO/IEx6SgJw2pvEGvXS\n\
-nt7I1oI0xa4TSe4eGnqEwrvESpE4lBDHRtxZ6wtD4iYj30oMXbmg1OrLE9ZypVRa\n\
-7SJTiOCABTy4RxVU9A+jFDDvMjpgH3YTahGoctjJ/8LZwElYDS0eursyBtv/PwXH\n\
-V+P1fBz9s4tBeAzUGt7N4EbL82oB4nna8uc2r60+TOeRGQtVSyatPBZ6755WVS8U\n\
-msd5TjlPsNhZzA30D84Ww9qEXUa+5yNZNYyOZ5bnxa/3Wusmn27SKB7Pa6SijWdl\n\
-IbToFKVSPR5Ehzr2Z1Qw24tLJkVgJUPiu/O1T5WVwgIC36+dXrdUGtVJr7YX3NgI\n\
-2I+wG6EdzBYoWSWa7vkx1YqhLF2zY1SRECGGljUhXJhlziwAQFgzLGwAQ8RMsoU=\n\
+MIICyTCCAbGgAwIBAgIJAPJnq4Q6g6GlMA0GCSqGSIb3DQEBBQUAMBQxEjAQBgNV\n\
+BAMTCXRlcm9ua29uZTAeFw0xMzAyMjAwODM4MzBaFw0yMzAyMTgwODM4MzBaMBQx\n\
+EjAQBgNVBAMTCXRlcm9ua29uZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n\
+ggEBANTqu+e+gvW7fzoq59DlM2z4kWLYfGKY0DKs8dB15uo1p3tAEn/SWxTE5s8t\n\
+HxW7ui7fs5JL8AC/94jCAbeN/xPJBf4nVdjnlg19fWiylcq4Ib+FxhCar6bu/a2W\n\
+uUvI8IuM42Z8uyybBRVv8Q1Sqn+O4YiPfvVi+7oAu0pE1vemlXZ7SyXecBBtqBpy\n\
+sWfW2lV4ixeLqSay9o/ZgHRdUdkZorv/eDpLlVIwo7zmQsLb0jbGMlfRATsNkYI8\n\
+IEOxPdJSIUjnY+tZcMYQniCc0CnxWIMAxWJxMgQchyCQPkNAStwEsO0Ty3NJKGfr\n\
+mMHIzc58x999i+MeZ80AWbLjjX0CAwEAAaMeMBwwCQYDVR0TBAIwADAPBgNVHREE\n\
+CDAGhwQKAAICMA0GCSqGSIb3DQEBBQUAA4IBAQACnClBnUXBUf+GmFlq2F+8k4m1\n\
+0A9q+7Krk56JgqzdBMy8SO7FHnsyd2azWoqXzSuJyVsTMfCD0xfWXKSdzJJPJvUR\n\
+SYNQxYNUWbVKfXjXQnALltR7D+IvHWCukeohBx3nPjnFzfb68xyr2809RTEdYFyq\n\
+3olggSjYDRiX+n1XP8ryx/l10X8M9cKkLXsa9o8bSyYrpxPuYPCM6bD9g2xriAO+\n\
+1irwp3fWWFcm1oedSSNv8E9AiZuevuliT5+0BtoXY11NE+ipPKDtJUVuo2gHRcqo\n\
+/92iZY4T5y0ERhZ2jnRB5k6xdb94EdL2aSBmz6XXbr7thAE29HUwkprKYaAt\n\
-----END CERTIFICATE-----\n"
#endif
-//CACERTS_H
+//CACERTS_H
\ No newline at end of file
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <string.h>
#include <stdlib.h>
-
-#include <wrapper.h>
-#ifdef WIN32
- #include <windows.h>
-#else
- #include <pthread.h>
-#endif
+#include <pthread.h>
#include <TlCm/3.0/tlCmApi.h>
#include <MobiCoreDriverApi.h>
/*
See provisioningagent.h for description of this function.
*/
+
rootpaerror_t executeCmpCommands(int numberOfCommands, CmpMessage* commandsP, CmpMessage* responsesP, uint32_t* internalError)
{
- LOGD("executeCmpCommands");
+ LOGD(">>executeCmpCommands");
return executeContentManagementCommands(numberOfCommands, commandsP, responsesP, internalError);
+ LOGD("<<executeCmpCommands");
}
rootpaerror_t openSessionToCmtl()
rootpaerror_t getVersion(int* tag, mcVersionInfo_t* versionP)
{
+ LOGD(">>getVersion");
rootpaerror_t ret=ROOTPA_OK;
uint32_t internalError=0;
CmpMessage command;
CmpMessage response;
- LOGD(">>getVersion");
memset(&command,0,sizeof(CmpMessage));
memset(&response,0,sizeof(CmpMessage));
command.length=GET_VERSION_COMMAND_LENGTH;
- command.contentP=(uint8_t*)malloc(GET_VERSION_COMMAND_LENGTH);
+ command.contentP=malloc(GET_VERSION_COMMAND_LENGTH);
if(!command.contentP)
{
return ROOTPA_ERROR_OUT_OF_MEMORY;
rootpaerror_t getSuid(mcSuid_t* suidP)
{
+ LOGD(">>getSuid");
rootpaerror_t ret=ROOTPA_OK;
uint32_t internalError=0;
CmpMessage command;
CmpMessage response;
- LOGD(">>getSuid");
memset(&command,0,sizeof(CmpMessage));
memset(&response,0,sizeof(CmpMessage));
command.length=GET_SUID_COMMAND_LENGTH;
- command.contentP=(uint8_t*)malloc(GET_SUID_COMMAND_LENGTH);
+ command.contentP=malloc(GET_SUID_COMMAND_LENGTH);
if(!command.contentP)
{
return ROOTPA_ERROR_OUT_OF_MEMORY;
rootpaerror_t isRootContainerRegistered(bool* isRegisteredP)
{
- rootpaerror_t ret=ROOTPA_OK;
- ROOTCONTAINERP rootContP=NULL;
- uint32_t rootContSize=0;
- mcResult_t result;
LOGD(">>isRootContainerRegistered");
+ rootpaerror_t ret=ROOTPA_OK;
+
if(NULL==isRegisteredP) return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
- result=regReadRoot(&rootContP, &rootContSize);
+ ROOTCONTAINERP rootContP=NULL;
+ uint32_t rootContSize=0;
+ mcResult_t result=regReadRoot(&rootContP, &rootContSize);
if(MC_DRV_OK == result)
{
rootpaerror_t isSpContainerRegistered(mcSpid_t spid, bool* isRegisteredP)
{
- rootpaerror_t ret=ROOTPA_OK;
- int state;
LOGD(">>isSpContainerRegistered");
+ rootpaerror_t ret=ROOTPA_OK;
if(NULL==isRegisteredP) return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
- ret=getSpContainerState(spid, (mcContainerState_t*)&state);
+ int state;
+ ret=getSpContainerState(spid, &state);
if(ROOTPA_OK == ret)
{
rootpaerror_t getSpContainerState(mcSpid_t spid, mcContainerState_t* stateP)
{
+ LOGD(">>getSpContainerState");
rootpaerror_t ret=ROOTPA_OK;
- mcResult_t result;
- LOGD(">>getSpContainerState");
if(NULL==stateP) return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
- result=regGetSpState(spid, stateP);
+ mcResult_t result=regGetSpState(spid, stateP);
if(MC_DRV_ERR_INVALID_DEVICE_FILE == result)
{
rootpaerror_t getSpContainerStructure(mcSpid_t spid, SpContainerStructure* spContainerStructure)
{
- rootpaerror_t ret=ROOTPA_OK;
- SPCONTAINERP spP=NULL;
- uint32_t spContSize=0;
- mcResult_t result;
- int i;
- TLTCONTAINERP tltP=NULL;
LOGD(">>getSpContainerStructure");
+ rootpaerror_t ret=ROOTPA_OK;
if(NULL==spContainerStructure) return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
memset(spContainerStructure, 0xFF, sizeof(SpContainerStructure));
spContainerStructure->nbrOfTlts=0;
- result=regReadSp(spid, &spP, &spContSize);
+ SPCONTAINERP spP=NULL;
+ uint32_t spContSize=0;
+ mcResult_t result=regReadSp(spid, &spP, &spContSize);
if(MC_DRV_OK == result)
{
spContainerStructure->state=spP->cont.attribs.state;
+ int i;
+
for(i=0; i<MC_CONT_CHILDREN_COUNT; i++)
{
if(containerExists(spP->cont.children[i]))
{
memcpy(&spContainerStructure->tltContainers[spContainerStructure->nbrOfTlts].uuid, &(spP->cont.children[i]), sizeof(mcUuid_t));
-
+ TLTCONTAINERP tltP=NULL;
if(ROOTPA_OK == ret)
{
uint32_t tltContSize=0;
return ret;
}
-rootpaerror_t storeTA(mcSpid_t spid, const mcUuid_t* uuidP, const uint8_t* taBinP, uint32_t taBinLength)
-{
- rootpaerror_t ret=ROOTPA_OK;
- mcResult_t result=0;
- mcContainerState_t state;
-
- result=regGetTaState(spid, uuidP, &state);
- LOGD("storeTA, TA state %d, result 0x%x", state, result);
- if(MC_DRV_ERR_INVALID_DEVICE_FILE == result)
- {
- LOGW("storeTA, not storing, since TA container is missing");
- ret=ROOTPA_ERROR_ILLEGAL_ARGUMENT;
- }
- else if (result!=MC_DRV_OK)
- {
- LOGW("storeTA, not storing, due to TA container read error 0x%x", result);
- ret=ROOTPA_ERROR_REGISTRY;
- }
- else
- {
- result =regStoreTA(spid, uuidP, taBinP, taBinLength);
-
- if(result != MC_DRV_OK)
- {
- LOGE("storeTA, storing TA failed, result from registry 0x%x", result);
- ret=ROOTPA_ERROR_REGISTRY;
- }
- }
-
- return ret;
-}
-
void dummyCallback(ProvisioningState state, rootpaerror_t error, tltInfo_t* tltInfoP)
{
- (void) state;
- (void) error;
- (void) tltInfoP;
LOGD("dummy callback %d %d %ld", state, error, (long int) tltInfoP);
}
initialRel_t initialRel;
trustletInstallationData_t* tltInstallationDataP;
} provisioningparams_t;
-#ifdef WIN32
- void* WINAPI provisioningThreadFunction(void* paramsP)
-#else
- void* provisioningThreadFunction(void* paramsP)
-#endif
+
+void* provisioningThreadFunction(void* paramsP)
{
- rootpaerror_t ret=ROOTPA_OK;
LOGD(">>provisioningThreadFunction %ld", (long int)((provisioningparams_t*)paramsP)->callbackP);
+
+ rootpaerror_t ret=ROOTPA_OK;
if((ret=openCmtlSession())==ROOTPA_OK)
{
doProvisioningWithSe(((provisioningparams_t*)paramsP)->spid,
}
else
{
- ((provisioningparams_t*)paramsP)->callbackP(ERROR_STATE, ret, NULL);
+ ((provisioningparams_t*)paramsP)->callbackP(ERROR, ret, NULL);
LOGE("provisioningThreadFunction: was not able to open session %d", ret);
}
free((char*)((provisioningparams_t*)paramsP)->tltInstallationDataP->tltPukHashP);
free(((provisioningparams_t*)paramsP)->tltInstallationDataP);
}
- if (paramsP != NULL) {
- free(paramsP);
- paramsP = NULL;
- }
+ free(paramsP); // Coverity complains that paramsP allocated in "provisioning" is not freed. It is done here.
LOGD("<<provisioningThreadFunction");
-#ifdef WIN32
- ExitThread(NULL);
-#else
pthread_exit(NULL);
-#endif
return NULL; // this is required by some compilers with some settings in order to avoid errors.
}
rootpaerror_t provision(mcSpid_t spid, CallbackFunctionP callbackP, SystemInfoCallbackFunctionP systemInfoCallbackP, trustletInstallationData_t* tltDataP, initialRel_t initialRel)
{
- provisioningparams_t* paramsP;
- rootpaerror_t ret;
-#ifdef WIN32
- HANDLE provisioningThread;
- DWORD threadID;
-#endif
LOGD(">>provision %ld %ld", (long int) callbackP, (long int) dummyCallback);
if(NULL==callbackP) callbackP=dummyCallback;
if(NULL==systemInfoCallbackP) systemInfoCallbackP=dummySysInfoCallback;
- paramsP=(provisioningparams_t*)malloc(sizeof(provisioningparams_t));
+ provisioningparams_t* paramsP=malloc(sizeof(provisioningparams_t));
if(!paramsP) return ROOTPA_ERROR_OUT_OF_MEMORY;
memset(paramsP,0,sizeof(provisioningparams_t)); // initialize in order to satisfy valgrind
paramsP->spid=spid;
if(tltDataP)
{
- // Coverity complains that paramsP allocated here is not freed. It is done in "provisioningThreadFunction"
- paramsP->tltInstallationDataP=(trustletInstallationData_t*)malloc(sizeof(trustletInstallationData_t));
+ // Coverity complains that paramsP allocated here is not freed. It is done in "provisioningThreadFunction"
+ paramsP->tltInstallationDataP=malloc(sizeof(trustletInstallationData_t));
if(!paramsP->tltInstallationDataP)
{
free(paramsP);
- paramsP = NULL;
return ROOTPA_ERROR_OUT_OF_MEMORY;
}
// malloc and copy data from/to the pointers
- paramsP->tltInstallationDataP->dataP=(const uint8_t *)malloc(tltDataP->dataLength);
+ paramsP->tltInstallationDataP->dataP=malloc(tltDataP->dataLength);
if(!paramsP->tltInstallationDataP->dataP)
{
free(paramsP->tltInstallationDataP);
free(paramsP);
- paramsP = NULL;
return ROOTPA_ERROR_OUT_OF_MEMORY;
}
memset((char*)paramsP->tltInstallationDataP->dataP,0,tltDataP->dataLength); // initialize in order to satisfy valgrind
memcpy((char*)paramsP->tltInstallationDataP->dataP, tltDataP->dataP, tltDataP->dataLength);
- paramsP->tltInstallationDataP->tltPukHashP=(const uint8_t *)malloc(tltDataP->tltPukHashLength);
+ paramsP->tltInstallationDataP->tltPukHashP=malloc(tltDataP->tltPukHashLength);
if(!paramsP->tltInstallationDataP->tltPukHashP)
{
free((void*) paramsP->tltInstallationDataP->dataP);
free((void*) paramsP->tltInstallationDataP);
free(paramsP);
- paramsP = NULL;
return ROOTPA_ERROR_OUT_OF_MEMORY;
}
memset((char*)paramsP->tltInstallationDataP->tltPukHashP,0,tltDataP->tltPukHashLength); // initialize in order to satisfy valgrind
paramsP->initialRel = initialRel;
- ret=ROOTPA_OK;
+ rootpaerror_t ret=ROOTPA_OK;
ret=getSuid(¶msP->suid);
if(ROOTPA_OK==ret)
{
-#ifdef WIN32
- provisioningThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)provisioningThreadFunction, (void*) paramsP, 0, &threadID);
-
- if (provisioningThread == NULL)
- {
- LOGE("unable to create thread");
- ret=ROOTPA_ERROR_INTERNAL;
- }
-#else
pthread_t provisioningThread;
pthread_attr_t attributes;
int r=0;
LOGE("unable to set detached state, trying with defaults %d",r);
}
- r=pthread_create(&provisioningThread, &attributes, provisioningThreadFunction, (void*) paramsP);
+ r=pthread_create(&provisioningThread, &attributes, provisioningThreadFunction, (void*) paramsP);
if(r)
{
LOGE("unable to create thread %d",r);
free(paramsP);
- paramsP = NULL;
ret=ROOTPA_ERROR_INTERNAL;
}
pthread_attr_destroy(&attributes);
}
-#endif
}
else
{
LOGE("provisioning can not get suid: %d",ret );
}
LOGD("<<provision ret: %d",ret );
-
return ret;
}
rootpaerror_t unregisterRootContainer(CallbackFunctionP callbackP, SystemInfoCallbackFunctionP systemInfoCallbackP)
{
- mcSpid_t spid;
LOGD("unregisterRootContainer");
+
+ mcSpid_t spid;
memset(&spid, 0x0, sizeof(mcSpid_t));
return provision(spid, callbackP, systemInfoCallbackP, NULL, initialRel_DELETE);
}
-
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <string.h>
#include <stdlib.h>
{
closeCmtlSession();
}
-
+
handle_=tltChannelOpen(sizeOfCmp(), &error);
if(NULL==handle_)
{
{
ret=ROOTPA_ERROR_MOBICORE_CONNECTION;
}
- }
+ }
return ret;
}
rootpaerror_t executeOneCmpCommand(CMTHANDLE handle, CmpMessage* commandP, CmpMessage* responseP);
rootpaerror_t executeContentManagementCommands(int numberOfCommands, CmpMessage* commandsP, CmpMessage* responsesP, uint32_t* internalError)
-{
+{
+ LOGD(">>executeContentManagementCommands");
rootpaerror_t ret=ROOTPA_OK ;
rootpaerror_t iRet=ROOTPA_OK ;
bool selfOpened=false;
- CMTHANDLE handle;
- LOGD(">>executeContentManagementCommands");
-
+
*internalError=0;
if(handle_==NULL)
ret=openCmtlSession();
selfOpened=true;
}
- handle=handle_;
-
+ CMTHANDLE handle=handle_;
+
if (handle)
{
int i;
{
responsesP[i].hdr.id=commandsP[i].hdr.id; // match the id;
responsesP[i].hdr.ignoreError=commandsP[i].hdr.ignoreError;
-
+
if(commandsP[i].length>0)
{
if(((iRet=executeOneCmpCommand(handle, &commandsP[i], &responsesP[i]))!=ROOTPA_OK))
{
responsesP[i].hdr.ret=ret;
}
-
+
if(commandsP[i].hdr.ignoreError==false)
{
LOGE("executeContentManagementCommands, ignoreError==false, returning %d", ret);
else
{
LOGE("executeContentManagementCommands, empty command");
- }
+ }
}
if(ret!=ROOTPA_OK)
*/
rootpaerror_t executeOneCmpCommand(CMTHANDLE handle, CmpMessage* commandP, CmpMessage* responseP)
{
- mcResult_t mcRet;
- cmpCommandId_t commandId;
- rootpaerror_t ret;
- uint32_t neededBytes;
LOGD(">>executeOneCmpCommand");
- if (unlikely( bad_write_ptr(handle,sizeof(CMTSTRUCT))))
+ if (unlikely( bad_write_ptr(handle,sizeof(CMTSTRUCT))))
{
return ROOTPA_ERROR_INTERNAL;
}
- if(unlikely(commandP->contentP==NULL || commandP->length< sizeof(cmpCommandId_t)))
+ if(unlikely (commandP->contentP==NULL || commandP->length< sizeof(cmpCommandId_t)))
{
return ROOTPA_ERROR_INTERNAL;
}
- mcRet=MC_DRV_OK;
- commandId=getCmpCommandId(commandP->contentP);
-
+ mcResult_t mcRet=MC_DRV_OK;
+ cmpCommandId_t commandId=getCmpCommandId(commandP->contentP);
+
handle->mappedSize=getTotalMappedBufferSize(commandP);
if(0==handle->mappedSize)
{
return ROOTPA_COMMAND_NOT_SUPPORTED;
}
- ret=ROOTPA_OK;
- while(true)
+ rootpaerror_t ret=ROOTPA_OK;
+ while(true)
{
- handle->mappedP=(uint8_t*)malloc((size_t) handle->mappedSize);
+ handle->mappedP=malloc((size_t) handle->mappedSize);
if(NULL==handle->mappedP)
{
ret=ROOTPA_ERROR_OUT_OF_MEMORY;
break;
}
- neededBytes=getNeededBytesFromResponse(handle->wsmP);
+ uint32_t neededBytes=getNeededBytesFromResponse(handle->wsmP);
if(0==neededBytes)
{
break;
}
- if((uint32_t)-1==neededBytes)
+ if(-1==neededBytes)
{
- ret=ROOTPA_ERROR_MOBICORE_CONNECTION;
+ ret=ROOTPA_ERROR_MOBICORE_CONNECTION;
break;
}
if(neededBytes <= handle->mappedSize)
{
- LOGE("executeOneCmpCommand, there is something wrong. CMTL is requesting smaller buffer than we originally had. Command: %d, original %d requested %d",
+ LOGE("executeOneCmpCommand, there is something wrong. CMTL is requesting smaller buffer than we originally had. Command: %d, original %d requested %d",
commandId, handle->mappedSize, neededBytes);
ret=ROOTPA_ERROR_MOBICORE_CONNECTION;
break;
LOGE("executeOneCmpCommand not able to free mapped memory %d", mcRet);
ret=ROOTPA_ERROR_MOBICORE_CONNECTION;
}
- LOGD("freeing mapped memory %ld", (long int) handle->mappedP);
- free(handle->mappedP);
+ LOGD("freeing mapped memory %ld", (long int) handle->mappedP);
+ free(handle->mappedP);
if(commandP->hdr.ret==ROOTPA_OK) commandP->hdr.ret=ret;
- if(responseP->hdr.ret==ROOTPA_OK) responseP->hdr.ret=ret;
+ if(responseP->hdr.ret==ROOTPA_OK) responseP->hdr.ret=ret;
LOGD("<<executeOneCmpCommand %d %d",commandId, ret);
return ret;
}
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef CONTENTMANAGER_H
#define CONTENTMANAGER_H
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef ENROLLMENTSERVICEXMLSCHEMA_H
#define ENROLLMENTSERVICEXMLSCHEMA_H
<xsd:attribute name=\"id\" type=\"xsd:int\" use=\"required\" /> \
</xsd:complexType> \
\
- <xsd:complexType name=\"TrustletEncryptionKey\"> \
+ <xsd:complexType name=\"TrustletEncryptionKey\"> \
<xsd:simpleContent> \
<xsd:extension base=\"xsd:base64Binary\"> \
<xsd:attribute name=\"minTltVersion\" type=\"mcpt:Version\" use=\"required\" /> \
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef LOGGING_H
#define LOGGING_H
-#ifndef LOG_TAG
#define LOG_TAG "RootPA-C"
-#endif
#ifdef ANDROID
#include <android/log.h>
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
- #ifdef __DEBUG
+ #ifdef __DEBUG
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#else
#define LOGD(scite ...)
- #endif
+ #endif
#else
-#ifdef WIN32
#include <stdio.h>
- #include <windows.h>
- void MyOutputFunction(const char *str, ...);
- void OutputToLogfile(char buf[]);
-
-
-#ifdef __cplusplus
-
- extern "C" void MyOutputFunctionC(const char *str, ...);
-
- #define LOGE(fmt, ...) MyOutputFunction(fmt "\n", ##__VA_ARGS__)
- #define LOGW(fmt, ...) MyOutputFunction(fmt "\n", ##__VA_ARGS__)
- #define LOGI(fmt, ...) MyOutputFunction(fmt "\n", ##__VA_ARGS__)
+ #define LOGE(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
+ #define LOGW(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
+ #define LOGI(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
#ifdef __DEBUG
- #define LOGD(fmt, ...) MyOutputFunction(fmt "\n", ##__VA_ARGS__)
+ #define LOGD(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
#else
#define LOGD(fmt, ...)
- #endif
-#else
-
- #define LOGE(fmt, ...) MyOutputFunctionC(fmt "\n", ##__VA_ARGS__)
- #define LOGW(fmt, ...) MyOutputFunctionC(fmt "\n", ##__VA_ARGS__)
- #define LOGI(fmt, ...) MyOutputFunctionC(fmt "\n", ##__VA_ARGS__)
-
- #ifdef __DEBUG
- #define LOGD(fmt, ...) MyOutputFunctionC(fmt "\n", ##__VA_ARGS__)
- #else
- #define LOGD(fmt, ...)
- #endif
-
+ #endif
#endif
-#else
-#ifdef TIZEN
- #include <stdio.h>
-#endif /*Tizen*/
- #define LOGE(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
- #define LOGW(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
- #define LOGI(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
- #ifdef __DEBUG
- #define LOGD(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
- #else
-#ifdef TIZEN
- #define LOGD(fmt, ...) do { } while(0)
-#else
- #define LOGD(fmt, ...)
-#endif/*Tizen*/
- #endif
-#endif // WIN32
-#endif // ANDROID
#endif // LOGGING_H
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef PROVISIONINGAGENT_H
#define PROVISIONINGAGENT_H
#endif
-#include <wrapper.h>
+#include <stdbool.h>
#include <TlCm/3.0/cmp.h>
#include <mcVersionInfo.h>
*/
rootpaerror_t unregisterRootContainer(CallbackFunctionP callbackP, SystemInfoCallbackFunctionP systemInfoCallbackP);
-
-/**
-Store's the GP TA binary to the registry. The corresponding TA container has to exists and contain correct information for decrypting the TA.
-
-@param spid service provider ID
-@param uuidP pointer to the UUID of the TA binary. This is the UUID that all t-base TA's have, NOT the UUID specific to GP TA's
-@param taBinP pointer to the actual TA binary
-@param taBinLength size of the actual TA binary
-
-@return ROOTPA_OK is unregistering root container succeeds, an error code otherwise
-*/
-rootpaerror_t storeTA(mcSpid_t spid, const mcUuid_t* uuidP, const uint8_t* taBinP, uint32_t taBinLength);
-
/**
This is helper function for the platform dependent part to inform the platform independent part
on the file storage location
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef ROOTPA_H
#define ROOTPA_H
extern "C" {
#endif
-#include <wrapper.h>
+#include <stdbool.h>
#include <mcUuid.h>
#include <mcContainer.h>
AUTHENTICATING_ROOT=4,
CREATING_SP_CONTAINER=5,
FINISHED_PROVISIONING=6,
- ERROR_STATE=7,
+ ERROR=7,
UNREGISTERING_ROOT_CONTAINER=8,
PROVISIONING_STATE_INSTALL_TRUSTLET=0xFEED,
PROVISIONING_STATE_THREAD_EXITING=0xDEAD
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef ROOTPAERRORS_H
#define ROOTPAERRORS_H
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
/** @addtogroup ROOTPA
*/
#ifndef ROOTPA_VERSION_H_
#define ROOTPA_VERSION_H_
-#define ROOTPA_VERSION_MAJOR 3
-#define ROOTPA_VERSION_MINOR 96
+#define ROOTPA_VERSION_MAJOR 2
+#define ROOTPA_VERSION_MINOR 68
#endif /** ROOTPA_VERSION_H_ */
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef WRAPPER_H_
-#define WRAPPER_H_
-
-#ifdef WIN32
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stdint.h>
- #include <inttypes.h>
-
- #define snprintf _snprintf
-
- typedef int pid_t;
-
- #define bool int
- #define TRUE 1
- #define FALSE 0
-
- #define false FALSE
- #define true TRUE
-
- #define sleep(x) Sleep(x)
-
- #ifdef __cplusplus
- }
- #endif // __cplusplus
-#else
- #include <stdbool.h>
-#endif // WINDOWS_BUILD
-#endif //WRAPPER_H_
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <string.h>
#include <stdlib.h>
-#include <wrapper.h>
+#include <stdbool.h>
#include <TlCm/3.0/cmpMap.h>
#include <TlCm/tlCmApiCommon.h>
return ROOTPA_ERROR_INTERNAL;
}
LOGD("allocateResponseBuffer, size %d", responseP->length);
- responseP->contentP=(uint8_t*)malloc(responseP->length);
+ responseP->contentP=malloc(responseP->length);
if(responseP->contentP==NULL) return ROOTPA_ERROR_OUT_OF_MEMORY;
return ROOTPA_OK;
}
{
if( neededSize > handle->mappedSize)
{
- uint8_t* newMappedP = (uint8_t*)realloc(handle->mappedP, neededSize);
+ uint8_t* newMappedP = realloc(handle->mappedP, neededSize);
if(!newMappedP)
{
LOGE("ensureMappedBufferSize, unable to allocate more memory %d", neededSize);
rootpaerror_t prepareCommand(cmpCommandId_t commandId, CmpMessage* inCommandP, CMTHANDLE handle, CmpMessage* responseP)
{
+ LOGI("prepareCommand command id %d length %d", commandId, inCommandP->length); // this is LOGI level on purpose to indicate that CMP command has reached RootPA
+
uint8_t* outCommandP =handle->mappedP;
uint32_t offset=0;
uint32_t elementIndex=1;
rootpaerror_t ret=ROOTPA_OK;
mcResult_t mcRet=MC_DRV_OK;
- LOGI("prepareCommand command id %d length %d", commandId, inCommandP->length); // this is LOGI level on purpose to indicate that CMP command has reached RootPA
memset(handle->wsmP,0,sizeOfCmp());
mcResult_t storeContainers(cmpCommandId_t commandId, CMTHANDLE handle, uint32_t elementIndex, uint32_t offset)
{
+ LOGD(">>pacmp3 storeContainers for %d element %d offset %d", commandId, elementIndex, offset);
mcResult_t mcRet=MC_DRV_OK;
uint32_t length=0;
- LOGD(">>pacmp3 storeContainers for %d element %d offset %d", commandId, elementIndex, offset);
// store the containers when needed
switch(commandId)
*/
rootpaerror_t handleResponse(cmpCommandId_t commandId, CmpMessage* outResponseP, CMTHANDLE handle)
{
+ LOGD(">>handleResponse for command %d ", commandId);
mcResult_t mcRet=MC_DRV_OK;
rootpaerror_t ret=ROOTPA_OK;
- uint32_t elementIndex=1;
- uint32_t offset=0;
- uint32_t length=0;
- LOGD(">>handleResponse for command %d ", commandId);
if(isValidResponseTo(commandId, handle->wsmP)==false)
{
return ROOTPA_ERROR_COMMAND_EXECUTION;
}
+ uint32_t elementIndex=1;
+ uint32_t offset=0;
+ uint32_t length=0;
+
ret=allocateResponseBuffer(outResponseP, handle);
if(ROOTPA_OK==ret)
if(mcRet != MC_DRV_OK)
{
LOGE("pacmp3 handleResponse for %d registry failed %d", commandId, mcRet);
- if((mcResult_t)-1==mcRet)
+ if(-1==mcRet)
{
ret = ROOTPA_ERROR_INTERNAL;
}
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef PACMP3_H
#define PACMP3_H
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <string.h>
#include "logging.h"
-
#include "pacmp3.h"
#include "registry.h"
#include "pacmtl.h"
void setCmdElementInfo(uint32_t* elementNbrP, uint8_t* wsmP, uint32_t* elementOffsetP, uint32_t elementLength)
{
- cmpMapOffsetInfo_t* elementP;
if(NULL==elementNbrP || NULL == elementOffsetP || NULL == wsmP)
{
LOGE("pacmtl setCmdElementInfo NULL's in input, not setting the element %ld %ld", (long int) elementNbrP, (long int) elementOffsetP);
return;
}
- elementP=(&((cmpCommandHeaderTci_t*)wsmP)->cmpCmdMapOffsetInfo);
+ cmpMapOffsetInfo_t* elementP=(&((cmpCommandHeaderTci_t*)wsmP)->cmpCmdMapOffsetInfo);
elementP+=((*elementNbrP)-1);
elementP->offset=*elementOffsetP;
const cmpSizes_t* getCmpSizeInfo(uint32_t cmdId)
{
- size_t i = 0;
+ int i = 0;
for ( i = 0; i < sizeof(sizeTable_)/sizeof(cmpSizes_t); i++)
{
if (cmdId == sizeTable_[i].cmdId)
uint32_t getTotalMappedBufferSize(CmpMessage* commandP)
{
- uint32_t commandSize;
- uint32_t containerSize;
const cmpSizes_t* sizesP=getCmpSizeInfo(getCmpCommandId(commandP->contentP));
if(NULL==sizesP) return 0;
- commandSize=bigger(sizesP->cmdRspSize, commandP->length);
- containerSize=bigger(sizesP->cmdContainerSize, sizesP->rspContainerSize);
+ uint32_t commandSize=bigger(sizesP->cmdRspSize, commandP->length);
+ uint32_t containerSize=bigger(sizesP->cmdContainerSize, sizesP->rspContainerSize);
LOGD("pacmtl getTotalMappedBufferSize %d returning %d (%d (%d %d) %d (%d %d))", sizesP->cmdId, commandSize+containerSize,
commandSize, sizesP->cmdRspSize, commandP->length,
containerSize, sizesP->cmdContainerSize, sizesP->rspContainerSize);
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef PACMTL_H
#define PACMTL_H
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <wrapper.h>
+#include <stdbool.h>
#include "rootpaErrors.h"
void addSlashToUri(char* uriP)
{
- int uriidx;
LOGD(">>addSlashToUri");
- uriidx=strlen(uriP);
+ int uriidx=strlen(uriP);
uriP[uriidx]='/';
LOGD("<<addSlashToUri %s", uriP);
}
void addBytesToUri(char* uriP, uint8_t* bytes, uint32_t length, bool uuid )
{
+ LOGD(">>addBytesToUri %d", length);
int uriidx=strlen(uriP);
- uint32_t i;
+ int i;
uint8_t singleNumber=0;
- LOGD(">>addBytesToUri %d", length);
for(i=0; i<length; i++)
{
singleNumber=(bytes[i]>>4);
size_t urlLength=0;
urlLength=strlen(initialUrl_) + (sizeof(mcSuid_t)*2) + (sizeof(mcSpid_t)*2) + (sizeof(mcUuid_t)*2)+6; //possible slash and end zero and four dashes
- tmpLinkP=(char*)malloc(urlLength);
- if(tmpLinkP != NULL)
- {
- memset(tmpLinkP,0,urlLength);
- strncpy(tmpLinkP, initialUrl_, urlLength);
- addBytesToUri(tmpLinkP, (uint8_t*) &suid, sizeof(suid), false);
- }
- else
- {
- LOGE("createBasicLink, out of memory");
- }
+ tmpLinkP=malloc(urlLength);
+ memset(tmpLinkP,0,urlLength);
+ strncpy(tmpLinkP, initialUrl_, urlLength);
+ addBytesToUri(tmpLinkP, (uint8_t*) &suid, sizeof(suid), false);
return tmpLinkP;
}
initialRel_t initialRel,
trustletInstallationData_t* tltDataP)
{
+ LOGD(">>doProvisioningWithSe");
+
rootpaerror_t ret=ROOTPA_OK;
rootpaerror_t tmpRet=ROOTPA_OK;
bool workToDo = true;
const char* usedRelP=NULL;
const char* usedCommandP=NULL;
- LOGD(">>doProvisioningWithSe");
-
callbackP_=callbackP;
if(empty(initialUrl_))
}
linkP=createBasicLink(suid);
- if(NULL==linkP)
- {
- callbackP(ERROR_STATE, ROOTPA_ERROR_OUT_OF_MEMORY, NULL);
- return;
- }
- else
- {
- LOGD("SE_ADDRESS %s", linkP);
- }
if (initialRel == initialRel_DELETE)
{
- relP = RELATION_INITIAL_DELETE;
+ relP = RELATION_INITIAL_DELETE;
}
else
{
- relP = RELATION_INITIAL_POST;
+ relP = RELATION_INITIAL_POST;
if(spid!=0) // SPID 0 is not legal. We use it for requesting root container creation only (no sp)
{
addIntToUri((char*)linkP, (uint32_t) spid);
ret=openSeClientAndInit();
if(ROOTPA_OK!=ret)
{
- callbackP(ERROR_STATE, ret, NULL);
+ callbackP(ERROR, ret, NULL);
workToDo=false;
}
if(ROOTPA_OK!=ret || NULL==responseP)
{
if(ROOTPA_OK==ret) ret=ROOTPA_ERROR_XML;
- callbackP(ERROR_STATE, ret, NULL);
+ callbackP(ERROR, ret, NULL);
workToDo=false;
}
else
int mcVersionTag=0;
mcVersionInfo_t mcVersion;
-#ifdef WIN32
-// TODO- remove the memory allocation from here and handle it properly on C# code
-
- osSpecificInfo.brandP = (char*)calloc(64, sizeof(char));
- osSpecificInfo.mnoP = (char*)calloc(64, sizeof(char));
- osSpecificInfo.imeiEsnP = (char*)calloc(64, sizeof(char));
- osSpecificInfo.manufacturerP = (char*)calloc(64, sizeof(char));
- osSpecificInfo.hardwareP = (char*)calloc(64, sizeof(char));
- osSpecificInfo.modelP = (char*)calloc(64, sizeof(char));
- osSpecificInfo.versionP = (char*)calloc(64, sizeof(char));
-#endif
tmpRet=getSysInfoP(&osSpecificInfo);
if(tmpRet!=ROOTPA_OK) ret=tmpRet;
free(osSpecificInfo.modelP);
free(osSpecificInfo.versionP);
- if(responseP!=NULL)
- {
- tmpRet=httpPutAndReceiveCommand(responseP, &linkP, &relP, &commandP);
- if(tmpRet!=ROOTPA_OK) ret=tmpRet;
- }
- else if(ROOTPA_OK==ret)
- {
- workToDo=false;
- ret=ROOTPA_ERROR_OUT_OF_MEMORY;
- }
-
+ tmpRet=httpPutAndReceiveCommand(responseP, &linkP, &relP, &commandP);
+ if(tmpRet!=ROOTPA_OK) ret=tmpRet;
if(ret!=ROOTPA_OK)
{
LOGE("getSysInfoP, getVersionP or buildXmlSystemInfo or httpPutAndReceiveCommand returned an error %d", ret);
- callbackP(ERROR_STATE, ret, NULL);
+ callbackP(ERROR, ret, NULL);
if(tmpRet!=ROOTPA_OK) workToDo=false; // if sending response succeeded, we rely on "relP" to tell whether we should continue or not
}
}
if(ret!=ROOTPA_OK)
{
LOGE("httpDeleteAndReceiveCommand returned an error %d", ret);
- callbackP(ERROR_STATE, ret, NULL);
+ callbackP(ERROR, ret, NULL);
workToDo=false;
}
}
if(ret!=ROOTPA_OK)
{
LOGE("httpPostAndReceiveCommand returned an error %d", ret);
- callbackP(ERROR_STATE, ret, NULL);
+ callbackP(ERROR, ret, NULL);
workToDo=false;
}
}
if(ret!=ROOTPA_OK && ret!=ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE) // if container is not found, not sending error intent to SP.PA since it is possible that SE can recover.
{ // If it can not, it will return an error code anyway.
LOGE("httpPostAndReceiveCommand or handleXmlMessage returned an error %d %d", ret, tmpRet);
- callbackP(ERROR_STATE, ret, NULL);
+ callbackP(ERROR, ret, NULL);
if(tmpRet!=ROOTPA_OK) workToDo=false; // if sending response succeeded, we rely on "relP" to tell whether we should continue or not
}
if(ret!=ROOTPA_OK)
{
LOGE("httpGetAndReceiveCommand returned an error %d", ret);
- callbackP(ERROR_STATE, ret, NULL);
+ callbackP(ERROR, ret, NULL);
workToDo=false;
}
}
{
LOGE("DO NOT UNDERSTAND REL %s", relP);
ret=ROOTPA_ERROR_ILLEGAL_ARGUMENT;
- callbackP(ERROR_STATE, ret, NULL);
+ callbackP(ERROR, ret, NULL);
workToDo=false;
}
} // while
closeSeClientAndCleanup();
- if(responseP!=NULL) {
- free((void*)responseP);
- responseP = NULL;
- }
-
- if(linkP!=NULL){
- free((void*)linkP);
- linkP = NULL;
- }
-
+ if(responseP!=NULL) free((void*)responseP);
+ if(linkP!=NULL) free((void*)linkP);
if(ROOTPA_OK != ret) LOGE("doProvisioningWithSe had some problems: %d",ret );
LOGD("<<doProvisioningWithSe ");
-
return;
}
LOGE("uploadTrustlet, no callbackP_");
return ROOTPA_COMMAND_NOT_SUPPORTED;
}
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef PROVISIONINGENGINE_H
#define PROVISIONINGENGINE_H
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <stdlib.h>
#include <MobiCoreRegistry.h>
int regReadAuthToken(AUTHTOKENCONTAINERP* atP, uint32_t* containerSize)
{
*containerSize = CONTAINER_BUFFER_SIZE; // this will be updated to actual size with the registry call
- *atP=(AUTHTOKENCONTAINERP)malloc(CONTAINER_BUFFER_SIZE);
+ *atP=malloc(CONTAINER_BUFFER_SIZE);
if(NULL==*atP) return MC_DRV_ERR_NO_FREE_MEMORY;
return mcRegistryReadAuthToken(*atP, containerSize);
}
int regReadRoot(ROOTCONTAINERP* rootP, uint32_t* containerSize)
{
*containerSize = CONTAINER_BUFFER_SIZE; // this will be updated to actual size with the registry call
- *rootP=(ROOTCONTAINERP)malloc(CONTAINER_BUFFER_SIZE);
+ *rootP=malloc(CONTAINER_BUFFER_SIZE);
if(NULL==*rootP) return MC_DRV_ERR_NO_FREE_MEMORY;
return mcRegistryReadRoot(*rootP, containerSize);
}
int regReadSp(mcSpid_t spid, SPCONTAINERP* spP, uint32_t* containerSize)
{
*containerSize = CONTAINER_BUFFER_SIZE; // this will be updated to actual size with the registry call
- *spP= (SPCONTAINERP)malloc(CONTAINER_BUFFER_SIZE);
+ *spP=malloc(CONTAINER_BUFFER_SIZE);
if(NULL==*spP) return MC_DRV_ERR_NO_FREE_MEMORY;
return mcRegistryReadSp(spid, *spP, containerSize);
}
int regGetSpState(mcSpid_t spid, mcContainerState_t* stateP)
{
- int ret;
SPCONTAINERP spP=NULL;
uint32_t containerSize=0;
containerSize = CONTAINER_BUFFER_SIZE; // this will be updated to actual size with the registry call
- ret=regReadSp(spid, &spP, &containerSize);
+ int ret=regReadSp(spid, &spP, &containerSize);
if(MC_DRV_OK==ret)
{
*stateP=spP->cont.attribs.state;
int regReadTlt(const mcUuid_t* uuidP, TLTCONTAINERP* tltP, uint32_t* containerSize, mcSpid_t spid)
{
*containerSize = CONTAINER_BUFFER_SIZE; // this will be update to actual size with the registry call
- *tltP=(TLTCONTAINERP)malloc(CONTAINER_BUFFER_SIZE);
+ *tltP=malloc(CONTAINER_BUFFER_SIZE);
if(NULL==*tltP) return MC_DRV_ERR_NO_FREE_MEMORY;
return mcRegistryReadTrustletCon(uuidP, spid, *tltP, containerSize);
}
{
return mcRegistryCleanupTrustlet(uuidP, spid);
}
-
-int regStoreTA(mcSpid_t spid, const mcUuid_t* uuidP, const uint8_t* taBinary, uint32_t taBinLength)
-{
- (void) uuidP;
-#ifdef WIN32
- return MC_DRV_ERR_INVALID_OPERATION; // TODO-fix Currently the Windows version of mcRegistry does not support mcRegistryStoreTABlob
-#else
- return mcRegistryStoreTABlob(spid, (void*) taBinary, taBinLength);
-#endif
-}
-
-int regGetTaState(mcSpid_t spid, const mcUuid_t* uuidP, mcContainerState_t* stateP)
-{
- TLTCONTAINERP taP=NULL;
- uint32_t containerSize=0;
- containerSize = CONTAINER_BUFFER_SIZE; // this will be updated to actual size with the registry call
- int ret=regReadTlt(uuidP, &taP, &containerSize, spid);
- if(MC_DRV_OK==ret)
- {
- *stateP=taP->cont.common.attribs.state;
- }
- free(taP);
- return ret;
-}
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <mcContainer.h>
int regReadTlt(const mcUuid_t* uuidP, TLTCONTAINERP* tltP, uint32_t* containerSize, mcSpid_t spid);
int regWriteTlt(const mcUuid_t* uuidP, const TLTCONTAINERP tltP, uint32_t containerSize, mcSpid_t spid);
int regCleanupTlt(const mcUuid_t* uuidP, mcSpid_t spid);
-
-int regStoreTA(mcSpid_t spid, const mcUuid_t* uuidP, const uint8_t* taBinary, uint32_t taBinLength);
-int regGetTaState(mcSpid_t spid, const mcUuid_t* uuidP, mcContainerState_t* stateP);
\ No newline at end of file
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <string.h>
#include <stdlib.h>
-#include <wrapper.h>
+#include <stdbool.h>
#include <time.h>
#include <math.h>
-#ifdef TIZEN
-#include <string.h>
-#endif
#include <curl/curl.h>
#define HTTP_CODE_HTTP_VERSION 505
#ifdef __DEBUG
-#define NONEXISTENT_TEST_URL "http://10.255.255.253/"
+#define NONEXISTENT_TEST_URL "http://10.255.255.8:9/"
#endif
#define CERT_PATH_MAX_LEN 256
static char certificatePath_[CERT_PATH_MAX_LEN];
static char certificateFilePath_[CERT_PATH_MAX_LEN];
static long int SE_CONNECTION_DEFAULT_TIMEOUT=58L; // timeout after 58 seconds
-static int MAX_ATTEMPTS=30; //30x0.3 = 9 seconds
-#ifdef WIN32
- static const DWORD SLEEPTIME_MS=300; // 0.3 seconds
-#else
- static const struct timespec SLEEPTIME={0,300*1000*1000}; // 0.3 seconds
-#endif
+static int MAX_ATTEMPTS=30;
+static const struct timespec SLEEPTIME={0,300*1000*1000}; // 0.3 seconds --> 30x0.3 = 9 seconds
rootpaerror_t httpCommunicate(const char* const inputP, const char** linkP, const char** relP, const char** commandP, httpMethod_t method);
-#ifdef WIN32
-
- char* strcasestr(char const *s, char const *find)
- {
- char* pos;
- char* ret;
- char* ls=_strdup(s);
- char* lfind=_strdup(find);
-
- ls=_strlwr(ls);
- lfind=_strlwr(lfind);
- pos = strstr(ls, lfind);
- ret = pos == NULL ? NULL : (char *)(s + (pos-ls));
- free(ls);
- free(lfind);
- return ret;
- }
-
-
-#endif
-
-#ifdef TIZEN
-#include <sys/types.h>
-#include <string.h>
-#include <ctype.h>
-/*
- * Find the first occurrence of find in s, ignore case.
- */
-char *
-strcasestr(s, find)
- const char *s, *find;
-{
- char c, sc;
- size_t len;
-
- if ((c = *find++) != 0) {
- c = tolower((unsigned char)c);
- len = strlen(find);
- do {
- do {
- if ((sc = *s++) == 0)
- return (NULL);
- } while ((char)tolower((unsigned char)sc) != c);
- } while (strncasecmp(s, find, len) != 0);
- s--;
- }
- return ((char *)s);
-}
-
-/*
- * Appends src to string dst of size siz (unlike strncat, siz is the
- * full size of dst, not space left). At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
- * Returns strlen(src) + MIN(siz, strlen(initial dst)).
- * If retval >= siz, truncation occurred.
- */
-size_t
-strlcat(char *dst, const char *src, size_t siz)
-{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
- size_t dlen;
-
- /* Find the end of dst and adjust bytes left but don't go past end */
- while (n-- != 0 && *d != '\0')
- d++;
- dlen = d - dst;
- n = siz - dlen;
-
- if (n == 0)
- return(dlen + strlen(s));
- while (*s != '\0') {
- if (n != 1) {
- *d++ = *s;
- n--;
- }
- s++;
- }
- *d = '\0';
-
- return(dlen + (s - src)); /* count does not include NUL */
-}
-
-/*
- * Copy src to string dst of size siz. At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
- */
-size_t
-strlcpy(char *dst, const char *src, size_t siz)
-{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
-
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
-}
-#endif
-
rootpaerror_t httpPostAndReceiveCommand(const char* const inputP, const char** linkP, const char** relP, const char** commandP)
{
LOGD("httpPostAndReceiveCommand %ld", (long int) inputP);
{
size_t realsize = size * nmemb;
MemoryStruct* mem = (MemoryStruct *)userp;
- mem->memoryP = (char*)realloc(mem->memoryP, mem->size + realsize + 1);
+
+ mem->memoryP = realloc(mem->memoryP, mem->size + realsize + 1);
if (mem->memoryP == NULL) {
/* out of memory! */
LOGE("not enough memory (realloc returned NULL)\n");
{
if(debugMessageP!=NULL && debugMessageSize!=0)
{
- char* msgP=(char*)malloc(debugMessageSize+1);
- if(NULL==msgP)return 0;
+ char* msgP=malloc(debugMessageSize+1);
memcpy(msgP, debugMessageP, debugMessageSize);
msgP[debugMessageSize]=0;
LOGD("curl: %d %s",info, msgP);
bool copyHeader(void *contents, size_t length, char** headerP)
{
- *headerP = (char *)malloc(length + 1);
+ *headerP = malloc(length + 1);
if (*headerP == NULL) {
/* out of memory! */
LOGE("not enough memory (malloc returned NULL)\n");
if (certPathP!=NULL && (strlen(certPathP)+1)<CERT_PATH_MAX_LEN)
{
-#ifdef TIZEN
- strlcpy(certificatePath_, certPathP, sizeof(certificatePath_));
-#else
-/* Fix coverity */
-// strncpy(certificatePath_, certPathP, sizeof(certificatePath_));
- strncpy(certificatePath_, certPathP, sizeof(certificatePath_)-1);
-#endif
+ strcpy(certificatePath_, certPathP);
}
if (localPathP!=NULL && (strlen(localPathP)+1+sizeof(CECERT_FILENAME))<CERT_PATH_MAX_LEN)
{
-#ifdef TIZEN
- strlcpy(certificateFilePath_, localPathP,sizeof(certificateFilePath_));
- strlcat(certificateFilePath_, "/",sizeof(certificateFilePath_));
-#else
-/* Fix coverity */
-// strncpy(certificateFilePath_, localPathP,sizeof(certificateFilePath_));
-// strncat(certificateFilePath_, "/",sizeof(certificateFilePath_));
- strncpy(certificateFilePath_, localPathP,sizeof(certificateFilePath_)-1);
- strncat(certificateFilePath_, "/",strlen("/"));
-#endif
+ strcpy(certificateFilePath_, localPathP);
+ strcat(certificateFilePath_, "/");
}
-#ifdef TIZEN
- strlcat(certificateFilePath_, CECERT_FILENAME,sizeof(certificateFilePath_));
-#else
-// strncat(certificateFilePath_, CECERT_FILENAME,sizeof(certificateFilePath_));
- strncat(certificateFilePath_, CECERT_FILENAME,strlen(CECERT_FILENAME));
-#endif
+ strcat(certificateFilePath_, CECERT_FILENAME);
}
//
// TODO-refactor: saveCertFile is duplicate from saveFile in xmlMessageHandler.c, move these to common place
//
void saveCertFile(char* filePath, char* fileContent)
{
- FILE* fh;
LOGD(">>saveCertFile %s", filePath);
+ FILE* fh;
if ((fh = fopen(filePath, "w")) != NULL) // recreating the file every time, this is not the most efficient way, but ensures
{ // the file is updated in case rootpa and the required content is updated
fprintf(fh, "%s", fileContent);
bool setBasicOpt(CURL* curl_handle, MemoryStruct* chunkP, HeaderStruct* headerChunkP, const char* linkP, struct curl_slist* headerListP)
{
- long int se_connection_timeout=SE_CONNECTION_DEFAULT_TIMEOUT;
-
if(curl_easy_setopt(curl_handle, CURLOPT_URL, linkP)!=CURLE_OK)
{
LOGE("curl_easy_setopt CURLOPT_URL failed");
return false;
}
+ long int se_connection_timeout=SE_CONNECTION_DEFAULT_TIMEOUT;
#ifdef __DEBUG
curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl_handle, CURLOPT_DEBUGFUNCTION, debug_function);
bool setPutOpt(CURL* curl_handle, ResponseStruct* responseChunk)
{
- long chunkSize=responseChunk->size;
LOGD(">>setPutOpt");
if (curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, readResponseCallback)!=CURLE_OK)
{
return false;
}
-
- if (curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE, chunkSize)!=CURLE_OK)
+ long s=responseChunk->size;
+ if (curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE, s)!=CURLE_OK)
{
LOGE("curl_easy_setopt CURLOPT_INFILESIZE_LARGE failed");
return false;
bool setDeleteOpt(CURL* curl_handle, const char* inputP)
{
- (void) inputP;
LOGD(">>setDeleteOpt %s", inputP);
if (curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, "DELETE")!=CURLE_OK)
{
time_t endtime=0;
int timediff=0;
- ResponseStruct responseChunk;
- MemoryStruct chunk;
- HeaderStruct headerChunk;
- headerChunk.linkSize = 0;
- headerChunk.relSize = 0;
- headerChunk.linkP = NULL;
- headerChunk.relP = NULL;
-
LOGD(">>httpCommunicate");
if(NULL==linkP || NULL==relP || NULL==commandP || NULL==*linkP)
{
*commandP=NULL;
*relP=NULL;
+ ResponseStruct responseChunk;
+
+ HeaderStruct headerChunk;
+ headerChunk.linkSize = 0;
+ headerChunk.relSize = 0;
+ headerChunk.linkP = NULL;
+ headerChunk.relP = NULL;
+
+ MemoryStruct chunk;
chunk.size = 0; /* no data at this point */
- chunk.memoryP = (char *)malloc(1); /* will be grown as needed by the realloc above */
+ chunk.memoryP = malloc(1); /* will be grown as needed by the realloc above */
if(NULL==chunk.memoryP)
{
return ROOTPA_ERROR_OUT_OF_MEMORY;
curlRet=curl_easy_perform(curl_handle_);
LOGD("curl_easy_perform %ld %d", curlRet, attempts );
if(CURLE_OK==curlRet) break;
-#ifdef WIN32
- Sleep(SLEEPTIME_MS);
-#else
nanosleep(&SLEEPTIME,NULL);
-#endif
endtime=time(NULL);
timediff=(int)ceil(difftime(endtime, begintime));
LOGD("timediff (ceil) %d", timediff);
LOGD("<<httpCommunicate %d %ld %ld", (int) ret, (long int) http_code, (long int) curlRet);
return ret;
}
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef SECLIENT_H
#define SECLIENT_H
@param linkP note that client has to free the memory from *linkP after using it
@param relP note that client has to free he memory from *relP after using it
@param commandP note that client has to free he memory from *commandP after using it
-
- @return ROOTPA_OK on success. In case of an error *relP and *commandP are set to NULL;
+
+ @return ROOTPA_OK on success. In case of an error *relP and *commandP are set to NULL;
linkP is not change but the original link remains.
*/
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
-#ifndef OWNTOOLS_H
-#define OWNTOOLS_H
+All rights reserved.
-#ifdef WIN32
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
-#include <windows.h>
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
-#define likely(cond) cond
-#define unlikely(cond) cond
-#define bad_read_ptr(_p,_c) IsBadReadPtr((const void *)(_p),(UINT_PTR)(_c))
-#define bad_write_ptr(_p,_c) IsBadWritePtr((void *)(_p),(UINT_PTR)(_c))
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
-#else
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef OWNTOOLS_H
+#define OWNTOOLS_H
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
#define bad_read_ptr(_p,_c) (NULL==(_p))
#define bad_write_ptr(_p,_c) (NULL==(_p))
-#endif
-
#endif // OWNTOOLS_H
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <string.h>
-#ifdef WIN32
- #include <cstring>
- #include <sys/stat.h>
-#endif
-#include <wrapper.h>
#include <stdlib.h>
#include <TlCm/tlCmUuid.h>
#include "tools.h"
static uint32_t tltChannelDeviceId=MC_DEVICE_ID_DEFAULT;
-#ifdef WIN32
-
-#define MAX_TL_FILENAME 1024
-
-/**
-Since Windows version of "mcDaemon" does not access registry, this function is used to load system TA and open session to it.
-*/
-mcResult_t OpenSysTaFromRegistry(
- mcSessionHandle_t * session,
- const mcUuid_t * uuid,
- uint8_t * tci,
- uint32_t tciLen)
- {
-
-
- size_t taSize;
- int result;
- struct stat fstat;
- mcResult_t status = MC_DRV_ERR_UNKNOWN;
- uint8_t * taBlob;
- int lastErr;
-
-
- // get registry path
- // TODO-2013-07-17-jearig01 import registry from global variable
-
- char registryPath[MAX_TL_FILENAME] = "C:\\Windows\\tbaseregistry\\";
- char trustedAppPath[MAX_TL_FILENAME];
- char hx[MAX_TL_FILENAME];
-
- for (size_t i = 0; i < sizeof(*uuid); i++) {
- sprintf(&hx[i * 2], "%02x", ((uint8_t *)uuid)[i]);
- }
-
- snprintf(trustedAppPath, sizeof(trustedAppPath), "%s%s%s", registryPath,hx, ".tlbin");
-
- printf("app path--> %s\n",trustedAppPath);
- printf("registryPath path--> %s\n",registryPath);
- printf("hx--> %s\n",hx);
-
- //check file
- result = stat(trustedAppPath, &fstat);
- if (result!=0) return MC_DRV_ERR_TRUSTLET_NOT_FOUND;
- taSize = fstat.st_size;
-
- // import file in a blob
- FILE *infile = fopen(trustedAppPath, "rb");
-
- if (infile == NULL) return MC_DRV_ERR_TRUSTLET_NOT_FOUND;
-
- taBlob = (uint8_t *) malloc(taSize);
- if (taBlob == NULL)
- {
- fclose(infile);
- return MC_DRV_ERR_NO_FREE_MEMORY;
- }
-
- result = fread (taBlob, 1, taSize, infile);
-
- printf("FREAD--> %d - %d\n",result, taSize);
- if (result == taSize)
- {
- // Call OpenTrustlet
- printf("app path--> %d - %d\n",tciLen, taSize);
- status = mcOpenTrustlet(session, 0, taBlob, taSize, tci, tciLen);
- }
-
- // free blobs, necessary data are supposed to have been sent to SWd and are now useless in NWd
- fclose(infile);
- free(taBlob);
-
- return status;
- }
-#endif
-
/*
Open session to content management trustlet and allocate enough memory for communication
*/
-CMTHANDLE tltChannelOpen(int sizeOfWsmBuffer, mcResult_t* result)
-{
+CMTHANDLE tltChannelOpen(int sizeOfWsmBuffer, mcResult_t* result){
+ CMTHANDLE handle = (CMTHANDLE)malloc(sizeof(CMTSTRUCT));
const mcUuid_t UUID = TL_CM_UUID;
- return taChannelOpen(sizeOfWsmBuffer, result, &UUID, NULL, 0,0);
-}
-
-/*
-*/
-CMTHANDLE taChannelOpen(int sizeOfWsmBuffer, mcResult_t* result, const mcUuid_t* uuidP, uint8_t* taBinaryP, uint32_t taLength, mcSpid_t spid)
-{
- CMTHANDLE handle = (CMTHANDLE)malloc(sizeof(CMTSTRUCT));
if (unlikely( NULL==handle ))
{
memset(handle,0,sizeof(CMTSTRUCT));
+#if ! ( defined(LINUX) || (defined(WIN32) && defined(_TEST_SUITE)) )
+
*result = mcOpenDevice(tltChannelDeviceId);
if (MC_DRV_OK != *result)
{
- LOGE("taChannelOpen: Unable to open device, error: %d", *result);
+ LOGE("tltChannelOpen: Unable to open device, error: %d", *result);
free(handle);
return NULL;
}
+#endif
*result = mcMallocWsm(tltChannelDeviceId, 0, sizeOfWsmBuffer, &handle->wsmP, 0);
if (MC_DRV_OK != *result)
{
- LOGE("taChannelOpen: Allocation of CMP WSM failed, error: %d", *result);
+ LOGE("tltChannelOpen: Allocation of CMP WSM failed, error: %d", *result);
mcCloseDevice(tltChannelDeviceId);
free(handle);
return NULL;
}
- if(taBinaryP!=NULL && taLength!=0)
- {
- *result = mcOpenTrustlet(&handle->session, spid, taBinaryP, taLength, handle->wsmP,(uint32_t)sizeOfWsmBuffer);
- }
- else
- {
-#ifdef WIN32
- *result = OpenSysTaFromRegistry(&handle->session,uuidP,handle->wsmP,(uint32_t)sizeOfWsmBuffer);
-#else
- *result = mcOpenSession(&handle->session,uuidP, handle->wsmP,(uint32_t)sizeOfWsmBuffer);
-#endif
- }
-
+ *result = mcOpenSession(&handle->session,(const mcUuid_t *)&UUID,handle->wsmP,(uint32_t)sizeOfWsmBuffer);
if (MC_DRV_OK != *result)
{
- LOGE("taChannelOpen: Open session failed, error: %d", *result);
+ LOGE("tltChannelOpen: Open session failed, error: %d", *result);
mcFreeWsm(tltChannelDeviceId,handle->wsmP);
mcCloseDevice(tltChannelDeviceId);
free(handle);
return handle;
}
-
/*
Close the communication channel and free resources
*/
if (NULL!=handle->wsmP) mcFreeWsm(tltChannelDeviceId, handle->wsmP);
+#if ! ( defined(LINUX) || (defined(WIN32) && defined(_TEST_SUITE)) )
result = mcCloseDevice(tltChannelDeviceId);
if (MC_DRV_OK != result)
{
LOGE("tltChannelClose: Closing MobiCore device failed, error: %d", result);
}
+#endif
free(handle);
}
}
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef TRUSTLETCHANNEL_H
#define TRUSTLETCHANNEL_H
-#include<wrapper.h>
-
+#include<stdbool.h>
#include<MobiCoreDriverApi.h>
typedef struct cmtstruct CMTSTRUCT;
*/
CMTHANDLE tltChannelOpen(int sizeOfWsmBuffer, mcResult_t* result);
-/**
-Open session to TA and allocate enough memory for communication. There are two way to do this, give TA uuid or TA binary, binary length and spid.
-The former works with system TA's the latter with SP TA's.
-*/
-CMTHANDLE taChannelOpen(int sizeOfWsmBuffer, mcResult_t* result, const mcUuid_t* uuidP, uint8_t* taBinaryP, uint32_t taLength, mcSpid_t spid);
/**
*/
void tltChannelClose(CMTHANDLE handle);
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
-#include <wrapper.h>
+#include <stdbool.h>
#include <stdint.h>
-#ifdef TIZEN
-#include <stdarg.h>
-extern int asprintf (char **result, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 3)));
-extern int vasprintf (char **result, const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 2, 0)));
-#endif
#include <libxml/parser.h>
#include <libxml/valid.h>
#define PLATFORM_TYPES_NS_PREFIX "mcpt"
#define PLATFORM_TYPES_NAMESPACE "http://www.mcore.gi-de.com/2012/02/schema/MCPlatformTypes"
-#define XSD_PATH_MAX_LEN 1024
+#define XSD_PATH_MAX_LEN 256
#define INT_BUFFER_LENGTH 11
#define UNKNOWN_ID 0xFFFFFFFF
static char platformTypesFullPath_[XSD_PATH_MAX_LEN];
static xmlNsPtr nameSpace_=NULL;
static xmlNsPtr typesNameSpace_=NULL;
+
// file internal functions
xmlDocPtr createXmlResponse()
bool addTrustletData(xmlNodePtr rootNode, bool tltBin, char* contentP)
{
- char* element;
xmlNodePtr trustletDataNode=xmlNewChild(rootNode, nameSpace_, BAD_CAST "trustletData", NULL);
if(NULL==trustletDataNode) return false;
- element ="encryptedKey";
+ char* element="encryptedKey";
if(tltBin)
{
element="tltBin";
char* errorCodeToString(rootpaerror_t errorCode)
{
- char* returnErrorCode = STRING_ROOTPA_ERROR_INTERNAL;
-
switch(errorCode)
{
case ROOTPA_COMMAND_NOT_SUPPORTED:
- returnErrorCode = STRING_ROOTPA_COMMAND_NOT_SUPPORTED;
- break;
+ return STRING_ROOTPA_COMMAND_NOT_SUPPORTED;
case ROOTPA_ERROR_LOCK:
- returnErrorCode = STRING_ROOTPA_ERROR_LOCK;
- break;
+ return STRING_ROOTPA_ERROR_LOCK;
//
// this is not currently understood by SE
//
// case ROOTPA_ERROR_COMMAND_EXECUTION:
-// returnErrorCode = STRING_ROOTPA_ERROR_COMMAND_EXECUTION;
-// break;
+// return STRING_ROOTPA_ERROR_COMMAND_EXECUTION;
case ROOTPA_ERROR_REGISTRY:
- returnErrorCode = STRING_ROOTPA_ERROR_REGISTRY;
- break;
+ return STRING_ROOTPA_ERROR_REGISTRY;
case ROOTPA_ERROR_MOBICORE_CONNECTION:
- returnErrorCode = STRING_ROOTPA_ERROR_MOBICORE_CONNECTION;
- break;
+ return STRING_ROOTPA_ERROR_MOBICORE_CONNECTION;
case ROOTPA_ERROR_OUT_OF_MEMORY:
- returnErrorCode = STRING_ROOTPA_ERROR_OUT_OF_MEMORY;
- break;
+ return STRING_ROOTPA_ERROR_OUT_OF_MEMORY;
case ROOTPA_ERROR_INTERNAL:
- returnErrorCode = STRING_ROOTPA_ERROR_INTERNAL;
- break;
+ return STRING_ROOTPA_ERROR_INTERNAL;
case ROOTPA_ERROR_XML:
- returnErrorCode = STRING_ROOTPA_ERROR_XML;
- break;
+ return STRING_ROOTPA_ERROR_XML;
case ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE:
- returnErrorCode = STRING_ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE;
- break;
+ return STRING_ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE;
+
}
LOGD("errorCodeToString: unknown error code %d", errorCode);
-
- return returnErrorCode;
+ return STRING_ROOTPA_ERROR_INTERNAL;
}
bool addCommandResultData(xmlNodePtr resultListNode, int id, char* commandResultP, rootpaerror_t errorCode, uint32_t errorDetail )
{
- bool retValue;
- char intBuffer[INT_BUFFER_LENGTH];
-
xmlNodePtr commandResultNode=xmlNewChild(resultListNode, nameSpace_, BAD_CAST "commandResult", NULL);
if(NULL==commandResultNode) return false;
- retValue=true;
+ bool retValue=true;
+ char intBuffer[INT_BUFFER_LENGTH];
+
snprintf(intBuffer,INT_BUFFER_LENGTH,"%u",(uint32_t) id);
if(xmlNewProp(commandResultNode, BAD_CAST "id", BAD_CAST intBuffer)==NULL) return false;
xmlNodePtr findFirstCommandNode(xmlDocPtr xmlDocP)
{
- xmlNodePtr commandsNodeP;
- xmlNodePtr rootElementP;
-
- rootElementP = xmlDocGetRootElement(xmlDocP);
+ xmlNodePtr rootElementP = xmlDocGetRootElement(xmlDocP);
if(NULL==rootElementP) return NULL;
- commandsNodeP=rootElementP->children;
+ xmlNodePtr commandsNodeP=rootElementP->children;
for (; commandsNodeP; commandsNodeP = commandsNodeP->next)
{
if (commandsNodeP->type == XML_ELEMENT_NODE && strcmp((char*)commandsNodeP->name, "commands")==0)
xmlNodePtr getNextCommand(xmlDocPtr xmlDocP, xmlNodePtr prevNode)
{
- xmlNodePtr firstNode;
- xmlNodePtr commandNode;
LOGD(">> getNextCommand %ld %ld", (long int) xmlDocP, (long int) prevNode);
+ xmlNodePtr firstNode;
if(NULL==prevNode)
{
firstNode=findFirstCommandNode(xmlDocP);
firstNode=prevNode->next;
}
+ xmlNodePtr commandNode;
for (commandNode = firstNode; commandNode; commandNode = commandNode->next)
{
if (commandNode->type == XML_ELEMENT_NODE && strcmp((char*)commandNode->name, "command")==0)
int getCommandId(xmlNodePtr commandNode)
{
- int id;
- xmlChar* idP;
- idP=xmlGetProp(commandNode, BAD_CAST "id");
+ xmlChar* idP=xmlGetProp(commandNode, BAD_CAST "id");
if(NULL==idP)
{
return UNKNOWN_ID;
}
- id=atoi((char*)idP);
+ int id=atoi((char*)idP);
xmlFree(idP);
return id;
}
commandtype_t getCommandType(xmlNodePtr commandNode)
{
- xmlChar* typeP;
- commandtype_t type;
if(NULL==commandNode) return UNKNOWN_TYPE;
- typeP=xmlGetProp(commandNode, BAD_CAST "type");
- type=UNKNOWN_TYPE;
+ xmlChar* typeP=xmlGetProp(commandNode, BAD_CAST "type");
+ commandtype_t type=UNKNOWN_TYPE;
if(typeP!=NULL)
{
if(strcmp((char*)typeP,"CMP")==0) type=CMP;
uint32_t extractCmpCommand(CmpMessage** cmpCommandsP, uint32_t numberOfCmpCommands, uint32_t id, char* commandValueP, bool ignoreError)
{
CmpMessage* localCommandsP=*cmpCommandsP; // localCommandsP is just to make the code a bit more readable
- CmpMessage* tmpCommandsP=(CmpMessage*)realloc(localCommandsP, sizeof(CmpMessage)*(numberOfCmpCommands+1));
+ CmpMessage* tmpCommandsP=realloc(localCommandsP, sizeof(CmpMessage)*(numberOfCmpCommands+1));
if(tmpCommandsP!=NULL)
{
rootpaerror_t handleCmpResponses(uint32_t maxNumberOfCmpResponses, CmpMessage* cmpResponsesP, xmlNodePtr rspResultElementP)
{
+ LOGD(">>handleCmpResponses %d", maxNumberOfCmpResponses);
rootpaerror_t ret=ROOTPA_OK;
uint32_t i;
- LOGD(">>handleCmpResponses %d", maxNumberOfCmpResponses);
-
- if(cmpResponsesP == NULL)
+ if(cmpResponsesP == NULL)
{
if(maxNumberOfCmpResponses>0)
{
char* commandValueP,
bool ignoreError)
{
- uint8_t* containerDataP = NULL;
- int containerLength;
- CommonMessage* localCommandsP=*uploadCommandsP; // localCommandsP is just to make the code a bit more readable
- CommonMessage* tmpCommandsP=(CommonMessage*)realloc(localCommandsP, sizeof(CommonMessage)*(numberOfUploadCommands+1));
LOGD(">>handleUploadCommand %d %lx %lx", commandType, (long int) uploadCommandsP, (long int) *uploadCommandsP);
+ CommonMessage* localCommandsP=*uploadCommandsP; // localCommandsP is just to make the code a bit more readable
+ CommonMessage* tmpCommandsP=realloc(localCommandsP, sizeof(CommonMessage)*(numberOfUploadCommands+1));
+
if(NULL == tmpCommandsP)
{
LOGE("handleUploadCommand: was not able to realloc, returning %d", ignoreError);
}
localCommandsP[numberOfUploadCommands].ret=ROOTPA_OK;
-
- containerLength= base64DecodeStringRemoveEndZero(commandValueP, (char**) &(containerDataP));
+ uint8_t* containerDataP = NULL;
+ int containerLength= base64DecodeStringRemoveEndZero(commandValueP, (char**) &(containerDataP));
if(0 == containerLength)
{
rootpaerror_t handleUploadResponses(uint32_t numberOfUploadResponses, CommonMessage* uploadResponsesP, xmlNodePtr rspResultElementP)
{
+ LOGD(">>handleUploadResponses %d", numberOfUploadResponses);
rootpaerror_t ret=ROOTPA_OK;
char zero=0;
uint32_t i;
- LOGD(">>handleUploadResponses %d", numberOfUploadResponses);
-
- if(uploadResponsesP == NULL)
+ if(uploadResponsesP == NULL)
{
if(numberOfUploadResponses>0)
{
rootpaerror_t handleCommandAndFillResponse(xmlDocPtr xmlCommandP, xmlDocPtr xmlResponseP)
{
+ LOGD(">>handleCommandAndFillResponse");
rootpaerror_t ret=ROOTPA_OK;
rootpaerror_t tmpRet=ROOTPA_OK;
- xmlNodePtr rspRootElementP;
+
+ xmlNodePtr rspRootElementP = xmlDocGetRootElement(xmlResponseP);
+ if(NULL==rspRootElementP) return ROOTPA_ERROR_XML;
CmpMessage* cmpCommandsP=NULL;
CommonMessage* uploadCommandsP=NULL;
commandtype_t commandType=UNKNOWN_TYPE;
uint32_t id=0;
char* commandValueP=NULL;
- CmpMessage* cmpResponsesP=NULL;
bool ignoreError=0;
xmlNodePtr commandNode=NULL;
- int i;
-
- LOGD(">>handleCommandAndFillResponse");
-
- rspRootElementP = xmlDocGetRootElement(xmlResponseP);
- if(NULL==rspRootElementP) return ROOTPA_ERROR_XML;
// parse command data out of xml, upload commands will also be executed
}
// execute the actual content management protocol commands, if there are any
+
+ CmpMessage* cmpResponsesP=NULL;
if(cmpCommandsP)
{
uint32_t internalError;
- cmpResponsesP=(CmpMessage *)malloc(sizeof(CmpMessage)*numberOfCmpCommands);
+ cmpResponsesP=malloc(sizeof(CmpMessage)*numberOfCmpCommands);
+ memset(cmpResponsesP, 0, sizeof(CmpMessage)*numberOfCmpCommands);
if(NULL==cmpResponsesP)
{
}
else
{
- memset(cmpResponsesP, 0, sizeof(CmpMessage)*numberOfCmpCommands);
tmpRet=executeContentManagementCommands(numberOfCmpCommands, cmpCommandsP, cmpResponsesP, &internalError);
if(ROOTPA_OK!=tmpRet)
{
}
// cleanup what has not yet been cleaned
+ int i;
for(i=0; i<numberOfCmpCommands; i++)
{
if(cmpCommandsP) free(cmpCommandsP[i].contentP);
void handleError(void* ctx, const char *format, ...)
{
- (void) ctx;
-#ifdef WIN32
- #define ERROR_LOG_LENGTH 256
- char errMsg[ERROR_LOG_LENGTH];
-
- va_list args;
- va_start(args, format);
- vsnprintf(errMsg, ERROR_LOG_LENGTH, format, args);
- va_end(args);
-
- LOGW("From libxml2: %s", errMsg);
-#else
char *errMsg;
-
- va_list args;
+ va_list args;
va_start(args, format);
vasprintf(&errMsg, format, args);
va_end(args);
-
- LOGW("From libxml2: %s", errMsg);
+ LOGW("From libxml2: %s", errMsg);
free(errMsg);
-#endif
}
/*
void saveFile(char* filePath, char* fileContent)
{
-
- FILE* fh;
LOGD(">>saveFile %s", filePath);
+ FILE* fh;
+
if ((fh = fopen(filePath, "w")) != NULL)
{
fprintf(fh, "%s", fileContent);
bool validXmlMessage(xmlDocPtr xmlDocP)
{
+ LOGD(">>validXmlMessage %s", enrollmentServiceFullPath_);
int result=-2;
xmlSchemaParserCtxtPtr parserCtxtP = NULL;
xmlSchemaPtr schemaP = NULL;
xmlSchemaValidCtxtPtr validCtxtP = NULL;
- LOGD(">>validXmlMessage %s", enrollmentServiceFullPath_);
+
// Here we store the schemas if they are not already on "disk". It seems
// xmlSchemaNewParserCtxt succeeds even if the file does not exists and it is
// xmlSchemaParse that requires the file to exists. That is why the files are
LOGD("<<validXmlMessage");
return true;
#endif // LIBXML_SCHEMAS_ENABLED
+
}
uint8_t* validateDumpAndFree(xmlDocPtr xmlResponseP)
{
uint8_t* dumpedP=NULL;
- int size=0;
- xmlChar* dumpP;
if(!validXmlMessage(xmlResponseP))
{
LOGE("validateDumpAndFree, invalid response");
}
-
- xmlDocDumpMemoryEnc(xmlResponseP, &dumpP, &size, "UTF-8");
+ int size=0;
+ xmlChar* dumpP;
+// xmlDocDumpMemory(xmlResponseP, &dumpP, &size);
+ xmlDocDumpMemoryEnc(xmlResponseP, &dumpP, &size, "UTF-8");
if(dumpP!=NULL)
{
// doing this copy only because libxml2 documentation tells to
// compatible with free but since I have not verified it, this is to
// be on the safe side
- dumpedP=(uint8_t*)malloc(size+1);
- if(dumpedP!=NULL)
- {
- strncpy((char*) dumpedP, (char*) dumpP, size+1);
- }
+ dumpedP=malloc(size+1);
+ strncpy((char*) dumpedP, (char*) dumpP, size+1);
xmlFree(dumpP);
}
xmlFreeDoc(xmlResponseP);
*/
rootpaerror_t handleXmlMessage(const char* messageP, const char** responseP)
{
-
+ LOGD(">>handleXmlMessage");
rootpaerror_t ret=ROOTPA_OK;
rootpaerror_t tmpRet=ROOTPA_OK;
- xmlDocPtr xmlDocP;
- xmlDocPtr xmlResponseP;
-
*responseP=NULL;
- LOGD(">>handleXmlMessage");
if (NULL==messageP)
{
xmlThrDefSetStructuredErrorFunc(NULL, NULL);
xmlThrDefSetGenericErrorFunc(NULL, handleError);
- xmlDocP= xmlParseMemory(messageP, strlen(messageP));
+ xmlDocPtr xmlDocP= xmlParseMemory(messageP, strlen(messageP));
if(NULL==xmlDocP)
{
LOGE("handleXmlMessage, can not parse xmlMessageP %s", messageP);
// attempting to parse the message anyway.
}
- xmlResponseP=createXmlResponse();
+ xmlDocPtr xmlResponseP=createXmlResponse();
// parse received command
rootpaerror_t fillMcVersion(xmlNodePtr mcVersionNode, int mcVersionTag, const mcVersionInfo_t* mcVersionP)
{
- (void) mcVersionTag;
- char intBuffer[INT_BUFFER_LENGTH];
LOGD(">>fillMcVersion");
+ char intBuffer[INT_BUFFER_LENGTH];
+
xmlSetStructuredErrorFunc(NULL, NULL);
xmlSetGenericErrorFunc(NULL, handleError);
xmlThrDefSetStructuredErrorFunc(NULL, NULL);
rootpaerror_t buildXmlTrustletInstallationRequest(const char** responseP, trustletInstallationData_t data )
{
char intBuffer[INT_BUFFER_LENGTH];
- rootpaerror_t ret=ROOTPA_OK;
- xmlDocPtr xmlResponseDocP;
- xmlNodePtr rspRootElementP;
- xmlNodePtr systemInfoNode;
- xmlNodePtr mcDataNode=NULL;
- char* encodedDataP;
- char* pukHashStringP;
LOGD(">>buildXmlTrustletInstallationRequest %ld (%ld %d %d)", (long int) responseP, (long int) data.dataP, data.dataLength, data.dataType);
+ rootpaerror_t ret=ROOTPA_OK;
if(NULL == responseP) return ROOTPA_ERROR_ILLEGAL_ARGUMENT; // data content checked earlier in commandhandler.c
- xmlResponseDocP=createXmlResponse();
- rspRootElementP = xmlDocGetRootElement(xmlResponseDocP);
+ xmlDocPtr xmlResponseDocP=createXmlResponse();
+ xmlNodePtr rspRootElementP = xmlDocGetRootElement(xmlResponseDocP);
if(NULL==rspRootElementP) return ROOTPA_ERROR_XML;
- systemInfoNode=xmlNewChild(rspRootElementP, nameSpace_, BAD_CAST "tltInstallationRequest", NULL);
+ xmlNodePtr systemInfoNode=xmlNewChild(rspRootElementP, nameSpace_, BAD_CAST "tltInstallationRequest", NULL);
if(NULL==systemInfoNode) return ROOTPA_ERROR_XML;
- encodedDataP=base64EncodeAddEndZero((char*) data.dataP, data.dataLength);
+ xmlNodePtr mcDataNode=NULL;
+ char* encodedDataP=base64EncodeAddEndZero((char*) data.dataP, data.dataLength);
if(NULL==encodedDataP)
{
LOGE("buildXmlTrustletInstallationRequest: base64 encoding of data failed");
return ROOTPA_ERROR_XML;
}
- pukHashStringP=base64EncodeAddEndZero((char*) data.tltPukHashP, data.tltPukHashLength);
+ char* pukHashStringP=base64EncodeAddEndZero((char*) data.tltPukHashP, data.tltPukHashLength);
if(NULL==pukHashStringP)
{
LOGE("buildXmlTrustletInstallationRequest: base64 encoding of PukHash failed");
*/
rootpaerror_t buildXmlSystemInfo(const char** responseP, int mcVersionTag, const mcVersionInfo_t* mcVersionP, const osInfo_t* osSpecificInfoP)
{
-
+ LOGD(">>buildXmlSystemInfo %ld %ld %ld", ( long int ) responseP, ( long int ) mcVersionP, ( long int ) osSpecificInfoP);
rootpaerror_t ret=ROOTPA_OK;
- xmlDocPtr xmlResponseDocP;
- xmlNodePtr rspRootElementP;
- xmlNodePtr systemInfoNode;
- xmlNodePtr mcVersionNode;
if(NULL == responseP || NULL == mcVersionP || NULL == osSpecificInfoP) return ROOTPA_ERROR_INTERNAL;
- LOGD(">>buildXmlSystemInfo %ld %ld %ld", ( long int ) responseP, ( long int ) mcVersionP, ( long int ) osSpecificInfoP);
xmlSetStructuredErrorFunc(NULL, NULL);
xmlSetGenericErrorFunc(NULL, handleError);
xmlThrDefSetStructuredErrorFunc(NULL, NULL);
xmlThrDefSetGenericErrorFunc(NULL, handleError);
- xmlResponseDocP=createXmlResponse();
- rspRootElementP= xmlDocGetRootElement(xmlResponseDocP);
+ xmlDocPtr xmlResponseDocP=createXmlResponse();
+ xmlNodePtr rspRootElementP = xmlDocGetRootElement(xmlResponseDocP);
if(NULL==rspRootElementP) return ROOTPA_ERROR_XML;
- systemInfoNode=xmlNewChild(rspRootElementP, nameSpace_, BAD_CAST "systemInformation", NULL);
+ xmlNodePtr systemInfoNode=xmlNewChild(rspRootElementP, nameSpace_, BAD_CAST "systemInformation", NULL);
if(NULL==systemInfoNode) return ROOTPA_ERROR_XML;
- mcVersionNode=xmlNewChild(systemInfoNode, typesNameSpace_, BAD_CAST "mcVersion", NULL);
+ xmlNodePtr mcVersionNode=xmlNewChild(systemInfoNode, typesNameSpace_, BAD_CAST "mcVersion", NULL);
if(NULL==mcVersionNode) return ROOTPA_ERROR_XML;
ret=fillSystemInfo(systemInfoNode, osSpecificInfoP);
if (xsdpathP!=NULL && strlen(xsdpathP)+1+sizeof(ENROLLMENT_SERVICE_XSD_NAME)<XSD_PATH_MAX_LEN) // ENROLLMENT_SERVICE_XSD_NAME is the longer of the two
{
-/* Fix coverity */
-// strncpy(enrollmentServiceFullPath_, xsdpathP, XSD_PATH_MAX_LEN);
-// strncpy(platformTypesFullPath_, xsdpathP, XSD_PATH_MAX_LEN);
- strncpy(enrollmentServiceFullPath_, xsdpathP, XSD_PATH_MAX_LEN-1);
- strncpy(platformTypesFullPath_, xsdpathP, XSD_PATH_MAX_LEN-1);
+ strncpy(enrollmentServiceFullPath_, xsdpathP, XSD_PATH_MAX_LEN);
+ strncpy(platformTypesFullPath_, xsdpathP, XSD_PATH_MAX_LEN);
strncat(enrollmentServiceFullPath_, "/", XSD_PATH_MAX_LEN-strlen(xsdpathP));
strncat(platformTypesFullPath_, "/", XSD_PATH_MAX_LEN-strlen(xsdpathP));
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+Copyright © Trustonic Limited 2013
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Trustonic Limited nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef XMLMESSAGEHANDLER_H
#define XMLMESSAGEHANDLER_H
/**
@param xmlMessageP received xml message to be handled
- @param xmlResponseP response to the received message in xml format. The caller is
+ @param xmlResponseP response to the received message in xml format. The caller is
responsible on freeing the memory the pointer points to.
- @return ROOTPA_OK on success, ROOTPA_ERROR_ILLEGAL_ARGUMENT if
+ @return ROOTPA_OK on success, ROOTPA_ERROR_ILLEGAL_ARGUMENT if
xmlMessageP is NULL or if the message is not valid xml
- If error is returned, the error is also included in xmlResponse
- (unless there is problem in allocating memory) and the response
+ If error is returned, the error is also included in xmlResponse
+ (unless there is problem in allocating memory) and the response
should still be returned to SE.
-
+
*/
rootpaerror_t handleXmlMessage(const char* xmlMessageP, const char** xmlResponseP);
/**
From the given system info creates a xml string that can be returned to SE.
-@param responseP pointer to a char pointer where the response to the received message in xml
+@param responseP pointer to a char pointer where the response to the received message in xml
format is to be copied. The caller is responsible on freeing the memory the pointer points to.
@param mcVersionTag version of Mobicore version info
@param mcVersionP pointer to the mobicore version struct
@param osSpecificInfoP pointer to struct containing operating system specific information
-@return ROOTPA_OK on success, ROOTPA_ERROR_INTERNAL if
+@return ROOTPA_OK on success, ROOTPA_ERROR_INTERNAL if
xmlMessageP is NULL or if the message is not valid xml
- If error is returned, the error is also included in xmlResponse
- (unless there is problem in allocating memory) and the response
+ If error is returned, the error is also included in xmlResponse
+ (unless there is problem in allocating memory) and the response
should still be returned to SE.
-
+
*/
rootpaerror_t buildXmlSystemInfo(const char** responseP, int mcVersionTag, const mcVersionInfo_t* mcVersionP, const osInfo_t* osSpecificInfoP);
/**
Builds request for trustlet installation
-@param responseP pointer to a char pointer where the response to the received message in xml
+@param responseP pointer to a char pointer where the response to the received message in xml
format is to be copied. The caller is responsible on freeing the memory the pointer points to.
@param data, information needed for trustlet installation
-@return ROOTPA_OK on success, ROOTPA_ERROR_ILLEGAL_ARGUMENT if data.dataP is NULL, responseP is NULL or if data.dataType
+@return ROOTPA_OK on success, ROOTPA_ERROR_ILLEGAL_ARGUMENT if data.dataP is NULL, responseP is NULL or if data.dataType
has something else than the values in the type.
-
+
*/
rootpaerror_t buildXmlTrustletInstallationRequest(const char** responseP, trustletInstallationData_t data );
+++ /dev/null
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := MobiCoreTlcm
-LOCAL_MODULE_TAGS := eng
-
-LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDES)
-
-include $(BUILD_STATIC_LIBRARY)
+++ /dev/null
-/*
- * Copyright (c) 2013-2014 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup CMP_2_0
- * Content Management Protocol 2.0 Definitions.
- *
- * The content management protocol (CMP) is based on the trustlet control
- * interface (TCI) and defines commands/responses with the content management
- * trustlet (TlCm).
- *
- * @{
- *
- * @file
- * CMP 2.0 global definitions.
- * Various components need access to (sub-)structures defined and used by CMP
- * 2.0. These common definitions are made available through this header file.
- */
-
-#ifndef CMP_H_
-#define CMP_H_
-
-#include "TlCm/cmpCommon.h"
-
-/** Key size of encryption algorithm used for secure messaging. */
-#define CMP_MSG_KEY_SIZE 32
-
-/** @defgroup MC_CMP_2_0_CMD_BEGIN_SOC_AUTHENTICATION \
- MC_CMP_2_0_CMD_BEGIN_SOC_AUTHENTICATION
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_BEGIN_SOC_AUTHENTICATION_CMD Command_2_0
- * @{ */
-
-/** BeginSocAuthentication non signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
-} cmpBeginSocAuthenticationCmd_t;
-
-/** BeginSocAuthentication command. */
-typedef struct {
- /** Command. */
- cmpBeginSocAuthenticationCmd_t cmd;
- /** AuthToken container secure object. */
- mcSoAuthTokenCont_t soAuthTokenCont;
-} cmpCmdBeginSocAuthentication_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_BEGIN_SOC_AUTHENTICATION_RSP Response_2_0
- * @{ */
-
-/** BeginSocAuthentication signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Suid. */
- mcSuid_t suid;
- /** SWd authentication random number. */
- cmpRnd8_t rnd1;
-} cmpBeginSocAuthenticationRspSdata_t;
-
-/** BeginSocAuthentication signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpBeginSocAuthenticationRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpBeginSocAuthenticationRsp_t;
-
-/** BeginSocAuthentication response. */
-typedef struct {
- /** Response. */
- cmpBeginSocAuthenticationRsp_t rsp;
-} cmpRspBeginSocAuthentication_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_BEGIN_ROOT_AUTHENTICATION \
- MC_CMP_2_0_CMD_BEGIN_ROOT_AUTHENTICATION
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_BEGIN_ROOT_AUTHENTICATION_CMD Command_2_0
- * @{ */
-
-/** BeginRootAuthentication non signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
-} cmpBeginRootAuthenticationCmd_t;
-
-/** BeginRootAuthentication command. */
-typedef struct {
- /** Command. */
- cmpBeginRootAuthenticationCmd_t cmd;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpCmdBeginRootAuthentication_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_BEGIN_ROOT_AUTHENTICATION_RSP Response_2_0
- * @{ */
-
-/** BeginRootAuthentication signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Suid. */
- mcSuid_t suid;
- /** SWd authentication random number. */
- cmpRnd8_t rnd1;
-} cmpBeginRootAuthenticationRspSdata_t;
-
-/** BeginRootAuthentication signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpBeginRootAuthenticationRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpBeginRootAuthenticationRsp_t;
-
-/** BeginRootAuthentication response. */
-typedef struct {
- /** Response. */
- cmpBeginRootAuthenticationRsp_t rsp;
-} cmpRspBeginRootAuthentication_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_BEGIN_SP_AUTHENTICATION \
- MC_CMP_2_0_CMD_BEGIN_SP_AUTHENTICATION
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_BEGIN_SP_AUTHENTICATION_CMD Command_2_0
- * @{ */
-
-/** BeginSpAuthentication non signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpBeginSpAuthenticationCmdSdata_t;
-
-/** BeginSpAuthentication non signed command and no signature. */
-typedef struct {
- /** Non signed command. */
- cmpBeginSpAuthenticationCmdSdata_t sdata;
-} cmpBeginSpAuthenticationCmd_t;
-
-/** BeginSpAuthentication command. */
-typedef struct {
- /** Command. */
- cmpBeginSpAuthenticationCmd_t cmd;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpCmdBeginSpAuthentication_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_BEGIN_SP_AUTHENTICATION_RSP Response_2_0
- * @{ */
-
-/** BeginSpAuthentication signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Suid. */
- mcSuid_t suid;
- /** Spid. */
- mcSpid_t spid;
- /** SWd authentication random number. */
- cmpRnd8_t rnd1;
-} cmpBeginSpAuthenticationRspSdata_t;
-
-/** BeginSpAuthentication signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpBeginSpAuthenticationRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpBeginSpAuthenticationRsp_t;
-
-/** BeginSpAuthentication response. */
-typedef struct {
- /** Response. */
- cmpBeginSpAuthenticationRsp_t rsp;
-} cmpRspBeginSpAuthentication_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE MC_CMP_2_0_CMD_AUTHENTICATE
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_CMD Command_2_0
- * @{ */
-
-/** Authenticate encrypted data command. */
-typedef struct {
- /** Suid. */
- mcSuid_t suid;
- /** EntityId. */
- uint32_t entityId;
- /** NWd authentication random number. */
- cmpRnd8_t rnd2;
- /** SWd authentication random number. */
- cmpRnd8_t rnd1;
- /** NWd authentication random seed. */
- cmpRnd32_t k2;
-} cmpAuthMsgEdata_t;
-
-/** Authenticate encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpAuthMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpAuthMsgEdata_t))];
-} cmpAuthCmdEd_t;
-
-/** Authenticate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Encrypted and padded data. */
- cmpAuthCmdEd_t ed;
-} cmpAuthCmdSdata_t;
-
-/** Authenticate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpAuthCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpAuthenticateCmd_t;
-
-/** Authenticate command. */
-typedef struct {
- /** Command. */
- cmpAuthenticateCmd_t cmd;
-} cmpCmdAuthenticate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_RSP Response_2_0
- * @{ */
-
-/** Authenticate encrypted data response. */
-typedef struct {
- /** Suid. */
- mcSuid_t suid;
- /** EntityId. */
- uint32_t entityId;
- /** SWd authentication random number. */
- cmpRnd8_t rnd1;
- /** NWd authentication random number. */
- cmpRnd8_t rnd2;
- /** SWd authentication random seed. */
- cmpRnd32_t k1;
-} cmpAuthRspEdata_t;
-
-/** Authenticate encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpAuthRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpAuthRspEdata_t))];
-} cmpAuthRspEd_t;
-
-/** Authenticate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpAuthRspEd_t ed;
-} cmpAuthRspSdata_t;
-
-/** Authenticate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpAuthRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpAuthenticateRsp_t;
-
-/** Authenticate response. */
-typedef struct {
- /** Response. */
- cmpAuthenticateRsp_t rsp;
-} cmpRspAuthenticate_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_TERMINATE \
- MC_CMP_2_0_CMD_AUTHENTICATE_TERMINATE
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_TERMINATE_CMD Command_2_0
- * @{ */
-
-/** AuthenticateTerminate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
-} cmpAuthenticateTerminateCmdSdata_t;
-
-/** AuthenticateTerminate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpAuthenticateTerminateCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpAuthenticateTerminateCmd_t;
-
-/** AuthenticateTerminate command. */
-typedef struct {
- /** Command. */
- cmpAuthenticateTerminateCmd_t cmd;
-} cmpCmdAuthenticateTerminate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_TERMINATE_RSP Response_2_0
- * @{ */
-
-/** AuthenticateTerminate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
-} cmpAuthenticateTerminateRspSdata_t;
-
-/** AuthenticateTerminate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpAuthenticateTerminateRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTerminateAutenticateRsp_t;
-
-/** AuthenticateTerminate response. */
-typedef struct {
- /** Response. */
- cmpTerminateAutenticateRsp_t rsp;
-} cmpRspAuthenticateTerminate_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_REGISTER_ACTIVATE \
- MC_CMP_2_0_CMD_ROOT_CONT_REGISTER_ACTIVATE
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_REGISTER_ACTIVATE_CMD Command_2_0
- * @{ */
-
-/** RootContRegisterActivate encrypted data command. */
-typedef struct {
- /** Root authentication key. */
- mcSymmetricKey_t kRootAuth;
-} cmpRootRegActMsgEdata_t;
-
-/** RootContRegisterActivate encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpRootRegActMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootRegActMsgEdata_t))];
-} cmpRootRegActCmdEd_t;
-
-/** RootContRegisterActivate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Rootid. */
- mcRootid_t rootid;
- /** Encrypted and padded data. */
- cmpRootRegActCmdEd_t ed;
-} cmpRootRegActCmdSdata_t;
-
-/** RootContRegisterActivate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpRootRegActCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContRegisterActivateCmd_t;
-
-/** RootContRegisterActivate command. */
-typedef struct {
- /** Command. */
- cmpRootContRegisterActivateCmd_t cmd;
-} cmpCmdRootContRegisterActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_REGISTER_ACTIVATE_RSP Response_2_0
- * @{ */
-
-/** RootContRegisterActivate encrypted data response. */
-typedef struct {
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpRootRegActRspEdata_t;
-
-/** RootContRegisterActivate encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpRootRegActRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootRegActRspEdata_t))];
-} cmpRootRegActRspEd_t;
-
-/** RootContRegisterActivate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpRootRegActRspEd_t ed;
-} cmpRootRegActRspSdata_t;
-
-/** RootContRegisterActivate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpRootRegActRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContRegisterActivateRsp_t;
-
-/** RooContRegisterActivate response. */
-typedef struct {
- /** Response. */
- cmpRootContRegisterActivateRsp_t rsp;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpRspRootContRegisterActivate_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNREGISTER \
- MC_CMP_2_0_CMD_ROOT_CONT_UNREGISTER
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNREGISTER_CMD Command_2_0
- * @{ */
-
-/** RootContUnregister encrypted data command. */
-typedef struct {
- /** Suid. */
- mcSuid_t suid;
- /** AuthToken container secure object. */
- mcSoAuthTokenCont_t soAuthTokenCont;
-} cmpRootUnregMsgEdata_t;
-
-/** RootContUnregister encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpRootUnregMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootUnregMsgEdata_t))];
-} cmpRootUnregCmdEd_t;
-
-/** RootContUnregister signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Encrypted and padded data. */
- cmpRootUnregCmdEd_t ed;
-} cmpRootUnregCmdSdata_t;
-
-/** RootContUnregister signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpRootUnregCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContUnregisterCmd_t;
-
-/** RootContUnregister command. */
-typedef struct {
- /** Command. */
- cmpRootContUnregisterCmd_t cmd;
-} cmpCmdRootContUnregister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNREGISTER_RSP Response_2_0
- * @{ */
-
-/** RootContUnregister encrypted data response. */
-typedef struct {
- /** Suid. */
- mcSuid_t suid;
-} cmpRootUnregRspEdata_t;
-
-/** RootContUnregister encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpRootUnregRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootUnregRspEdata_t))];
-} cmpRootUnregRspEd_t;
-
-/** RootContUnregister signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpRootUnregRspEd_t ed;
-} cmpRootUnregRspSdata_t;
-
-/** RootContUnregister signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpRootUnregRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContUnregisterRsp_t;
-
-/** RootContUnregister response. */
-typedef struct {
- /** Response. */
- cmpRootContUnregisterRsp_t rsp;
- /** AuthToken container secure object. */
- mcSoAuthTokenCont_t soAuthTokenCont;
-} cmpRspRootContUnregister_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_LOCK_BY_ROOT \
- MC_CMP_2_0_CMD_ROOT_CONT_LOCK_BY_ROOT
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_LOCK_BY_ROOT_CMD Command_2_0
- * @{ */
-
-/** RootContLockByRoot signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
-} cmpRootLockByRootCmdSdata_t;
-
-/** RootContLockByRoot signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpRootLockByRootCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContLockByRootCmd_t;
-
-/** RootContLockByRoot command. */
-typedef struct {
- /** Command. */
- cmpRootContLockByRootCmd_t cmd;
-} cmpCmdRootContLockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_LOCK_BY_ROOT_RSP Response_2_0
- * @{ */
-
-/** RootContLockByRoot encrypted data response. */
-typedef struct {
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpRootLockByRootRspEdata_t;
-
-/** RootContLockByRoot encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpRootLockByRootRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootLockByRootRspEdata_t))];
-} cmpRootLockByRootRspEd_t;
-
-/** RootContLockByRoot signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpRootLockByRootRspEd_t ed;
-} cmpRootLockByRootRspSdata_t;
-
-/** RootContLockByRoot signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpRootLockByRootRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContLockByRootRsp_t;
-
-/** RootContLockByRoot response. */
-typedef struct {
- /** Response. */
- cmpRootContLockByRootRsp_t rsp;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpRspRootContLockByRoot_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNLOCK_BY_ROOT \
- MC_CMP_2_0_CMD_ROOT_CONT_UNLOCK_BY_ROOT
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNLOCK_BY_ROOT_CMD Command_2_0
- * @{ */
-
-/** RootContUnlockByRoot signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
-} cmpRootUnlockByRootCmdSdata_t;
-
-/** RootContUnlockByRoot signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpRootUnlockByRootCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContUnlockByRootCmd_t;
-
-/** RootContUnlockByRoot command. */
-typedef struct {
- /** Command. */
- cmpRootContUnlockByRootCmd_t cmd;
-} cmpCmdRootContUnlockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNLOCK_BY_ROOT_RSP Response_2_0
- * @{ */
-
-/** RootContUnlockByRoot encrypted data response. */
-typedef struct {
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpRootUnlockByRootRspEdata_t;
-
-/** RootContUnlockByRoot encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpRootUnlockByRootRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootUnlockByRootRspEdata_t))];
-} cmpRootUnlockByRootRspEd_t;
-
-/** RootContUnlockByRoot signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpRootUnlockByRootRspEd_t ed;
-} cmpRootUnlockByRootRspSdata_t;
-
-/** RootContUnlockByRoot signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpRootUnlockByRootRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContUnlockByRootRsp_t;
-
-/** RootContUnlockByRoot response. */
-typedef struct {
- /** Response. */
- cmpRootContUnlockByRootRsp_t rsp;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpRspRootContUnlockByRoot_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_ACTIVATE \
- MC_CMP_2_0_CMD_SP_CONT_REGISTER_ACTIVATE
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_ACTIVATE_CMD Command_2_0
- * @{ */
-
-/** SpContRegisterActivate encrypted data command. */
-typedef struct {
- /** Sp authentication key. */
- mcSymmetricKey_t kSpAuth;
-} cmpSpRegActMsgEdata_t;
-
-/** SpContRegisterActivate encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpSpRegActMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegActMsgEdata_t))];
-} cmpSpRegActCmdEd_t;
-
-/** SpContRegisterActivate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- mcSpid_t spid;
- /** Encrypted and padded data. */
- cmpSpRegActCmdEd_t ed;
-} cmpSpRegActCmdSdata_t;
-
-/** SpContRegisterActivate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpRegActCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContRegisterActivateCmd_t;
-
-/** SpContRegisterActivate command. */
-typedef struct {
- /** Command. */
- cmpSpContRegisterActivateCmd_t cmd;
-} cmpCmdSpContRegisterActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_ACTIVATE_RSP Response_2_0
- * @{ */
-
-/** SpContRegisterActivate encrypted data response. */
-typedef struct {
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpRegActRspEdata_t;
-
-/** SpContRegisterActivate encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpSpRegActRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegActRspEdata_t))];
-} cmpSpRegActRspEd_t;
-
-/** SpContRegisterActivate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpSpRegActRspEd_t ed;
-} cmpSpRegActRspSdata_t;
-
-/** SpContRegisterActivate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpRegActRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContRegisterActivateRsp_t;
-
-/** SpContRegisterActivate response. */
-typedef struct {
- /** Response. */
- cmpSpContRegisterActivateRsp_t rsp;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpRspSpContRegisterActivate_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNREGISTER \
- MC_CMP_2_0_CMD_SP_CONT_UNREGISTER
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNREGISTER_CMD Command_2_0
- * @{ */
-
-/** SpContUnregister signed response. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpSpContUnregCmdSdata_t;
-
-/** SpContUnregister signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpContUnregCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnregisterCmd_t;
-
-/** SpContUnregister command. */
-typedef struct {
- /** Command. */
- cmpSpContUnregisterCmd_t cmd;
-} cmpCmdSpContUnregister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNREGISTER_RSP Response_2_0
- * @{ */
-
-/** SpContUnregister encrypted data response. */
-typedef struct {
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpSpUnregRspEdata_t;
-
-/** SpContUnregister encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpSpUnregRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpUnregRspEdata_t))];
-} cmpSpUnregRspEd_t;
-
-/** SpContUnregister signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpSpUnregRspEd_t ed;
-} cmpSpContUnregRspSdata_t;
-
-/** SpContUnregister signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpContUnregRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnregisterRsp_t;
-
-/** SpContUnregister response. */
-typedef struct {
- /** Response. */
- cmpSpContUnregisterRsp_t rsp;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpRspSpContUnregister_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER \
- MC_CMP_2_0_CMD_SP_CONT_REGISTER
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_CMD Command_2_0
- * @{ */
-
-/** SpContRegister encrypted data command. */
-typedef struct {
- /** Sp authentication key. */
- mcSymmetricKey_t kSpAuth;
-} cmpSpRegisterMsgEdata_t;
-
-/** SpContRegister encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpSpRegisterMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegisterMsgEdata_t))];
-} cmpSpRegisterCmdEd_t;
-
-/** SpContRegister signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Encrypted and padded data. */
- cmpSpRegisterCmdEd_t ed;
-} cmpSpRegisterCmdSdata_t;
-
-/** SpContRegister signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpRegisterCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContRegisterCmd_t;
-
-/** SpContRegister command. */
-typedef struct {
- /** Command. */
- cmpSpContRegisterCmd_t cmd;
-} cmpCmdSpContRegister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_RSP Response_2_0
- * @{ */
-
-/** SpContRegister encrypted data response. */
-typedef struct {
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpRegisterRspEdata_t;
-
-/** SpContRegister encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpSpRegisterRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegisterRspEdata_t))];
-} cmpSpRegisterRspEd_t;
-
-/** SpContRegister signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpSpRegisterRspEd_t ed;
-} cmpSpRegisterRspSdata_t;
-
-/** SpContRegister signed response and signature. */
-typedef struct {
- cmpSpRegisterRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContRegisterRsp_t;
-
-/** SpContRegister response. */
-typedef struct {
- /** Response. */
- cmpSpContRegisterRsp_t rsp;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpRspSpContRegister_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_ROOT \
- MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_ROOT
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_ROOT_CMD Command_2_0
- * @{ */
-
-/** SpContLockByRoot signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpSpLockByRootCmdSdata_t;
-
-/** SpContLockByRoot signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpLockByRootCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContLockByRootCmd_t;
-
-/** SpContLockByRoot command. */
-typedef struct {
- /** Command. */
- cmpSpContLockByRootCmd_t cmd;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpCmdSpContLockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_ROOT_RSP Response_2_0
- * @{ */
-
-/** SpContLockByRoot encrypted data response. */
-typedef struct {
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpLockByRootRspEdata_t;
-
-/** SpContLockByRoot encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpSpLockByRootRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpLockByRootRspEdata_t))];
-} cmpSpLockByRootRspEd_t;
-
-/** SpContLockByRoot signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpSpLockByRootRspEd_t ed;
-} cmpSpLockByRootRspSdata_t;
-
-/** SpContLockByRoot signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpLockByRootRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContLockByRootRsp_t;
-
-/** SpContLockByRoot response. */
-typedef struct {
- /** Response. */
- cmpSpContLockByRootRsp_t rsp;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpRspSpContLockByRoot_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_ROOT \
- MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_ROOT
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_ROOT_CMD Command_2_0
- * @{ */
-
-/** SpContUnlockByRoot signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpSpUnlockByRootCmdSdata_t;
-
-/** SpContUnlockByRoot signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpUnlockByRootCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnlockByRootCmd_t;
-
-/** SpContUnlockByRoot command. */
-typedef struct {
- /** Command. */
- cmpSpContUnlockByRootCmd_t cmd;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpCmdSpContUnlockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_ROOT_RSP Response_2_0
- * @{ */
-
-/** SpContUnlockByRoot encrypted data response. */
-typedef struct {
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpUnlockByRootRspEdata_t;
-
-/** SpContUnlockByRoot encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpSpUnlockByRootRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpUnlockByRootRspEdata_t))];
-} cmpSpUnlockByRootRspEd_t;
-
-/** SpContUnlockByRoot signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpSpUnlockByRootRspEd_t ed;
-} cmpSpUnlockByRootRspSdata_t;
-
-/** SpContUnlockByRoot signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpUnlockByRootRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnlockByRootRsp_t;
-
-/** SpContUnlockByRoot response. */
-typedef struct {
- /** Response. */
- cmpSpContUnlockByRootRsp_t rsp;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpRspSpContUnlockByRoot_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_ACTIVATE \
- MC_CMP_2_0_CMD_SP_CONT_ACTIVATE
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_ACTIVATE_CMD Command_2_0
- * @{ */
-
-/** SpContActivate encrypted data command. */
-typedef struct {
- /** Sp authentication key. */
- mcSymmetricKey_t kSpAuth;
-} cmpSpActivateMsgEdata_t;
-
-/** SpContActivate encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpSpActivateMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpActivateMsgEdata_t))];
-} cmpSpActivateCmdEd_t;
-
-/** SpContActivate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Encrypted and padded data. */
- cmpSpActivateCmdEd_t ed;
-} cmpSpActivateCmdSdata_t;
-
-/** SpContActivate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpActivateCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContActivateCmd_t;
-
-/** SpContActivate command. */
-typedef struct {
- /** Command. */
- cmpSpContActivateCmd_t cmd;
-} cmpCmdSpContActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_ACTIVATE_RSP Response_2_0
- * @{ */
-
-/** SpContActivate encrypted data response. */
-typedef struct {
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpActivateRspEdata_t;
-
-/** SpContActivate encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpSpActivateRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpActivateRspEdata_t))];
-} cmpSpActivateRspEd_t;
-
-/** SpContActivate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpSpActivateRspEd_t ed;
-} cmpSpActivateRspSdata_t;
-
-/** SpContActivate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpActivateRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContActivateRsp_t;
-
-/** SpContActivate response. */
-typedef struct {
- /** Response. */
- cmpSpContActivateRsp_t rsp;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpRspSpContActivate_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_SP \
- MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_SP
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_SP_CMD Command_2_0
- * @{ */
-
-/** SpContLockBySp signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpSpLockBySpCmdSdata_t;
-
-/** SpContLockBySp signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpLockBySpCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContLockBySpCmd_t;
-
-/** SpContLockBySp command. */
-typedef struct {
- /** Command. */
- cmpSpContLockBySpCmd_t cmd;
-} cmpCmdSpContLockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_SP_RSP Response_2_0
- * @{ */
-
-/** SpContLockBySp encrypted data response. */
-typedef struct {
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpLockBySpRspEdata_t;
-
-/** SpContLockBySp encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpSpLockBySpRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpLockBySpRspEdata_t))];
-} cmpSpLockBySpRspEd_t;
-
-/** SpContLockBySp signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpSpLockBySpRspEd_t ed;
-} cmpSpLockBySpRspSdata_t;
-
-/** SpContLockBySp signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpLockBySpRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContLockBySpRsp_t;
-
-/** SpContLockBySp response. */
-typedef struct {
- /** Response. */
- cmpSpContLockBySpRsp_t rsp;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpRspSpContLockBySp_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_SP \
- MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_SP
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_SP_CMD Command_2_0
- * @{ */
-
-/** SpContUnlockBySp signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpSpUnlockBySpCmdSdata_t;
-
-/** SpContUnlockBySp signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpUnlockBySpCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnlockBySpCmd_t;
-
-/** SpContUnlockBySp command. */
-typedef struct {
- /** Command. */
- cmpSpContUnlockBySpCmd_t cmd;
-} cmpCmdSpContUnlockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_SP_RSP Response_2_0
- * @{ */
-
-/** SpContUnlockBySp encrypted data response. */
-typedef struct {
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpUnlockBySpRspEdata_t;
-
-/** SpContUnlockBySp encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpSpUnlockBySpRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpUnlockBySpRspEdata_t))];
-} cmpSpUnlockBySpRspEd_t;
-
-/** SpContUnlockBySp signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpSpUnlockBySpRspEd_t ed;
-} cmpSpUnlockBySpRspSdata_t;
-
-/** SpContUnlockBySp signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpUnlockBySpRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnlockBySpRsp_t;
-
-/** SpContUnlockBySp response. */
-typedef struct {
- /** Response. */
- cmpSpContUnlockBySpRsp_t rsp;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpRspSpContUnlockBySp_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_ACTIVATE \
- MC_CMP_2_0_CMD_TLT_CONT_REGISTER_ACTIVATE
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_ACTIVATE_CMD Command_2_0
- * @{ */
-
-/** TltContRegisterActivate encrypted data command. */
-typedef struct {
- /** Tlt authentication key. */
- mcSymmetricKey_t kSpTltEnc;
-} cmpTltRegActMsgEdata_t;
-
-/** TltContRegisterActivate encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpTltRegActMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegActMsgEdata_t))];
-} cmpTltRegActCmdEd_t;
-
-/** TltContRegisterActivate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
- /** Encrypted and padded data. */
- cmpTltRegActCmdEd_t ed;
-} cmpTltRegActCmdSdata_t;
-
-/** TltContRegisterActivate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltRegActCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContRegisterActivateCmd_t;
-
-/** TltContRegisterActivate command. */
-typedef struct {
- /** Command. */
- cmpTltContRegisterActivateCmd_t cmd;
-} cmpCmdTltContRegisterActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_ACTIVATE_RSP Response_2_0
- * @{ */
-
-/** TltContRegisterActivate encrypted data response. */
-typedef struct {
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpTltRegActRspEdata_t;
-
-/** TltContRegisterActivate encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpTltRegActRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegActRspEdata_t))];
-} cmpTltRegActRspEd_t;
-
-/** TltContRegisterActivate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpTltRegActRspEd_t ed;
-} cmpTltRegActRspSdata_t;
-
-/** TltContRegisterActivate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltRegActRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContRegisterActivateRsp_t;
-
-/** TltContRegisterActivate response. */
-typedef struct {
- /** Response. */
- cmpTltContRegisterActivateRsp_t rsp;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpRspTltContRegisterActivate_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNREGISTER \
- MC_CMP_2_0_CMD_TLT_CONT_UNREGISTER
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNREGISTER_CMD Command_2_0
- * @{ */
-
-/** TltContUnregister signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
-} cmpTltUnregCmdSdata_t;
-
-/** TltContUnregister signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltUnregCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContUnregisterCmd_t;
-
-/** TltContUnregister command. */
-typedef struct {
- /** Command. */
- cmpTltContUnregisterCmd_t cmd;
-} cmpCmdTltContUnregister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNREGISTER_RSP Response_2_0
- * @{ */
-
-/** TltContUnregister encrypted data response. */
-typedef struct {
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpTltUnregRspEdata_t;
-
-/** TltContUnregister encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpTltUnregRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltUnregRspEdata_t))];
-} cmpTltUnregRspEd_t;
-
-/** TltContUnregister signed command. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpTltUnregRspEd_t ed;
-} cmpTltUnregRspSdata_t;
-
-/** TltContUnregister signed command and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltUnregRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContUnregisterRsp_t;
-
-/** TltContUnregister response. */
-typedef struct {
- /** Response. */
- cmpTltContUnregisterRsp_t rsp;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpRspTltContUnregister_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER \
- MC_CMP_2_0_CMD_TLT_CONT_REGISTER
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_CMD Command_2_0
- * @{ */
-
-/** TltContRegister encrypted data command. */
-typedef struct {
- /** Tlt authentication key. */
- mcSymmetricKey_t kSpTltEnc;
-} cmpTltRegMsgEdata_t;
-
-/** TltContRegister encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpTltRegMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegMsgEdata_t))];
-} cmpTltRegCmdEd_t;
-
-/** TltContRegister signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
- /** Encrypted and padded data. */
- cmpTltRegCmdEd_t ed;
-} cmpTltRegCmdSdata_t;
-
-/** TltContRegister signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltRegCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContRegisterCmd_t;
-
-/** TltContRegister command. */
-typedef struct {
- /** Command. */
- cmpTltContRegisterCmd_t cmd;
-} cmpCmdTltContRegister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_RSP Response_2_0
- * @{ */
-
-/** TltContRegister encrypted data response. */
-typedef struct {
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpTltRegRspEdata_t;
-
-/** TltContRegister encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpTltRegRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegRspEdata_t))];
-} cmpTltRegRspEd_t;
-
-/** TltContRegister signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpTltRegRspEd_t ed;
-} cmpTltRegRspSdata_t;
-
-/** TltContRegister signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltRegRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContRegisterRsp_t;
-
-/** TltContRegister response. */
-typedef struct {
- /** Response. */
- cmpTltContRegisterRsp_t rsp;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpRspTltContRegister_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_ACTIVATE \
- MC_CMP_2_0_CMD_TLT_CONT_ACTIVATE
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_ACTIVATE_CMD Command_2_0
- * @{ */
-
-/** TltContActivate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
-} cmpTltActCmdSdata_t;
-
-/** TltContActivate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltActCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContActivateCmd_t;
-
-/** TltContActivate command. */
-typedef struct {
- /** Command. */
- cmpTltContActivateCmd_t cmd;
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpCmdTltContActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_ACTIVATE_RSP Response_2_0
- * @{ */
-
-/** TltContActivate encrypted data response. */
-typedef struct {
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpTltActRspEdata_t;
-
-/** TltContActivate encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpTltActRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltActRspEdata_t))];
-} cmpTltActRspEd_t;
-
-/** TltContActivate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpTltActRspEd_t ed;
-} cmpTltActRspSdata_t;
-
-/** TltContActivate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltActRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContActivateRsp_t;
-
-/** TltContActivate response. */
-typedef struct {
- /** Response. */
- cmpTltContActivateRsp_t rsp;
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpRspTltContActivate_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_LOCK_BY_SP \
- MC_CMP_2_0_CMD_TLT_CONT_LOCK_BY_SP
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_LOCK_BY_SP_CMD Command_2_0
- * @{ */
-
-/** TltContLockBySp signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
-} cmpTltLockBySpCmdSdata_t;
-
-/** TltContLockBySp signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltLockBySpCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContLockBySpCmd_t;
-
-/** TltContLockBySp command. */
-typedef struct {
- /** Command. */
- cmpTltContLockBySpCmd_t cmd;
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpCmdTltContLockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_LOCK_BY_SP_RSP Response_2_0
- * @{ */
-
-/** TltContLockBySp encrypted data response. */
-typedef struct {
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpTltLockBySpRspEdata_t;
-
-/** TltContLockBySp encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpTltLockBySpRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltLockBySpRspEdata_t))];
-} cmpTltLockBySpRspEd_t;
-
-/** TltContLockBySp signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpTltLockBySpRspEd_t ed;
-} cmpTltLockBySpRspSdata_t;
-
-/** TltContLockBySp signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltLockBySpRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContLockBySpRsp_t;
-
-/** TltContLockBySp response. */
-typedef struct {
- /** Response. */
- cmpTltContLockBySpRsp_t rsp;
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpRspTltContLockBySp_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNLOCK_BY_SP \
- MC_CMP_2_0_CMD_TLT_CONT_UNLOCK_BY_SP
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNLOCK_BY_SP_CMD Command_2_0
- * @{ */
-
-/** TltContUnlockBySp signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
-} cmpTltUnlockBySpCmdSdata_t;
-
-/** TltContUnlockBySp signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltUnlockBySpCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContUnlockBySpCmd_t;
-
-/** TltContUnlockBySp command. */
-typedef struct {
- /** Command. */
- cmpTltContUnlockBySpCmd_t cmd;
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpCmdTltContUnlockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNLOCK_BY_SP_RSP Response_2_0
- * @{ */
-
-/** TltContUnlockBySp encrypted data response. */
-typedef struct {
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpTltUnlockBySpRspEdata_t;
-
-/** TltContUnlockBySp encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpTltUnlockBySpRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltUnlockBySpRspEdata_t))];
-} cmpTltUnlockBySpRspEd_t;
-
-/** TltContUnlockBySp signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data. */
- cmpTltUnlockBySpRspEd_t ed;
-} cmpTltUnlockBySpRspSdata_t;
-
-/** TltContUnlockBySp signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltUnlockBySpRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContUnlockBySpRsp_t;
-
-/** TltContUnlockBySp response. */
-typedef struct {
- /** Response. */
- cmpTltContUnlockBySpRsp_t rsp;
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpRspTltContUnlockBySp_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_PERSONALIZE \
- MC_CMP_2_0_CMD_TLT_CONT_PERSONALIZE
- * @{ */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_PERSONALIZE_CMD Command_2_0
- * @{ */
-
-/** TltContPersonalize encrypted data command. */
-typedef struct {
- /** Pid. */
- mcPid_t pid;
- /** Data. */
- mcCoDataCont_t persoData;
-} cmpTltContPersonalizeCmdEdata_t;
-
-/** TltContPersonalize encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpTltContPersonalizeCmdEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltContPersonalizeCmdEdata_t))];
-} cmpTltContPersonalizeCmdEd_t;
-
-/** TltContPersonalize signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpTltContPersonalizeCmdEd_t ed;
-} cmpTltContPersonalizeCmdSdata_t;
-
-/** TltContPersonalize signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltContPersonalizeCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContPersonalizeCmd_t;
-
-/** TltContPersonalize command. */
-typedef struct {
- /** Command. */
- cmpTltContPersonalizeCmd_t cmd;
- /** Tlt container secure object. */
- mcSoTltCont_2_0_t soTltCont;
-} cmpCmdTltContPersonalize_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_PERSONLIZE_RSP Response_2_0
- * @{ */
-
-/** TltContPersonalize encrypted data response. */
-typedef struct {
- /** Data container secure object. */
- mcSoDataCont_t soDataCont;
-} cmpTltContPersonalizeRspEdata_t;
-
-/** TltContPersonalize encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpTltContPersonalizeRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltContPersonalizeRspEdata_t))];
-} cmpTltContPersonalizeRspEd_t;
-
-/** TltContPersonalize signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpTltContPersonalizeRspEd_t ed;
-} cmpTltContPersonalizeRspSdata_t;
-
-/** TltContPersonalize signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltContPersonalizeRspSdata_t sdata;
- cmpMac_t mac;
-} cmpTltContPersonalizeRsp_t;
-
-/** TltContPersonalize response. */
-typedef struct {
- /** Response. */
- cmpTltContPersonalizeRsp_t rsp;
- /** Data container secure object. */
- mcSoDataCont_t soDataCont;
-} cmpRspTltContPersonalize_t;
-
-/** @} */
-
-/** @} */
-
-#endif // CMP_H_
-
-/** @} */
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup CMP_2_0
- * @{
- * @file
- * Interface to content management trustlet (TlCm) definitions.
- *
- * The TlCm is responsible for implementing content management protocol (CMP)
- * 2.0 commands and generating approriate CMP 2.0 responses in the trustlet
- * control interface (TCI).
- */
-
-#ifndef TL_CM_API_H_
-#define TL_CM_API_H_
-
-#include "TlCm/tlCmApiCommon.h"
-#include "TlCm/2.0/cmp.h"
-
-/** TCI CMP 2.0 messages. */
-typedef union {
- /** Command header. */
- cmpCommandHeader_t commandHeader;
- /** Response header. */
- cmpResponseHeader_t responseHeader;
-
- /** System command GetVersion. */
- cmpCmdGetVersion_t cmpCmdGetVersion;
- /** System response GetVersion. */
- cmpRspGetVersion_t cmpRspGetVersion;
- /** System command GetSuid. */
- cmpCmdGetSuid_t cmpCmdGetSuid;
- /** System response GetSuid. */
- cmpRspGetSuid_t cmpRspGetSuid;
- /** System command GenAuthToken. */
- cmpCmdGenAuthToken_t cmpCmdGenAuthToken;
- /** System response GenAuthToken. */
- cmpRspGenAuthToken_t cmpRspGenAuthToken;
-
- /** Authentication command BeginSocAuthentication. */
- cmpCmdBeginSocAuthentication_t cmpCmdBeginSocAuthentication;
- /** Authentication response BeginSocAuthentication. */
- cmpRspBeginSocAuthentication_t cmpRspBeginSocAuthentication;
- /** Authentication command BeginRootAuthentication. */
- cmpCmdBeginRootAuthentication_t cmpCmdBeginRootAuthentication;
- /** Authentication response BeginRootAuthentication. */
- cmpRspBeginRootAuthentication_t cmpRspBeginRootAuthentication;
- /** Authentication command BeginSpAuthentication. */
- cmpCmdBeginSpAuthentication_t cmpCmdBeginSpAuthentication;
- /** Authentication response BeginSpAuthentication. */
- cmpRspBeginSpAuthentication_t cmpRspBeginSpAuthentication;
- /** Authentication command Authenticate. */
- cmpCmdAuthenticate_t cmpCmdAuthenticate;
- /** Authentication response Authenticate. */
- cmpRspAuthenticate_t cmpRspAuthenticate;
- /** Authentication command AuthenticateTerminate. */
- cmpCmdAuthenticateTerminate_t cmpCmdAuthenticateTerminate;
- /** Authentication response AuthenticateTerminate. */
- cmpRspAuthenticateTerminate_t cmpRspAuthenticateTerminate;
-
- /** SoC administrative command RootContRegisterActivate. */
- cmpCmdRootContRegisterActivate_t cmpCmdRootContRegisterActivate;
- /** SoC administrative response RootContRegisterActivate. */
- cmpRspRootContRegisterActivate_t cmpRspRootContRegisterActivate;
-
- /** Root administrative command RootContUnregister. */
- cmpCmdRootContUnregister_t cmpCmdRootContUnregister;
- /** Root administrative response RootContUnregister. */
- cmpRspRootContUnregister_t cmpRspRootContUnregister;
- /** Root administrative command RootContLockByRoot. */
- cmpCmdRootContLockByRoot_t cmpCmdRootContLockByRoot;
- /** Root administrative response RootContLockByRoot. */
- cmpRspRootContLockByRoot_t cmpRspRootContLockByRoot;
- /** Root administrative command RootContUnlockByRoot. */
- cmpCmdRootContUnlockByRoot_t cmpCmdRootContUnlockByRoot;
- /** Root administrative command RootContUnlockByRoot. */
- cmpRspRootContUnlockByRoot_t cmpRspRootContUnlockByRoot;
- /** Root administrative command SpContRegisterActivate. */
- cmpCmdSpContRegisterActivate_t cmpCmdSpContRegisterActivate;
- /** Root administrative response SpContRegisterActivate. */
- cmpRspSpContRegisterActivate_t cmpRspSpContRegisterActivate;
- /** Root administrative command SpContUnregister. */
- cmpCmdSpContUnregister_t cmpCmdSpContUnregister;
- /** Root administrative response SpContUnregister. */
- cmpRspSpContUnregister_t cmpRspSpContUnregister;
- /** Root administrative command SpContRegister. */
- cmpCmdSpContRegister_t cmpCmdSpContRegister;
- /** Root administrative response SpContRegister. */
- cmpRspSpContRegister_t cmpRspSpContRegister;
- /** Root administrative command SpContLockByRoot. */
- cmpCmdSpContLockByRoot_t cmpCmdSpContLockByRoot;
- /** Root administrative response SpContLockByRoot. */
- cmpRspSpContLockByRoot_t cmpRspSpContLockByRoot;
- /** Root administrative command SpContUnlockByRoot. */
- cmpCmdSpContUnlockByRoot_t cmpCmdSpContUnlockByRoot;
- /** Root administrative response SpContUnlockByRoot. */
- cmpRspSpContUnlockByRoot_t cmpRspSpContUnlockByRoot;
-
- /** Sp administrative command SpContActivate. */
- cmpCmdSpContActivate_t cmpCmdSpContActivate;
- /** Sp administrative response SpContActivate. */
- cmpRspSpContActivate_t cmpRspSpContActivate;
- /** Sp administrative command SpContLockBySp. */
- cmpCmdSpContLockBySp_t cmpCmdSpContLockBySp;
- /** Sp administrative response SpContLockBySp. */
- cmpRspSpContLockBySp_t cmpRspSpContLockBySp;
- /** Sp administrative command SpContUnlockBySp. */
- cmpCmdSpContUnlockBySp_t cmpCmdSpContUnlockBySp;
- /** Sp administrative command SpContUnlockBySp. */
- cmpRspSpContUnlockBySp_t cmpRspSpContUnlockBySp;
- /** Sp administrative command TltContRegisterActivate. */
- cmpCmdTltContRegisterActivate_t cmpCmdTltContRegisterActivate;
- /** Sp administrative response TltContRegisterActivate. */
- cmpRspTltContRegisterActivate_t cmpRspTltContRegisterActivate;
- /** Sp administrative command TltContUnregister. */
- cmpCmdTltContUnregister_t cmpCmdTltContUnregister;
- /** Sp administrative response TltContUnregister. */
- cmpRspTltContUnregister_t cmpRspTltContUnregister;
- /** Sp administrative command TltContRegister. */
- cmpCmdTltContRegister_t cmpCmdTltContRegister;
- /** Sp administrative response TltContRegister. */
- cmpRspTltContRegister_t cmpRspTltContRegister;
- /** Sp administrative command TltContActivate. */
- cmpCmdTltContActivate_t cmpCmdTltContActivate;
- /** Sp administrative response TltContActivate. */
- cmpRspTltContActivate_t cmpRspTltContActivate;
- /** Sp administrative command TltContLockBySp. */
- cmpCmdTltContLockBySp_t cmpCmdTltContLockBySp;
- /** Sp administrative response TltContLockBySp. */
- cmpRspTltContLockBySp_t cmpRspTltContLockBySp;
- /** Sp administrative command TltContUnlockBySp. */
- cmpCmdTltContUnlockBySp_t cmpCmdTltContUnlockBySp;
- /** Sp administrative response TltContUnlockBySp. */
- cmpRspTltContUnlockBySp_t cmpRspTltContUnlockBySp;
- /** Sp administrative command TltContPersonalize. */
- cmpCmdTltContPersonalize_t cmpCmdTltContPersonalize;
- /** Sp administrative response TltContPersonalize. */
- cmpRspTltContPersonalize_t cmpRspTltContPersonalize;
-} cmpMessage_t;
-
-/** TCI CMP 2.0. */
-typedef struct {
- /** TCI CMP 2.0 messages. */
- cmpMessage_t msg;
-} cmp_t;
-
-#endif // TL_CM_API_H_
-
-/** @} */
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup CMP
- * Content Management Protocol Definitions.
- *
- * The content management protocol (CMP) is based on the trustlet control
- * interface (TCI) and CMP mapped interfaces. It defines commands/responses
- * with the content management trustlet (TlCm).
- *
- * @{
- *
- * @file
- * CMP TCI global definitions.
- * Various components need access to (sub-)structures defined and used by CMP;
- * these common definitions are made available through this header file.
- */
-
-#ifndef CMP_H_
-#define CMP_H_
-
-#include "TlCm/cmpCommon.h"
-
-/** Info of the whole mapped memory with NWd. */
-typedef struct {
- /** Address of the mapped memory. */
-#if ( __WORDSIZE == 64 )
- uint32_t addr; /**< The virtual address of the Bulk buffer regarding the address space of the Trusted Application, already includes a possible offset! */
-#else
- void* addr;
-#endif
- /** Size of the mapped memory. */
- uint32_t len;
-} cmpMapInfo_t;
-
-/** Info of the mapped element from a CMP message with NWd. */
-typedef struct {
- /** Offset of the mapped element in the mapped memory. */
- uint32_t offset;
- /** Size of the mapped element. */
- uint32_t len;
-} cmpMapOffsetInfo_t;
-
-/** TCI CMP command header. */
-typedef struct {
- /** CMP version. */
- cmpVersionId_t version;
- /** Command id. */
- cmpCommandId_t commandId;
- /** Info of the whole mapped memory with NWd. */
- cmpMapInfo_t mapInfo;
- /** Info of the mapped CMP command with NWd. */
- cmpMapOffsetInfo_t cmpCmdMapOffsetInfo;
-} cmpCommandHeaderTci_t;
-
-/** TCI CMP response header. */
-typedef struct {
- /** CMP version. */
- cmpVersionId_t version;
- /** Response id (must be command id | RSP_ID_MASK ). */
- cmpResponseId_t responseId;
- /** Required lenght (return 0 if lenght is enough) of the mapped memory
- * with NWd. */
- uint32_t len;
-} cmpResponseHeaderTci_t;
-
-/** @defgroup MC_CMP_CMD_GET_VERSION_TCI \
- MC_CMP_CMD_GET_VERSION_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_GET_VERSION_TCI_CMD Command
- * @{ */
-
-/** GetVersion TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdGetVersionTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GET_VERSION_TCI_RSP Response
- * @{ */
-
-/** GetVersion TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
-} cmpRspGetVersionTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GET_SUID_TCI \
- MC_CMP_CMD_GET_SUID_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_GET_VERSION_TCI_CMD Command
- * @{ */
-
-/** GetSuid TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdGetSuidTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GET_VERSION_TCI_RSP Response
- * @{ */
-
-/** GetSuid TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
-} cmpRspGetSuidTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI \
- MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI_CMD Command
- * @{ */
-
-/** GenAuthToken TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdGenAuthTokenTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI_RSP Response
- * @{ */
-
-/** GenAuthToken TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeaderTci;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped AuthTokenCont with NWd. */
- cmpMapOffsetInfo_t cmpAuthTokenContMapOffsetInfo;
-} cmpRspGenAuthTokenTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GENERATE_BINDING_KEY_TCI \
- MC_CMP_CMD_GENERATE_BINDING_KEY_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_GENERATE_BINDING_KEY_TCI_CMD Command
- * @{ */
-
-/** GenBindingKey TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdGenBindingKeyTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GENERATE_BINDING_KEY_TCI_RSP Response
- * @{ */
-
-/** GenAuthToken TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeaderTci;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped AuthTokenCont with NWd. */
- cmpMapOffsetInfo_t cmpAuthTokenContMapOffsetInfo;
-} cmpRspGenBindingKeyTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_TCI \
- MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_TCI_CMD Command
- * @{ */
-
-/** BeginSocAuthentication TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
- /** Offset of the mapped AuthTokenCont with NWd. */
- cmpMapOffsetInfo_t cmpAuthTokenContMapOffsetInfo;
-} cmpCmdBeginSocAuthenticationTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_TCI_RSP Response
- * @{ */
-
-/** BeginSocAuthentication TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
-} cmpRspBeginSocAuthenticationTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_TCI \
- MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_TCI_CMD Command
- * @{ */
-
-/** BeginRootAuthentication TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
- /** Offset of the mapped RootCont with NWd. */
- cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
-} cmpCmdBeginRootAuthenticationTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_TCI_RSP Response
- * @{ */
-
-/** BeginRootAuthentication TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
-} cmpRspBeginRootAuthenticationTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_TCI \
- MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_TCI_CMD Command
- * @{ */
-
-/** BeginSpAuthentication TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
- /** Offset of the mapped RootCont with NWd. */
- cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
-} cmpCmdBeginSpAuthenticationTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_TCI_RSP Response
- * @{ */
-
-/** BeginSpAuthentication TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
-} cmpRspBeginSpAuthenticationTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE_TCI \
- MC_CMP_CMD_AUTHENTICATE_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE_TCI_CMD Command
- * @{ */
-
-/** Authenticate TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdAuthenticateTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE_TCI_RSP Response
- * @{ */
-
-/** Authenticate TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
-} cmpRspAuthenticateTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_TCI \
- MC_CMP_CMD_AUTHENTICATE_TERMINATE_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_TCI_CMD Command
- * @{ */
-
-/** AuthenticateTerminate TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdAuthenticateTerminateTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_TCI_RSP Response
- * @{ */
-
-/** AuthenticateTerminate TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
-} cmpRspAuthenticateTerminateTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_TCI \
- MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_TCI_CMD Command
- * @{ */
-
-/** RootContRegisterActivate TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdRootContRegisterActivateTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_TCI_RSP Response
- * @{ */
-
-/** RootContRegisterActivate TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped RootCont with NWd. */
- cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
-} cmpRspRootContRegisterActivateTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_TCI \
- MC_CMP_CMD_ROOT_CONT_UNREGISTER_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_TCI_CMD Command
- * @{ */
-
-/** RootContUnregister TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdRootContUnregisterTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_TCI_RSP Response
- * @{ */
-
-/** RootContUnregister TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
-} cmpRspRootContUnregisterTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_TCI \
- MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_TCI_CMD Command
- * @{ */
-
-/** RootContLockByRoot TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdRootContLockByRootTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_TCI_RSP Response
- * @{ */
-
-/** RootContLockByRoot TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped RootCont with NWd. */
- cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
-} cmpRspRootContLockByRootTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_TCI \
- MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_TCI_CMD Command
- * @{ */
-
-/** RootContUnlockByRoot TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdRootContUnlockByRootTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_TCI_RSP Response
- * @{ */
-
-/** RootContUnlockByRoot TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped RootCont with NWd. */
- cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
-} cmpRspRootContUnlockByRootTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_TCI \
- MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_TCI_CMD Command
- * @{ */
-
-/** SpContRegisterActivate TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdSpContRegisterActivateTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_TCI_RSP Response
- * @{ */
-
-/** SpContRegisterActivate TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped RootCont with NWd. */
- cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
-} cmpRspSpContRegisterActivateTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_TCI \
- MC_CMP_CMD_SP_CONT_UNREGISTER_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_TCI_CMD Command
- * @{ */
-
-/** SpContUnregister TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdSpContUnregisterTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_TCI_RSP Response
- * @{ */
-
-/** SpContUnregister TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped RootCont with NWd. */
- cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
-} cmpRspSpContUnregisterTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_TCI \
- MC_CMP_CMD_SP_CONT_REGISTER_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_TCI_CMD Command
- * @{ */
-
-/** SpContRegister TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdSpContRegisterTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_TCI_RSP Response
- * @{ */
-
-/** SpContRegister TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped RootCont with NWd. */
- cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
-} cmpRspSpContRegisterTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_TCI \
- MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_TCI_CMD Command
- * @{ */
-
-/** SpContLockByRoot TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
-} cmpCmdSpContLockByRootTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_TCI_RSP Response
- * @{ */
-
-/** SpContLockByRoot TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
-} cmpRspSpContLockByRootTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_TCI \
- MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_TCI_CMD Command
- * @{ */
-
-/** SpContUnlockByRoot TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
-} cmpCmdSpContUnlockByRootTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_TCI_RSP Response
- * @{ */
-
-/** SpContUnlockByRoot TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
-} cmpRspSpContUnlockByRootTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_TCI \
- MC_CMP_CMD_SP_CONT_ACTIVATE_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_TCI_CMD Command
- * @{ */
-
-/** SpContActivate TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdSpContActivateTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_TCI_RSP Response
- * @{ */
-
-/** SpContActivate TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
-} cmpRspSpContActivateTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_TCI \
- MC_CMP_CMD_SP_CONT_LOCK_BY_SP_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_TCI_CMD Command
- * @{ */
-
-/** SpContLockBySp TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdSpContLockBySpTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_TCI_RSP Response
- * @{ */
-
-/** SpContLockBySp TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
-} cmpRspSpContLockBySpTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_TCI \
- MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_TCI_CMD Command
- * @{ */
-
-/** SpContUnlockBySp TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdSpContUnlockBySpTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_TCI_RSP Response
- * @{ */
-
-/** SpContUnlockBySp TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
-} cmpRspSpContUnlockBySpTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_TCI \
- MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_TCI_CMD Command
- * @{ */
-
-/** TltContRegisterActivate TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdTltContRegisterActivateTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_TCI_RSP Response
- * @{ */
-
-/** TltContRegisterActivate TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
- /** Offset of the mapped TltCont with NWd. */
- cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
-} cmpRspTltContRegisterActivateTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_TCI \
- MC_CMP_CMD_TLT_CONT_UNREGISTER_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_TCI_CMD Command
- * @{ */
-
-/** TltContUnregister TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdTltContUnregisterTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_TCI_RSP Response
- * @{ */
-
-/** TltContUnregister TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
-} cmpRspTltContUnregisterTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_TCI \
- MC_CMP_CMD_TLT_CONT_REGISTER_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_TCI_CMD Command
- * @{ */
-
-/** TltContRegister TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
-} cmpCmdTltContRegisterTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_TCI_RSP Response
- * @{ */
-
-/** TltContRegister TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped SpCont with NWd. */
- cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
- /** Offset of the mapped TltCont with NWd. */
- cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
-} cmpRspTltContRegisterTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_TCI \
- MC_CMP_CMD_TLT_CONT_ACTIVATE_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_TCI_CMD Command
- * @{ */
-
-/** TltContActivate TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
- /** Offset of the mapped TltCont with NWd. */
- cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
-} cmpCmdTltContActivateTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_TCI_RSP Response
- * @{ */
-
-/** TltContActivate TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped TltCont with NWd. */
- cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
-} cmpRspTltContActivateTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_TCI \
- MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_TCI_CMD Command
- * @{ */
-
-/** TltContLockBySp TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
- /** Offset of the mapped TltCont with NWd. */
- cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
-} cmpCmdTltContLockBySpTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_TCI_RSP Response
- * @{ */
-
-/** TltContLockBySp TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped TltCont with NWd. */
- cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
-} cmpRspTltContLockBySpTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_TCI \
- MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_TCI_CMD Command
- * @{ */
-
-/** TltContUnlockBySp TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
- /** Offset of the mapped TltCont with NWd. */
- cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
-} cmpCmdTltContUnlockBySpTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_TCI_RSP Response
- * @{ */
-
-/** TltContUnlockBySp TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped TltCont with NWd. */
- cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
-} cmpRspTltContUnlockBySpTci_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_TCI \
- MC_CMP_CMD_TLT_CONT_PERSONALIZE_TCI
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_TCI_CMD Command
- * @{ */
-
-/** TltContPersonalize TCI command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderTci_t cmdHeader;
- /** Offset of the mapped TltCont with NWd. */
- cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
-} cmpCmdTltContPersonalizeTci_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_TCI_RSP Response
- * @{ */
-
-/** TltContPersonalize TCI response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderTci_t rspHeader;
- /** Offset of the mapped CMP response with NWd. */
- cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
- /** Offset of the mapped PersonalizeData with NWd. */
- cmpMapOffsetInfo_t cmpTltContPersoMapOffsetInfo;
-} cmpRspTltContPersonalizeTci_t;
-
-/** @} */
-
-/** @} */
-
-#endif // CMP_H_
-
-/** @} */
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup CMP
- * Content Management Protocol Definitions.
- *
- * The content management protocol (CMP) is based on the trustlet control
- * interface (TCI) and CMP mapped interfaces. It defines commands/responses with
- * the content management trustlet (TlCm).
- *
- * @{
- *
- * @file
- * CMP mapped global definitions.
- * Various components need access to (sub-)structures defined and used by CMP;
- * these common definitions are made available through this header file.
- */
-
-#ifndef CMP_MAP_H_
-#define CMP_MAP_H_
-
-#include "TlCm/3.0/cmp.h"
-
-/** Map CMP GetVersion message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdGetVersion_t cmpCmdGetVersion;
- /** Map CMP response. */
- cmpRspGetVersion_t cmpRspGetVersion;
-} cmpMapGetVersion_t;
-
-/** Map CMP GetSuid message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdGetSuid_t cmpCmdGetSuid;
- /** Map CMP response. */
- cmpRspGetSuid_t cmpRspGetSuid;
-} cmpMapGetSuid_t;
-
-/** Map CMP GenAuthToken message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdGenAuthToken_t cmpCmdGenAuthToken;
- /** Map CMP response. */
- cmpRspGenAuthToken_t cmpRspGenAuthToken;
-} cmpMapGenAuthToken_t;
-
-/** Map CMP GenBindingKey message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdGenBindingKey_t cmpCmdGenBindingKey;
- /** Map CMP response. */
- cmpRspGenBindingKey_t cmpRspGenBindingKey;
-} cmpMapGenBindingKey_t;
-
-/** Map CMP command header. */
-typedef struct {
- /** Command id. */
- cmpCommandId_t commandId;
- /** Size of command. */
- uint32_t len;
- /** Reserved. */
- uint32_t reserved;
-} cmpCommandHeaderMap_t;
-
-/** Map CMP response header. */
-typedef struct {
- /** Return id. */
- cmpResponseId_t responseId;
- /** Return code. */
- cmpReturnCode_t returnCode;
- /** Size of response. */
- uint32_t len;
- /** Reserved. */
- uint32_t reserved;
-} cmpResponseHeaderMap_t;
-
-/** Map CMP message header. */
-typedef union {
- /** Map CMP command. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Map CMP response. */
- cmpResponseHeaderMap_t rspHeader;
-} cmpMapHeader_t;
-
-/** CMP error signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Signature. */
- cmpMac_t mac;
-} cmpErrorRsp_t;
-
-/** Map CMP error response. */
-typedef struct {
- /** Response. */
- cmpErrorRsp_t rsp;
-} cmpMapError_t;
-
-/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION \
- MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION
- * @{ */
-
-/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_CMD Command
- * @{ */
-
-/** BeginSocAuthentication non signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
-} cmpBeginSocAuthenticationCmd_t;
-
-/** BeginSocAuthentication command. */
-typedef struct {
- /** Command. */
- cmpBeginSocAuthenticationCmd_t cmd;
-} cmpCmdBeginSocAuthentication_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_RSP Response
- * @{ */
-
-/** BeginSocAuthentication signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Suid. */
- mcSuid_t suid;
- /** SWd authentication random number. */
- cmpRnd8_t rnd1;
-} cmpBeginSocAuthenticationRspSdata_t;
-
-/** BeginSocAuthentication signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpBeginSocAuthenticationRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpBeginSocAuthenticationRsp_t;
-
-/** BeginSocAuthentication response. */
-typedef struct {
- /** Response. */
- cmpBeginSocAuthenticationRsp_t rsp;
-} cmpRspBeginSocAuthentication_t;
-
-/** @} */
-
-/** Map CMP BeginSocAuthentication message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdBeginSocAuthentication_t cmpCmdBeginSocAuthentication;
- /** Map CMP response. */
- cmpRspBeginSocAuthentication_t cmpRspBeginSocAuthentication;
-} cmpMapBeginSocAuthentication_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION \
- MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION
- * @{ */
-
-/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_CMD Command
- * @{ */
-
-/** BeginRootAuthentication non signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
-} cmpBeginRootAuthenticationCmd_t;
-
-/** BeginRootAuthentication command. */
-typedef struct {
- /** Command. */
- cmpBeginRootAuthenticationCmd_t cmd;
-} cmpCmdBeginRootAuthentication_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_RSP Response
- * @{ */
-
-/** BeginRootAuthentication signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Suid. */
- mcSuid_t suid;
- /** SWd authentication random number. */
- cmpRnd8_t rnd1;
-} cmpBeginRootAuthenticationRspSdata_t;
-
-/** BeginRootAuthentication signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpBeginRootAuthenticationRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpBeginRootAuthenticationRsp_t;
-
-/** BeginRootAuthentication response. */
-typedef struct {
- /** Response. */
- cmpBeginRootAuthenticationRsp_t rsp;
-} cmpRspBeginRootAuthentication_t;
-
-/** @} */
-
-/** Map CMP BeginRootAuthentication message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdBeginRootAuthentication_t cmpCmdBeginRootAuthentication;
- /** Map CMP response. */
- cmpRspBeginRootAuthentication_t cmpRspBeginRootAuthentication;
-} cmpMapBeginRootAuthentication_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION \
- MC_CMP_CMD_BEGIN_SP_AUTHENTICATION
- * @{ */
-
-/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_CMD Command
- * @{ */
-
-/** BeginSpAuthentication non signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpBeginSpAuthenticationCmd_t;
-
-/** BeginSpAuthentication command. */
-typedef struct {
- /** Command. */
- cmpBeginSpAuthenticationCmd_t cmd;
-} cmpCmdBeginSpAuthentication_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_RSP Response
- * @{ */
-
-/** BeginSpAuthentication signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Suid. */
- mcSuid_t suid;
- /** Spid. */
- mcSpid_t spid;
- /** SWd authentication random number. */
- cmpRnd8_t rnd1;
-} cmpBeginSpAuthenticationRspSdata_t;
-
-/** BeginSpAuthentication signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpBeginSpAuthenticationRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpBeginSpAuthenticationRsp_t;
-
-/** BeginSpAuthentication response. */
-typedef struct {
- /** Response. */
- cmpBeginSpAuthenticationRsp_t rsp;
-} cmpRspBeginSpAuthentication_t;
-
-/** @} */
-
-/** Map CMP BeginSpAuthentication message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdBeginSpAuthentication_t cmpCmdBeginSpAuthentication;
- /** Map CMP response. */
- cmpRspBeginSpAuthentication_t cmpRspBeginSpAuthentication;
-} cmpMapBeginSpAuthentication_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE MC_CMP_CMD_AUTHENTICATE
- * @{ */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE_CMD Command
- * @{ */
-
-/** Authenticate encrypted data command. */
-typedef struct {
- /** NWd authentication random number. */
- cmpRnd8_t rnd2;
- /** Suid. */
- mcSuid_t suid;
- /** EntityId. */
- uint32_t entityId;
- /** SWd authentication random number. */
- cmpRnd8_t rnd1;
- /** NWd authentication random seed. */
- cmpRnd32_t k2;
-} cmpAuthMsgEdata_t;
-
-/** Authenticate encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpAuthMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpAuthMsgEdata_t))];
-} cmpAuthCmdEd_t;
-
-/** Authenticate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpAuthCmdEd_t ed;
-} cmpAuthCmdSdata_t;
-
-/** Authenticate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpAuthCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpAuthenticateCmd_t;
-
-/** Authenticate command. */
-typedef struct {
- /** Command. */
- cmpAuthenticateCmd_t cmd;
-} cmpCmdAuthenticate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE_RSP Response
- * @{ */
-
-/** Authenticate encrypted data response. */
-typedef struct {
- /** NWd authentication random number. */
- cmpRnd8_t rnd2;
- /** Suid. */
- mcSuid_t suid;
- /** EntityId. */
- uint32_t entityId;
- /** SWd authentication random number. */
- cmpRnd8_t rnd1;
- /** SWd authentication random seed. */
- cmpRnd32_t k1;
-} cmpAuthRspEdata_t;
-
-/** Authenticate encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpAuthRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpAuthRspEdata_t))];
-} cmpAuthRspEd_t;
-
-/** Authenticate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpAuthRspEd_t ed;
-} cmpAuthRspSdata_t;
-
-/** Authenticate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpAuthRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpAuthenticateRsp_t;
-
-/** Authenticate response. */
-typedef struct {
- /** Response. */
- cmpAuthenticateRsp_t rsp;
-} cmpRspAuthenticate_t;
-
-/** @} */
-
-/** Map CMP Authenticate message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdAuthenticate_t cmpCmdAuthenticate;
- /** Map CMP response. */
- cmpRspAuthenticate_t cmpRspAuthenticate;
-} cmpMapAuthenticate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE \
- MC_CMP_CMD_AUTHENTICATE_TERMINATE
- * @{ */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_CMD Command
- * @{ */
-
-/** AuthenticateTerminate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
-} cmpAuthenticateTerminateCmdSdata_t;
-
-/** AuthenticateTerminate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpAuthenticateTerminateCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpAuthenticateTerminateCmd_t;
-
-/** AuthenticateTerminate command. */
-typedef struct {
- /** Command. */
- cmpAuthenticateTerminateCmd_t cmd;
-} cmpCmdAuthenticateTerminate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_RSP Response
- * @{ */
-
-/** AuthenticateTerminate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
-} cmpAuthenticateTerminateRspSdata_t;
-
-/** AuthenticateTerminate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpAuthenticateTerminateRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpAutenticateTerminateRsp_t;
-
-/** AuthenticateTerminate response. */
-typedef struct {
- /** Response. */
- cmpAutenticateTerminateRsp_t rsp;
-} cmpRspAuthenticateTerminate_t;
-
-/** @} */
-
-/** Map CMP AuthenticateTerminate message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdAuthenticateTerminate_t cmpCmdAuthenticateTerminate;
- /** Map CMP response. */
- cmpRspAuthenticateTerminate_t cmpRspAuthenticateTerminate;
-} cmpMapAuthenticateTerminate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE \
- MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE
- * @{ */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_CMD Command
- * @{ */
-
-/** RootContRegisterActivate encrypted data command. */
-typedef struct {
- /** Root authentication key. */
- mcSymmetricKey_t kRootAuth;
-} cmpRootRegActMsgEdata_t;
-
-/** RootContRegisterActivate encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpRootRegActMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootRegActMsgEdata_t))];
-} cmpRootRegActCmdEd_t;
-
-/** RootContRegisterActivate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Rootid. */
- mcRootid_t rootid;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpRootRegActCmdEd_t ed;
-} cmpRootRegActCmdSdata_t;
-
-/** RootContRegisterActivate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpRootRegActCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContRegisterActivateCmd_t;
-
-/** RootContRegisterActivate command. */
-typedef struct {
- /** Command. */
- cmpRootContRegisterActivateCmd_t cmd;
-} cmpCmdRootContRegisterActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_RSP Response
- * @{ */
-
-/** RootContRegisterActivate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Root container secure object size. */
- uint32_t soRootContLen;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpRootRegActRspSdata_t;
-
-/** RootContRegisterActivate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpRootRegActRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContRegisterActivateRsp_t;
-
-/** RooContRegisterActivate response. */
-typedef struct {
- /** Response. */
- cmpRootContRegisterActivateRsp_t rsp;
-} cmpRspRootContRegisterActivate_t;
-
-/** @} */
-
-/** Map CMP RootContRegisterActivate message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdRootContRegisterActivate_t cmpCmdRootContRegisterActivate;
- /** Map CMP response. */
- cmpRspRootContRegisterActivate_t cmpRspRootContRegisterActivate;
-} cmpMapRootContRegisterActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER \
- MC_CMP_CMD_ROOT_CONT_UNREGISTER
- * @{ */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_CMD Command
- * @{ */
-
-/** RootContUnregister encrypted data command. */
-typedef struct {
- /** Suid. */
- mcSuid_t suid;
-} cmpRootUnregMsgEdata_t;
-
-/** RootContUnregister encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpRootUnregMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootUnregMsgEdata_t))];
-} cmpRootUnregCmdEd_t;
-
-/** RootContUnregister signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpRootUnregCmdEd_t ed;
-} cmpRootUnregCmdSdata_t;
-
-/** RootContUnregister signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpRootUnregCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContUnregisterCmd_t;
-
-/** RootContUnregister command. */
-typedef struct {
- /** Command. */
- cmpRootContUnregisterCmd_t cmd;
-} cmpCmdRootContUnregister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_RSP Response
- * @{ */
-
-/** RootContUnregister encrypted data response. */
-typedef struct {
- /** Suid. */
- mcSuid_t suid;
-} cmpRootUnregRspEdata_t;
-
-/** RootContUnregister encrypted and padded data response. */
-typedef struct {
- /** Encrypted data. */
- cmpRootUnregRspEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpRootUnregRspEdata_t))];
-} cmpRootUnregRspEd_t;
-
-/** RootContUnregister signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpRootUnregRspEd_t ed;
-} cmpRootUnregRspSdata_t;
-
-/** RootContUnregister signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpRootUnregRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContUnregisterRsp_t;
-
-/** RootContUnregister response. */
-typedef struct {
- /** Response. */
- cmpRootContUnregisterRsp_t rsp;
-} cmpRspRootContUnregister_t;
-
-/** @} */
-
-/** Map CMP RootContUnregister message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdRootContUnregister_t cmpCmdRootContUnregister;
- /** Map CMP response. */
- cmpRspRootContUnregister_t cmpRspRootContUnregister;
-} cmpMapRootContUnregister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT \
- MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT
- * @{ */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_CMD Command
- * @{ */
-
-/** RootContLockByRoot signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
-} cmpRootLockByRootCmdSdata_t;
-
-/** RootContLockByRoot signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpRootLockByRootCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContLockByRootCmd_t;
-
-/** RootContLockByRoot command. */
-typedef struct {
- /** Command. */
- cmpRootContLockByRootCmd_t cmd;
-} cmpCmdRootContLockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_RSP Response
- * @{ */
-
-/** RootContLockByRoot signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Root container secure object size. */
- uint32_t soRootContLen;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpRootLockByRootRspSdata_t;
-
-/** RootContLockByRoot signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpRootLockByRootRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContLockByRootRsp_t;
-
-/** RootContLockByRoot response. */
-typedef struct {
- cmpRootContLockByRootRsp_t rsp;
-} cmpRspRootContLockByRoot_t;
-
-/** @} */
-
-/** Map CMP RootContLockByRoot message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdRootContLockByRoot_t cmpCmdRootContLockByRoot;
- /** Map CMP response. */
- cmpRspRootContLockByRoot_t cmpRspRootContLockByRoot;
-} cmpMapRootContLockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT \
- MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT
- * @{ */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_CMD Command
- * @{ */
-
-/** RootContUnlockByRoot signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
-} cmpRootUnlockByRootCmdSdata_t;
-
-/** RootContUnlockByRoot signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpRootUnlockByRootCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContUnlockByRootCmd_t;
-
-/** RootContUnlockByRoot command. */
-typedef struct {
- /** Command. */
- cmpRootContUnlockByRootCmd_t cmd;
-} cmpCmdRootContUnlockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_RSP Response
- * @{ */
-
-/** RootContUnlockByRoot signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Root container secure object size. */
- uint32_t soRootContLen;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpRootUnlockByRootRspSdata_t;
-
-/** RootContUnlockByRoot signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpRootUnlockByRootRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpRootContUnlockByRootRsp_t;
-
-/** RootContUnlockByRoot response. */
-typedef struct {
- /** Response. */
- cmpRootContUnlockByRootRsp_t rsp;
-} cmpRspRootContUnlockByRoot_t;
-
-/** @} */
-
-/** Map CMP RootContUnlockByRoot message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdRootContUnlockByRoot_t cmpCmdRootContUnlockByRoot;
- /** Map CMP response. */
- cmpRspRootContUnlockByRoot_t cmpRspRootContUnlockByRoot;
-} cmpMapRootContUnlockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE \
- MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_CMD Command
- * @{ */
-
-/** SpContRegisterActivate encrypted data command. */
-typedef struct {
- /** Sp authentication key. */
- mcSymmetricKey_t kSpAuth;
-} cmpSpRegActMsgEdata_t;
-
-/** SpContRegisterActivate encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpSpRegActMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegActMsgEdata_t))];
-} cmpSpRegActCmdEd_t;
-
-/** SpContRegisterActivate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpSpRegActCmdEd_t ed;
-} cmpSpRegActCmdSdata_t;
-
-/** SpContRegisterActivate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpRegActCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContRegisterActivateCmd_t;
-
-/** SpContRegisterActivate command. */
-typedef struct {
- /** Command. */
- cmpSpContRegisterActivateCmd_t cmd;
-} cmpCmdSpContRegisterActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_RSP Response
- * @{ */
-
-/** SpContRegisterActivate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Root container secure object size. */
- uint32_t soRootContLen;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
- /** Sp container secure object size. */
- uint32_t soSpContLen;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpRegActRspSdata_t;
-
-/** SpContRegisterActivate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpRegActRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContRegisterActivateRsp_t;
-
-/** SpContRegisterActivate response. */
-typedef struct {
- /** Response. */
- cmpSpContRegisterActivateRsp_t rsp;
-} cmpRspSpContRegisterActivate_t;
-
-/** @} */
-
-/** Map CMP SpContRegisterActivate message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdSpContRegisterActivate_t cmpCmdSpContRegisterActivate;
- /** Map CMP response. */
- cmpRspSpContRegisterActivate_t cmpRspSpContRegisterActivate;
-} cmpMapSpContRegisterActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER \
- MC_CMP_CMD_SP_CONT_UNREGISTER
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_CMD Command
- * @{ */
-
-/** SpContUnregister signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpSpContUnregCmdSdata_t;
-
-/** SpContUnregister signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpContUnregCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnregisterCmd_t;
-
-/** SpContUnregister command. */
-typedef struct {
- /** Command. */
- cmpSpContUnregisterCmd_t cmd;
-} cmpCmdSpContUnregister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_RSP Response
- * @{ */
-
-/** SpContUnregister signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Root container secure object size. */
- uint32_t soRootContLen;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
-} cmpSpContUnregRspSdata_t;
-
-/** SpContUnregister signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpContUnregRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnregisterRsp_t;
-
-/** SpContUnregister response. */
-typedef struct {
- /** Response. */
- cmpSpContUnregisterRsp_t rsp;
-} cmpRspSpContUnregister_t;
-
-/** @} */
-
-/** Map CMP SpContUnregister message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdSpContUnregister_t cmpCmdSpContUnregister;
- /** Map CMP response. */
- cmpRspSpContUnregister_t cmpRspSpContUnregister;
-} cmpMapSpContUnregister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER \
- MC_CMP_CMD_SP_CONT_REGISTER
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_CMD Command
- * @{ */
-
-/** SpContRegister encrypted data command. */
-typedef struct {
- /** Sp authentication key. */
- mcSymmetricKey_t kSpAuth;
-} cmpSpRegisterMsgEdata_t;
-
-/** SpContRegister encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpSpRegisterMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpRegisterMsgEdata_t))];
-} cmpSpRegisterCmdEd_t;
-
-/** SpContRegister signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpSpRegisterCmdEd_t ed;
-} cmpSpRegisterCmdSdata_t;
-
-/** SpContRegister signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpRegisterCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContRegisterCmd_t;
-
-/** SpContRegister command. */
-typedef struct {
- /** Command. */
- cmpSpContRegisterCmd_t cmd;
-} cmpCmdSpContRegister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_RSP Response
- * @{ */
-
-/** SpContRegister signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Root container secure object size. */
- uint32_t soRootContLen;
- /** Root container secure object. */
- mcSoRootCont_t soRootCont;
- /** Sp container secure object size. */
- uint32_t soSpContLen;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpRegisterRspSdata_t;
-
-/** SpContRegister signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpRegisterRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContRegisterRsp_t;
-
-/** SpContRegister response. */
-typedef struct {
- /** Response. */
- cmpSpContRegisterRsp_t rsp;
-} cmpRspSpContRegister_t;
-
-/** @} */
-
-/** Map CMP SpContRegister message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdSpContRegister_t cmpCmdSpContRegister;
- /** Map CMP response. */
- cmpRspSpContRegister_t cmpRspSpContRegister;
-} cmpMapSpContRegister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT \
- MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_CMD Command
- * @{ */
-
-/** SpContLockByRoot signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpSpLockByRootCmdSdata_t;
-
-/** SpContLockByRoot signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpLockByRootCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContLockByRootCmd_t;
-
-/** SpContLockByRoot command. */
-typedef struct {
- /** Command. */
- cmpSpContLockByRootCmd_t cmd;
-} cmpCmdSpContLockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_RSP Response
- * @{ */
-
-/** SpContLockByRoot signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Sp container secure object size. */
- uint32_t soSpContLen;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpLockByRootRspSdata_t;
-
-/** SpContLockByRoot signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpLockByRootRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContLockByRootRsp_t;
-
-/** SpContLockByRoot response. */
-typedef struct {
- /** Response. */
- cmpSpContLockByRootRsp_t rsp;
-} cmpRspSpContLockByRoot_t;
-
-/** @} */
-
-/** Map CMP SpContLockByRoot message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdSpContLockByRoot_t cmpCmdSpContLockByRoot;
- /** Map CMP response. */
- cmpRspSpContLockByRoot_t cmpRspSpContLockByRoot;
-} cmpMapSpContLockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT \
- MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_CMD Command
- * @{ */
-
-/** SpContUnlockByRoot signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpSpUnlockByRootCmdSdata_t;
-
-/** SpContUnlockByRoot signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpUnlockByRootCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnlockByRootCmd_t;
-
-/** SpContUnlockByRoot command. */
-typedef struct {
- /** Command. */
- cmpSpContUnlockByRootCmd_t cmd;
-} cmpCmdSpContUnlockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_RSP Response
- * @{ */
-
-/** SpContUnlockByRoot signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Sp container secure object size. */
- uint32_t soSpContLen;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpUnlockByRootRspSdata_t;
-
-/** SpContUnlockByRoot signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpUnlockByRootRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnlockByRootRsp_t;
-
-/** SpContUnlockByRoot response. */
-typedef struct {
- /** Response. */
- cmpSpContUnlockByRootRsp_t rsp;
-} cmpRspSpContUnlockByRoot_t;
-
-/** @} */
-
-/** Map CMP SpContUnlockByRoot message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdSpContUnlockByRoot_t cmpCmdSpContUnlockByRoot;
- /** Map CMP response. */
- cmpRspSpContUnlockByRoot_t cmpRspSpContUnlockByRoot;
-} cmpMapSpContUnlockByRoot_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE \
- MC_CMP_CMD_SP_CONT_ACTIVATE
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_CMD Command
- * @{ */
-
-/** SpContActivate encrypted data command. */
-typedef struct {
- /** Sp authentication key. */
- mcSymmetricKey_t kSpAuth;
-} cmpSpActivateMsgEdata_t;
-
-/** SpContActivate encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpSpActivateMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpSpActivateMsgEdata_t))];
-} cmpSpActivateCmdEd_t;
-
-/** SpContActivate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpSpActivateCmdEd_t ed;
-} cmpSpActivateCmdSdata_t;
-
-/** SpContActivate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpActivateCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContActivateCmd_t;
-
-/** SpContActivate command. */
-typedef struct {
- /** Command. */
- cmpSpContActivateCmd_t cmd;
-} cmpCmdSpContActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_RSP Response
- * @{ */
-
-/** SpContActivate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Sp container secure object size. */
- uint32_t soSpContLen;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpActivateRspSdata_t;
-
-/** SpContActivate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpActivateRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContActivateRsp_t;
-
-/** SpContActivate response. */
-typedef struct {
- /** Response. */
- cmpSpContActivateRsp_t rsp;
-} cmpRspSpContActivate_t;
-
-/** @} */
-
-/** Map CMP SpContActivate message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdSpContActivate_t cmpCmdSpContActivate;
- /** Map CMP response. */
- cmpRspSpContActivate_t cmpRspSpContActivate;
-} cmpMapSpContActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP \
- MC_CMP_CMD_SP_CONT_LOCK_BY_SP
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_CMD Command
- * @{ */
-
-/** SpContLockBySp signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpSpLockBySpCmdSdata_t;
-
-/** SpContLockBySp signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpLockBySpCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContLockBySpCmd_t;
-
-/** SpContLockBySp command. */
-typedef struct {
- /** Command. */
- cmpSpContLockBySpCmd_t cmd;
-} cmpCmdSpContLockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_RSP Response
- * @{ */
-
-/** SpContLockBySp signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Sp container secure object size. */
- uint32_t soSpContLen;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpLockBySpRspSdata_t;
-
-/** SpContLockBySp signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpLockBySpRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContLockBySpRsp_t;
-
-/** SpContLockBySp response. */
-typedef struct {
- /** Response. */
- cmpSpContLockBySpRsp_t rsp;
-} cmpRspSpContLockBySp_t;
-
-/** @} */
-
-/** Map CMP SpContLockBySp message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdSpContLockBySp_t cmpCmdSpContLockBySp;
- /** Map CMP response. */
- cmpRspSpContLockBySp_t cmpRspSpContLockBySp;
-} cmpMapSpContLockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP \
- MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP
- * @{ */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_CMD Command
- * @{ */
-
-/** SpContUnlockBySp signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
-} cmpSpUnlockBySpCmdSdata_t;
-
-/** SpContUnlockBySp signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpSpUnlockBySpCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnlockBySpCmd_t;
-
-/** SpContUnlockBySp command. */
-typedef struct {
- /** Command. */
- cmpSpContUnlockBySpCmd_t cmd;
-} cmpCmdSpContUnlockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_RSP Response
- * @{ */
-
-/** SpContUnlockBySp signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Sp container secure object size. */
- uint32_t soSpContLen;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpSpUnlockBySpRspSdata_t;
-
-/** SpContUnlockBySp signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpSpUnlockBySpRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpSpContUnlockBySpRsp_t;
-
-/** SpContUnlockBySp response. */
-typedef struct {
- /** Response. */
- cmpSpContUnlockBySpRsp_t rsp;
-} cmpRspSpContUnlockBySp_t;
-
-/** @} */
-
-/** Map CMP SpContUnlockBySp message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdSpContUnlockBySp_t cmpCmdSpContUnlockBySp;
- /** Map CMP response. */
- cmpRspSpContUnlockBySp_t cmpRspSpContUnlockBySp;
-} cmpMapSpContUnlockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE \
- MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_CMD Command
- * @{ */
-
-/** TltContRegisterActivate encrypted data command. */
-typedef struct {
- /** Tlt authentication key. */
- mcSymmetricKey_t kSpTltEnc;
-} cmpTltRegActMsgEdata_t;
-
-/** TltContRegisterActivate encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpTltRegActMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegActMsgEdata_t))];
-} cmpTltRegActCmdEd_t;
-
-/** TltContRegisterActivate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
- /** Trustlet public key hash. */
- mcSha256_t skSpTltEnc;
- /** Minimum trustlet version supported. */
- mcContVersion_t tltVersion;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpTltRegActCmdEd_t ed;
-} cmpTltRegActCmdSdata_t;
-
-/** TltContRegisterActivate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltRegActCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContRegisterActivateCmd_t;
-
-/** TltContRegisterActivate command. */
-typedef struct {
- /** Command. */
- cmpTltContRegisterActivateCmd_t cmd;
-} cmpCmdTltContRegisterActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_RSP Response
- * @{ */
-
-/** TltContRegisterActivate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Sp container secure object size. */
- uint32_t soSpContLen;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
- /* TltCont mapping info is in TCI cmpRspTltContRegisterActivateTci */
- uint32_t soTltContLen;
- mcSoTltCont_2_1_t soTltCont;
-} cmpTltRegActRspSdata_t;
-
-/** TltContRegisterActivate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltRegActRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContRegisterActivateRsp_t;
-
-/** TltContRegisterActivate response. */
-typedef struct {
- cmpTltContRegisterActivateRsp_t rsp;
-} cmpRspTltContRegisterActivate_t;
-
-/** @} */
-
-/** Map CMP TltContRegisterActivate message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdTltContRegisterActivate_t cmpCmdTltContRegisterActivate;
- /** Map CMP response. */
- cmpRspTltContRegisterActivate_t cmpRspTltContRegisterActivate;
-} cmpMapTltContRegisterActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER \
- MC_CMP_CMD_TLT_CONT_UNREGISTER
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_CMD Command
- * @{ */
-
-/** TltContUnregister signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
-} cmpTltUnregCmdSdata_t;
-
-/** TltContUnregister signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltUnregCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContUnregisterCmd_t;
-
-/** TltContUnregister command. */
-typedef struct {
- /** Command. */
- cmpTltContUnregisterCmd_t cmd;
-} cmpCmdTltContUnregister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_RSP Response
- * @{ */
-
-/** TltContUnregister signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Sp container secure object size. */
- uint32_t soSpContLen;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
-} cmpTltUnregRspSdata_t;
-
-/** TltContUnregister signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltUnregRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContUnregisterRsp_t;
-
-/** TltContUnregister response. */
-typedef struct {
- /** Response. */
- cmpTltContUnregisterRsp_t rsp;
-} cmpRspTltContUnregister_t;
-
-/** @} */
-
-/** Map CMP TltContUnregister message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdTltContUnregister_t cmpCmdTltContUnregister;
- /** Map CMP response. */
- cmpRspTltContUnregister_t cmpRspTltContUnregister;
-} cmpMapTltContUnregister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER \
- MC_CMP_CMD_TLT_CONT_REGISTER
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_CMD Command
- * @{ */
-
-/** TltContRegister encrypted data command. */
-typedef struct {
- /** Tlt authentication key. */
- mcSymmetricKey_t kSpTltEnc;
-} cmpTltRegMsgEdata_t;
-
-/** TltContRegister encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpTltRegMsgEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltRegMsgEdata_t))];
-} cmpTltRegCmdEd_t;
-
-/** TltContRegister signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
- /** Trustlet public key hash. */
- mcSha256_t skSpTltEnc;
- /** Minimum trustlet version supported. */
- mcContVersion_t tltVersion;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpTltRegCmdEd_t ed;
-} cmpTltRegCmdSdata_t;
-
-/** TltContRegister signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltRegCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContRegisterCmd_t;
-
-/** TltContRegister command. */
-typedef struct {
- /** Command. */
- cmpTltContRegisterCmd_t cmd;
-} cmpCmdTltContRegister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_RSP Response
- * @{ */
-
-/** TltContRegister signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Sp container secure object size. */
- uint32_t soSpContLen;
- /** Sp container secure object. */
- mcSoSpCont_t soSpCont;
- /** Tlt container secure object size. */
- uint32_t soTltContLen;
- /** Tlt container secure object. */
- mcSoTltCont_2_1_t soTltCont;
-} cmpTltRegRspSdata_t;
-
-/** TltContRegister signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltRegRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContRegisterRsp_t;
-
-/** TltContRegister response. */
-typedef struct {
- /** Response. */
- cmpTltContRegisterRsp_t rsp;
-} cmpRspTltContRegister_t;
-
-/** @} */
-
-/** Map CMP TltContRegister message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdTltContRegister_t cmpCmdTltContRegister;
- /** Map CMP response. */
- cmpRspTltContRegister_t cmpRspTltContRegister;
-} cmpMapTltContRegister_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE \
- MC_CMP_CMD_TLT_CONT_ACTIVATE
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_CMD Command
- * @{ */
-
-/** TltContActivate signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
-} cmpTltActCmdSdata_t;
-
-/** TltContActivate signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltActCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContActivateCmd_t;
-
-/** TltContActivate command. */
-typedef struct {
- /** Command. */
- cmpTltContActivateCmd_t cmd;
-} cmpCmdTltContActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_RSP Response
- * @{ */
-
-/** TltContActivate signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Tlt container secure object size. */
- uint32_t soTltContLen;
- /** Tlt container secure object. */
- mcSoTltCont_2_1_t soTltCont;
-} cmpTltActRspSdata_t;
-
-/** TltContActivate signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltActRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContActivateRsp_t;
-
-/** TltContActivate response. */
-typedef struct {
- /** Response. */
- cmpTltContActivateRsp_t rsp;
-} cmpRspTltContActivate_t;
-
-/** @} */
-
-/** Map CMP TltContActivate message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdTltContActivate_t cmpCmdTltContActivate;
- /** Map CMP response. */
- cmpRspTltContActivate_t cmpRspTltContActivate;
-} cmpMapTltContActivate_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP \
- MC_CMP_CMD_TLT_CONT_LOCK_BY_SP
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_CMD Command
- * @{ */
-
-/** TltContLockBySp signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
-} cmpTltLockBySpCmdSdata_t;
-
-/** TltContLockBySp signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltLockBySpCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContLockBySpCmd_t;
-
-/** TltContLockBySp command. */
-typedef struct {
- /** Command. */
- cmpTltContLockBySpCmd_t cmd;
-} cmpCmdTltContLockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_RSP Response
- * @{ */
-
-/** TltContLockBySp signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Tlt container secure object size. */
- uint32_t soTltContLen;
- /** Tlt container secure object. */
- mcSoTltCont_2_1_t soTltCont;
-} cmpTltLockBySpRspSdata_t;
-
-/** TltContLockBySp signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltLockBySpRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContLockBySpRsp_t;
-
-/** TltContLockBySp response. */
-typedef struct {
- /** Response. */
- cmpTltContLockBySpRsp_t rsp;
-} cmpRspTltContLockBySp_t;
-
-/** @} */
-
-/** Map CMP TltContLockBySp message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdTltContLockBySp_t cmpCmdTltContLockBySp;
- /** Map CMP response. */
- cmpRspTltContLockBySp_t cmpRspTltContLockBySp;
-} cmpMapTltContLockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP \
- MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_CMD Command
- * @{ */
-
-/** TltContLockBySp signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
-} cmpTltUnlockBySpCmdSdata_t;
-
-/** TltContLockBySp signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltUnlockBySpCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContUnlockBySpCmd_t;
-
-/** TltContUnlockBySp command. */
-typedef struct {
- /** Command. */
- cmpTltContUnlockBySpCmd_t cmd;
-} cmpCmdTltContUnlockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_RSP Response
- * @{ */
-
-/** TltContUnlockBySp signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Tlt container secure object size. */
- uint32_t soTltContLen;
- /** Tlt container secure object. */
- mcSoTltCont_2_1_t soTltCont;
-} cmpTltUnlockBySpRspSdata_t;
-
-/** TltContUnlockBySp signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltUnlockBySpRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContUnlockBySpRsp_t;
-
-/** TltContUnlockBySp response. */
-typedef struct {
- /** Response. */
- cmpTltContUnlockBySpRsp_t rsp;
-} cmpRspTltContUnlockBySp_t;
-
-/** @} */
-
-/** Map CMP TltContUnlockBySp message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdTltContUnlockBySp_t cmpCmdTltContUnlockBySp;
- /** Map CMP response. */
- cmpRspTltContUnlockBySp_t cmpRspTltContUnlockBySp;
-} cmpMapTltContUnlockBySp_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE \
- MC_CMP_CMD_TLT_CONT_PERSONALIZE
- * @{ */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_CMD Command
- * @{ */
-
-/** TltContPersonalize encrypted data command. */
-typedef struct {
- /** Data. */
- mcCoDataCont_t dataCont;
-} cmpTltContPersonalizeCmdEdata_t;
-
-/** TltContPersonalize encrypted and padded data command. */
-typedef struct {
- /** Encrypted data. */
- cmpTltContPersonalizeCmdEdata_t edata;
- /** Padding. */
- uint8_t padding[CMP_ED_PADDING(sizeof(cmpTltContPersonalizeCmdEdata_t))];
-} cmpTltContPersonalizeCmdEd_t;
-
-/** TltContPersonalize signed command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Spid. */
- mcSpid_t spid;
- /** Uuid. */
- mcUuid_t uuid;
- /** Pid. */
- mcPid_t pid;
- /** Encrypted and padded data size. */
- uint32_t edLen;
- /** Encrypted and padded data. */
- cmpTltContPersonalizeCmdEd_t ed;
-} cmpTltContPersonalizeCmdSdata_t;
-
-/** TltContPersonalize signed command and signature. */
-typedef struct {
- /** Signed command. */
- cmpTltContPersonalizeCmdSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContPersonalizeCmd_t;
-
-/** TltContPersonalize command. */
-typedef struct {
- cmpTltContPersonalizeCmd_t cmd;
-} cmpCmdTltContPersonalize_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_RSP Response
- * @{ */
-
-/** TltContPersonalize signed response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
- /** Data container secure object size. */
- uint32_t soDataContLen;
- /** Data container secure object. */
- mcSoDataCont_t soDataCont;
-} cmpTltContPersonalizeRspSdata_t;
-
-/** TltContPersonalize signed response and signature. */
-typedef struct {
- /** Signed response. */
- cmpTltContPersonalizeRspSdata_t sdata;
- /** Signature. */
- cmpMac_t mac;
-} cmpTltContPersonalizeRsp_t;
-
-/** TltContPersonalize response. */
-typedef struct {
- /** Response. */
- cmpTltContPersonalizeRsp_t rsp;
-} cmpRspTltContPersonalize_t;
-
-/** @} */
-
-/** Map CMP TltContPersonalize message. */
-typedef union {
- /** Map CMP command. */
- cmpCmdTltContPersonalize_t cmpCmdTltContPersonalize;
- /** Map CMP response. */
- cmpRspTltContPersonalize_t cmpRspTltContPersonalize;
-} cmpMapTltContPersonalize_t;
-
-/** @} */
-
-/** Map CMP messages. */
-typedef union {
- /** Backward compatible command header. */
- cmpCommandHeader_t commandHeader;
- /** Backward compatible response header. */
- cmpResponseHeader_t responseHeader;
-
- /** Backward compatible system command GetVersion. */
- cmpCmdGetVersion_t cmpCmdGetVersion;
- /** Backward compatible system response GetVersion. */
- cmpRspGetVersion_t cmpRspGetVersion;
- /** Backward compatible system command GetSuid. */
- cmpCmdGetSuid_t cmpCmdGetSuid;
- /** Backward compatible system response GetSuid. */
- cmpRspGetSuid_t cmpRspGetSuid;
- /** Backward compatible system command GenAuthToken. */
- cmpCmdGenAuthToken_t cmpCmdGenAuthToken;
- /** Backward compatible system response GenAuthToken. */
- cmpRspGenAuthToken_t cmpRspGenAuthToken;
- /** Backward compatible system command GenBindingKey. */
- cmpCmdGenBindingKey_t cmpCmdGenBindingKey;
- /** Backward compatible system response GenBindingKey. */
- cmpRspGenBindingKey_t cmpRspGenBindingKey;
-
- /** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
- /** Response header. */
- cmpResponseHeaderMap_t rspHeader;
-
- /** Error signed response. */
- cmpMapError_t cmpMapError;
-
- /** Authentication command BeginSocAuthentication. */
- cmpCmdBeginSocAuthentication_t cmpCmdBeginSocAuthentication;
- /** Authentication response BeginSocAuthentication. */
- cmpRspBeginSocAuthentication_t cmpRspBeginSocAuthentication;
- /** Authentication command BeginRootAuthentication. */
- cmpCmdBeginRootAuthentication_t cmpCmdBeginRootAuthentication;
- /** Authentication response BeginRootAuthentication. */
- cmpRspBeginRootAuthentication_t cmpRspBeginRootAuthentication;
- /** Authentication command BeginSpAuthentication. */
- cmpCmdBeginSpAuthentication_t cmpCmdBeginSpAuthentication;
- /** Authentication response BeginSpAuthentication. */
- cmpRspBeginSpAuthentication_t cmpRspBeginSpAuthentication;
- /** Authentication command Authenticate. */
- cmpCmdAuthenticate_t cmpCmdAuthenticate;
- /** Authentication response Authenticate. */
- cmpRspAuthenticate_t cmpRspAuthenticate;
- /** Authentication command AuthenticateTerminate. */
- cmpCmdAuthenticateTerminate_t cmpCmdAuthenticateTerminate;
- /** Authentication response AuthenticateTerminate. */
- cmpRspAuthenticateTerminate_t cmpRspAuthenticateTerminate;
-
- /** SoC administrative command RootContRegisterActivate. */
- cmpCmdRootContRegisterActivate_t cmpCmdRootContRegisterActivate;
- /** SoC administrative response RootContRegisterActivate. */
- cmpRspRootContRegisterActivate_t cmpRspRootContRegisterActivate;
-
- /** Root administrative command RootContUnregister. */
- cmpCmdRootContUnregister_t cmpCmdRootContUnregister;
- /** Root administrative response RootContUnregister. */
- cmpRspRootContUnregister_t cmpRspRootContUnregister;
- /** Root administrative command RootContLockByRoot. */
- cmpCmdRootContLockByRoot_t cmpCmdRootContLockByRoot;
- /** Root administrative response RootContLockByRoot. */
- cmpRspRootContLockByRoot_t cmpRspRootContLockByRoot;
- /** Root administrative command RootContUnlockByRoot. */
- cmpCmdRootContUnlockByRoot_t cmpCmdRootContUnlockByRoot;
- /** Root administrative response RootContUnlockByRoot. */
- cmpRspRootContUnlockByRoot_t cmpRspRootContUnlockByRoot;
- /** Root administrative command SpContRegisterActivate. */
- cmpCmdSpContRegisterActivate_t cmpCmdSpContRegisterActivate;
- /** Root administrative response SpContRegisterActivate. */
- cmpRspSpContRegisterActivate_t cmpRspSpContRegisterActivate;
- /** Root administrative command SpContUnregister. */
- cmpCmdSpContUnregister_t cmpCmdSpContUnregister;
- /** Root administrative response SpContUnregister. */
- cmpRspSpContUnregister_t cmpRspSpContUnregister;
- /** Root administrative command SpContRegister. */
- cmpCmdSpContRegister_t cmpCmdSpContRegister;
- /** Root administrative response SpContRegister. */
- cmpRspSpContRegister_t cmpRspSpContRegister;
- /** Root administrative command SpContLockByRoot. */
- cmpCmdSpContLockByRoot_t cmpCmdSpContLockByRoot;
- /** Root administrative response SpContLockByRoot. */
- cmpRspSpContLockByRoot_t cmpRspSpContLockByRoot;
- /** Root administrative command SpContUnlockByRoot. */
- cmpCmdSpContUnlockByRoot_t cmpCmdSpContUnlockByRoot;
- /** Root administrative response SpContUnlockByRoot. */
- cmpRspSpContUnlockByRoot_t cmpRspSpContUnlockByRoot;
-
- /** Sp administrative command SpContActivate. */
- cmpCmdSpContActivate_t cmpCmdSpContActivate;
- /** Sp administrative response SpContActivate. */
- cmpRspSpContActivate_t cmpRspSpContActivate;
- /** Sp administrative command SpContLockBySp. */
- cmpCmdSpContLockBySp_t cmpCmdSpContLockBySp;
- /** Sp administrative response SpContLockBySp. */
- cmpRspSpContLockBySp_t cmpRspSpContLockBySp;
- /** Sp administrative command SpContUnlockBySp. */
- cmpCmdSpContUnlockBySp_t cmpCmdSpContUnlockBySp;
- /** Sp administrative response SpContUnlockBySp. */
- cmpRspSpContUnlockBySp_t cmpRspSpContUnlockBySp;
- /** Sp administrative command TltContRegisterActivate. */
- cmpCmdTltContRegisterActivate_t cmpCmdTltContRegisterActivate;
- /** Sp administrative response TltContRegisterActivate. */
- cmpRspTltContRegisterActivate_t cmpRspTltContRegisterActivate;
- /** Sp administrative command TltContUnregister. */
- cmpCmdTltContUnregister_t cmpCmdTltContUnregister;
- /** Sp administrative response TltContUnregister. */
- cmpRspTltContUnregister_t cmpRspTltContUnregister;
- /** Sp administrative command TltContRegister. */
- cmpCmdTltContRegister_t cmpCmdTltContRegister;
- /** Sp administrative response TltContRegister. */
- cmpRspTltContRegister_t cmpRspTltContRegister;
- /** Sp administrative command TltContActivate. */
- cmpCmdTltContActivate_t cmpCmdTltContActivate;
- /** Sp administrative response TltContActivate. */
- cmpRspTltContActivate_t cmpRspTltContActivate;
- /** Sp administrative command TltContLockBySp. */
- cmpCmdTltContLockBySp_t cmpCmdTltContLockBySp;
- /** Sp administrative response TltContLockBySp. */
- cmpRspTltContLockBySp_t cmpRspTltContLockBySp;
- /** Sp administrative command TltContUnlockBySp. */
- cmpCmdTltContUnlockBySp_t cmpCmdTltContUnlockBySp;
- /** Sp administrative response TltContUnlockBySp. */
- cmpRspTltContUnlockBySp_t cmpRspTltContUnlockBySp;
- /** Sp administrative command TltContPersonalize. */
- cmpCmdTltContPersonalize_t cmpCmdTltContPersonalize;
- /** Sp administrative response TltContPersonalize. */
- cmpRspTltContPersonalize_t cmpRspTltContPersonalize;
-} cmpMap_t;
-
-#endif // CMP_MAP_H_
-
-/** @} */
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup CMP
- * @{
- * @file
- * Interface to content management trustlet (TlCm) definitions.
- *
- * The TlCm is responsible for implementing content management protocol (CMP)
- * commands and generating approriate CMP responses in the trustlet control
- * interface (TCI).
- */
-
-#ifndef TL_CM_API_H_
-#define TL_CM_API_H_
-
-#include "TlCm/tlCmApiCommon.h"
-#include "TlCm/3.0/cmp.h"
-#include "TlCm/3.0/cmpMap.h"
-
-/** TCI CMP messages. */
-typedef union {
- /** Command header. */
- cmpCommandHeaderTci_t commandHeader;
- /** Response header. */
- cmpResponseHeaderTci_t responseHeader;
-
- /** System command GetVersion. */
- cmpCmdGetVersionTci_t cmpCmdGetVersionTci;
- /** System response GetVersion. */
- cmpRspGetVersionTci_t cmpRspGetVersionTci;
- /** System command GetSuid. */
- cmpCmdGetSuidTci_t cmpCmdGetSuidTci;
- /** System response GetSuid. */
- cmpRspGetSuidTci_t cmpRspGetSuidTci;
- /** System command GenAuthToken. */
- cmpCmdGenAuthTokenTci_t cmpCmdGenAuthTokenTci;
- /** System response GenAuthToken. */
- cmpRspGenAuthTokenTci_t cmpRspGenAuthTokenTci;
- /** System command GenBindingKey. */
- cmpCmdGenBindingKeyTci_t cmpCmdGenBindingKeyTci;
- /** System response GenBindingKey. */
- cmpRspGenBindingKeyTci_t cmpRspGenBindingKeyTci;
-
- /** Authentication command BeginSocAuthentication. */
- cmpCmdBeginSocAuthenticationTci_t cmpCmdBeginSocAuthenticationTci;
- /** Authentication response BeginSocAuthentication. */
- cmpRspBeginSocAuthenticationTci_t cmpRspBeginSocAuthenticationTci;
- /** Authentication command BeginRootAuthentication. */
- cmpCmdBeginRootAuthenticationTci_t cmpCmdBeginRootAuthenticationTci;
- /** Authentication response BeginRootAuthentication. */
- cmpRspBeginRootAuthenticationTci_t cmpRspBeginRootAuthenticationTci;
- /** Authentication command BeginSpAuthentication. */
- cmpCmdBeginSpAuthenticationTci_t cmpCmdBeginSpAuthenticationTci;
- /** Authentication response BeginSpAuthentication. */
- cmpRspBeginSpAuthenticationTci_t cmpRspBeginSpAuthenticationTci;
- /** Authentication command Authenticate. */
- cmpCmdAuthenticateTci_t cmpCmdAuthenticateTci;
- /** Authentication response Authenticate. */
- cmpRspAuthenticateTci_t cmpRspAuthenticateTci;
- /** Authentication command AuthenticateTerminate. */
- cmpCmdAuthenticateTerminateTci_t cmpCmdAuthenticateTerminateTci;
- /** Authentication response AuthenticateTerminate. */
- cmpRspAuthenticateTerminateTci_t cmpRspAuthenticateTerminateTci;
-
- /** SoC administrative command RootContRegisterActivate. */
- cmpCmdRootContRegisterActivateTci_t cmpCmdRootContRegisterActivateTci;
- /** SoC administrative response RootContRegisterActivate. */
- cmpRspRootContRegisterActivateTci_t cmpRspRootContRegisterActivateTci;
-
- /** Root administrative command RootContUnregister. */
- cmpCmdRootContUnregisterTci_t cmpCmdRootContUnregisterTci;
- /** Root administrative response RootContUnregister. */
- cmpRspRootContUnregisterTci_t cmpRspRootContUnregisterTci;
- /** Root administrative command RootContLockByRoot. */
- cmpCmdRootContLockByRootTci_t cmpCmdRootContLockByRootTci;
- /** Root administrative response RootContLockByRoot. */
- cmpRspRootContLockByRootTci_t cmpRspRootContLockByRootTci;
- /** Root administrative command RootContUnlockByRoot. */
- cmpCmdRootContUnlockByRootTci_t cmpCmdRootContUnlockByRootTci;
- /** Root administrative command RootContUnlockByRoot. */
- cmpRspRootContUnlockByRootTci_t cmpRspRootContUnlockByRootTci;
- /** Root administrative command SpContRegisterActivate. */
- cmpCmdSpContRegisterActivateTci_t cmpCmdSpContRegisterActivateTci;
- /** Root administrative response SpContRegisterActivate. */
- cmpRspSpContRegisterActivateTci_t cmpRspSpContRegisterActivateTci;
- /** Root administrative command SpContUnregister. */
- cmpCmdSpContUnregisterTci_t cmpCmdSpContUnregisterTci;
- /** Root administrative response SpContUnregister. */
- cmpRspSpContUnregisterTci_t cmpRspSpContUnregisterTci;
- /** Root administrative command SpContRegister. */
- cmpCmdSpContRegisterTci_t cmpCmdSpContRegisterTci;
- /** Root administrative response SpContRegister. */
- cmpRspSpContRegisterTci_t cmpRspSpContRegisterTci;
- /** Root administrative command SpContLockByRoot. */
- cmpCmdSpContLockByRootTci_t cmpCmdSpContLockByRootTci;
- /** Root administrative response SpContLockByRoot. */
- cmpRspSpContLockByRootTci_t cmpRspSpContLockByRootTci;
- /** Root administrative command SpContUnlockByRoot. */
- cmpCmdSpContUnlockByRootTci_t cmpCmdSpContUnlockByRootTci;
- /** Root administrative response SpContUnlockByRoot. */
- cmpRspSpContUnlockByRootTci_t cmpRspSpContUnlockByRootTci;
-
- /** Sp administrative command SpContActivate. */
- cmpCmdSpContActivateTci_t cmpCmdSpContActivateTci;
- /** Sp administrative response SpContActivate. */
- cmpRspSpContActivateTci_t cmpRspSpContActivateTci;
- /** Sp administrative command SpContLockBySp. */
- cmpCmdSpContLockBySpTci_t cmpCmdSpContLockBySpTci;
- /** Sp administrative response SpContLockBySp. */
- cmpRspSpContLockBySpTci_t cmpRspSpContLockBySpTci;
- /** Sp administrative command SpContUnlockBySp. */
- cmpCmdSpContUnlockBySpTci_t cmpCmdSpContUnlockBySpTci;
- /** Sp administrative command SpContUnlockBySp. */
- cmpRspSpContUnlockBySpTci_t cmpRspSpContUnlockBySpTci;
- /** Sp administrative command TltContRegisterActivate. */
- cmpCmdTltContRegisterActivateTci_t cmpCmdTltContRegisterActivateTci;
- /** Sp administrative response TltContRegisterActivate. */
- cmpRspTltContRegisterActivateTci_t cmpRspTltContRegisterActivateTci;
- /** Sp administrative command TltContUnregister. */
- cmpCmdTltContUnregisterTci_t cmpCmdTltContUnregisterTci;
- /** Sp administrative response TltContUnregister. */
- cmpRspTltContUnregisterTci_t cmpRspTltContUnregisterTci;
- /** Sp administrative command TltContRegister. */
- cmpCmdTltContRegisterTci_t cmpCmdTltContRegisterTci;
- /** Sp administrative command TltContRegister. */
- cmpRspTltContRegisterTci_t cmpRspTltContRegisterTci;
- /** Sp administrative command TltContActivate. */
- cmpCmdTltContActivateTci_t cmpCmdTltContActivateTci;
- /** Sp administrative command TltContActivate. */
- cmpRspTltContActivateTci_t cmpRspTltContActivateTci;
- /** Sp administrative command TltContLockBySp. */
- cmpCmdTltContLockBySpTci_t cmpCmdTltContLockBySpTci;
- /** Sp administrative response TltContLockBySp. */
- cmpRspTltContLockBySpTci_t cmpRspTltContLockBySpTci;
- /** Sp administrative command TltContUnlockBySp. */
- cmpCmdTltContUnlockBySpTci_t cmpCmdTltContUnlockBySpTci;
- /** Sp administrative response TltContUnlockBySp. */
- cmpRspTltContUnlockBySpTci_t cmpRspTltContUnlockBySpTci;
- /** Sp administrative command TltContPersonalize. */
- cmpCmdTltContPersonalizeTci_t cmpCmdTltContPersonalizeTci;
- /** Sp administrative response TltContPersonalize. */
- cmpRspTltContPersonalizeTci_t cmpRspTltContPersonalizeTci;
-} cmpMessage_t;
-
-/** TCI CMP. */
-typedef struct {
- /** TCI CMP messages. */
- cmpMessage_t msg;
-} cmp_t;
-
-#endif // TL_CM_API_H_
-
-/** @} */
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup CMP_COMMON
- * Common definitions of content management protocols (CMP) supported by the
- * content management trustlet (TlCm).
- *
- * @{
- *
- * @file
- * Common CMP global definitions.
- * Various components need access to (sub-)structures defined and used by CMP.
- * These common definitions are made available through this header file.
- */
-
-#ifndef CMP_COMMON_H_
-#define CMP_COMMON_H_
-
-#include "mcContainer.h"
-#include "mcUuid.h"
-#include "mcVersionInfo.h"
-#include "version.h"
-
-/** Minimum TCI CMP 2.0 size. */
-#define CMP_SIZE 4388
-
-/** Default CMP MAP size. */
-#define CMP_MAP_SIZE 2412
-
-/** CMP version id. */
-typedef uint32_t cmpVersionId_t;
-/** CMP command id. */
-typedef uint32_t cmpCommandId_t;
-/** CMP response id. */
-typedef uint32_t cmpResponseId_t;
-/** CMP return code. */
-typedef uint32_t cmpReturnCode_t;
-
-/** Responses have bit 31 set */
-#define RSP_ID_MASK (1U << 31)
-#define RSP_ID(cmdId) (((uint32_t)(cmdId)) | RSP_ID_MASK)
-#define IS_CMD(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == 0)
-#define IS_RSP(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == RSP_ID_MASK)
-
-/** CMP command header. */
-typedef struct {
- /** Command id. */
- cmpCommandId_t commandId;
-} cmpCommandHeader_t;
-
-/** CMP response header. */
-typedef struct {
- /** Response id (must be command id | RSP_ID_MASK ). */
- cmpResponseId_t responseId;
- /** Return code. */
- cmpReturnCode_t returnCode;
-} cmpResponseHeader_t;
-
-/** Total number of bytes used for HMAC-SHA256 message authentication code. */
-#define CMP_MAC_SIZE 32
-
-/** Message authentication code. */
-typedef struct {
- /** MAC value. */
- uint8_t mac[CMP_MAC_SIZE];
-} cmpMac_t;
-
-/** 64-bit random number. */
-typedef struct {
- /** Random number value. */
- uint8_t data[8];
-} cmpRnd8_t;
-
-/** 256-bit random number. */
-typedef struct {
- /** Random number value. */
- uint8_t data[32];
-} cmpRnd32_t;
-
-/** @defgroup MC_CMP_CMD_GET_VERSION MC_CMP_CMD_GET_VERSION
- * @{ */
-
-/** Version tags. */
-typedef enum {
- /** Version tag deprecated. */
- CMP_VERSION_TAG1 = 0x00000001,
- /** Version tag. */
- CMP_VERSION_TAG2 = 0x00000002,
-} cmpVersionTag_t;
-
-/** Version data info for deprecated version tag. */
-typedef struct {
- /** Version data value. */
- cmpVersionId_t number;
-} cmpVersionData1_t;
-
-/** Version data info. */
-typedef struct {
- /** Version data value. */
- mcVersionInfo_t versionInfo;
-} cmpVersionData2_t;
-
-/** Version data infos. */
-typedef union {
- /** Version data info deprecated. */
- cmpVersionData1_t versionData1;
- /** Version data info. */
- cmpVersionData2_t versionData2;
-} cmpVersionData_t;
-
-/** @defgroup MC_CMP_CMD_GET_VERSION_CMD Command
- * @{ */
-
-/** GetVersion command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
-} cmpCmdGetVersion_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GET_VERSION_RSP Response
- * @{ */
-
-/** GetVersion response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Version tag. */
- cmpVersionTag_t tag;
- /** Version data info. */
- cmpVersionData_t data;
-} cmpRspGetVersion_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GET_SUID MC_CMP_CMD_GET_SUID
- * @{ */
-
-/** @defgroup MC_CMP_CMD_GET_SUID_CMD Command
- * @{ */
-
-/** GetSuid command. */
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
-} cmpCmdGetSuid_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GET_SUID_RSP Response
- * @{ */
-
-/** GetSuid response. */
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Suid. */
- mcSuid_t suid;
-} cmpRspGetSuid_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN MC_CMP_CMD_GENERATE_AUTH_TOKEN
- * @{ */
-
-/** Block size of the encryption algorithm used for secure messaging. */
-#define CMP_MSG_CRYPTO_BLOCK_SIZE 16
-
-/** Total number of padding bytes required to encrypt data of given size. */
-#define CMP_ED_PADDING(netsize) \
- (CMP_MSG_CRYPTO_BLOCK_SIZE - (netsize) % CMP_MSG_CRYPTO_BLOCK_SIZE)
-
-/** Total number of bytes used for PSS signature in GENERATE AUTH TOKEN command. */
-#define CMP_GEN_AUTH_TOKEN_PSS_SIZE 256
-
-/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_CMD Command
- * @{ */
-
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Suid. */
- mcSuid_t suid;
- /** Authentication key. */
- mcSymmetricKey_t kSocAuth;
- /** Key id. */
- uint32_t kid;
-} cmpGenAuthTokenCmdSdata_t;
-
-typedef struct {
- /** Signed data. */
- cmpGenAuthTokenCmdSdata_t sdata;
- /** Signature. */
- uint8_t pssSignature[CMP_GEN_AUTH_TOKEN_PSS_SIZE];
-} cmpGenAuthTokenCmd_t;
-
-/** GenAuthToken command. */
-typedef struct {
- /** Command. */
- cmpGenAuthTokenCmd_t cmd;
-} cmpCmdGenAuthToken_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_RSP Response
- * @{ */
-
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
-} cmpGenAuthTokenRsp_t;
-
-/** GenAuthToken response. */
-typedef struct {
- /** Response. */
- cmpGenAuthTokenRsp_t rsp;
- /** AuthToken container. */
- mcSoAuthTokenCont_t soAuthCont;
-} cmpRspGenAuthToken_t;
-
-/** @} */
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GENERATE_BINDING_KEY MC_CMP_CMD_GENERATE_BINDING_KEY
- * @{ */
-
-/** Total number of bytes used for PSS signature in GENERATE BINDING KEY command. */
-#define CMP_GEN_BINDING_KEY_PSS_SIZE 256
-
-/** Total number of bytes used for receipt data in GENERATE BINDING KEY response. */
-#define CMP_GEN_BINDING_RECEIPT_ENC_PART_SIZE 256
-
-/** Maximum Length in bytes for the entropy input */
-#define CMP_GEN_BINDING_KEY_ENTROPY_SIZE_MAX (56)
-
-/** @defgroup MC_CMP_CMD_GENERATE_BINDING_KEY_CMD Command
- * @{ */
-
-typedef struct {
- /** Command header. */
- cmpCommandHeader_t cmdHeader;
- /** Key id. */
- uint32_t kid;
-} cmpGenBindingKeyCmdSdata_t;
-
-typedef struct {
- /** Signed data. */
- cmpGenBindingKeyCmdSdata_t sdata;
- /** Signature. */
- uint8_t pssSignature[CMP_GEN_BINDING_KEY_PSS_SIZE];
- /** Production Station Serial Number. */
- uint64_t serialNumber;
- /** Timestamp (seconds since epoch). */
- uint64_t timestamp;
- /** Additional entropy length in bytes. */
- uint16_t entropyLen;
- /** Additional entropy for K.SoC.Auth generation */
- uint8_t entropy[CMP_GEN_BINDING_KEY_ENTROPY_SIZE_MAX];
-} cmpCmdGenBindingKeyCmd_t;
-
-/** GenBindingKey command. */
-typedef struct {
- /** Command. */
- cmpCmdGenBindingKeyCmd_t cmd;
-} cmpCmdGenBindingKey_t;
-
-/** @} */
-
-/** @defgroup MC_CMP_CMD_GENERATE_BINDING_KEY_RSP Response
- * @{ */
-
-/** Receipt Data. */
-typedef struct {
- uint8_t dataPart1[CMP_GEN_BINDING_RECEIPT_ENC_PART_SIZE];
- uint8_t dataPart2[CMP_GEN_BINDING_RECEIPT_ENC_PART_SIZE];
-} receipt_t;
-
-typedef struct {
- /** Response header. */
- cmpResponseHeader_t rspHeader;
- /** Suid. */
- mcSuid_t suid;
- /**Receipt data. */
- receipt_t receipt;
-} cmpGenBindingKeyRsp_t;
-
-/** GenBindingKey response. */
-typedef struct {
- /** Response. */
- cmpGenBindingKeyRsp_t rsp;
- /** AuthToken container. */
- mcSoAuthTokenCont_t soAuthCont;
-} cmpRspGenBindingKey_t;
-
-/** @} */
-
-/** @} */
-
-#endif // CMP_COMMON_H_
-
-/** @} */
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup CMP_COMMON
- * @{
- * @file
- * Common interface definitions to content management trustlet (TlCm).
- *
- * The TlCm is responsible for implementing content management protocol (CMP)
- * commands and generating approriate CMP responses.
- */
-
-#ifndef TL_CM_API_COMMON_H_
-#define TL_CM_API_COMMON_H_
-
-#include "tlCmError.h"
-
-/** TlCm command ids supported.
- * @note All command ids must be in range 0 to 0x1D.
- */
-//lint -esym(756, cmpCommands_t) cmpCommands_t type by itself not used.
-typedef enum cmpCommands_t {
- MC_CMP_CMD_AUTHENTICATE = 0,
- MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION = 1,
- MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION = 2,
- MC_CMP_CMD_BEGIN_SP_AUTHENTICATION = 3,
- MC_CMP_CMD_GENERATE_AUTH_TOKEN = 4,
- MC_CMP_CMD_GET_VERSION = 5,
- MC_CMP_CMD_GENERATE_BINDING_KEY = 0x30,
- //MC_CMP_CMD_ROOT_CONT_ACTIVATE = 6,
- MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT = 7,
- //MC_CMP_CMD_ROOT_CONT_REGISTER = 8,
- MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE = 9,
- MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT = 10,
- MC_CMP_CMD_ROOT_CONT_UNREGISTER = 11,
- MC_CMP_CMD_SP_CONT_ACTIVATE = 12,
- MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT = 13,
- MC_CMP_CMD_SP_CONT_LOCK_BY_SP = 14,
- MC_CMP_CMD_SP_CONT_REGISTER = 15,
- MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE = 16,
- MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT = 17,
- MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP = 18,
- MC_CMP_CMD_SP_CONT_UNREGISTER = 19,
- MC_CMP_CMD_TLT_CONT_ACTIVATE = 20,
- MC_CMP_CMD_TLT_CONT_LOCK_BY_SP = 21,
- MC_CMP_CMD_TLT_CONT_PERSONALIZE = 22,
- MC_CMP_CMD_TLT_CONT_REGISTER = 23,
- MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE = 24,
- MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP = 25,
- MC_CMP_CMD_TLT_CONT_UNREGISTER = 26,
- MC_CMP_CMD_GET_SUID = 27,
- MC_CMP_CMD_AUTHENTICATE_TERMINATE = 28,
- MC_CMP_CMD_LAST_ = MC_CMP_CMD_GENERATE_BINDING_KEY,
-} cmpCommands_t;
-
-/** TlCm exit code: TlCm exited with error. */
-#define EXIT_ERROR ((uint32_t)(-1))
-
-#endif // TL_CM_API_COMMON_H_
-
-/** @} */
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup CMP_COMMON
- * @{
- *
- * @file
- * Content management trustlet (TlCm) error return code definitions.
- * Definition of all possible TlCm error return codes.
- */
-
-#ifndef TL_CM_ERROR_H_
-#define TL_CM_ERROR_H_
-
-/** No error. */
-#define SUCCESSFUL 0x00000000
-
-/** Error unknown command. */
-#define RET_ERR_EXT_UNKNOWN_COMMAND 0xE0000000
-/** Error security status not satified. */
-#define RET_ERR_EXT_SECURITY_STATUS_NOT_SATISFIED 0xE0000010
-/** Error secure messaging failed. */
-#define RET_ERR_EXT_SECURE_MESSAGING_FAILED 0xE0000020
-/** Error incorrect parameters. */
-#define RET_ERR_EXT_INCORRECT_PARAMETERS 0xE0000030
-/** Error referenced data invalid. */
-#define RET_ERR_EXT_REFERENCED_DATA_INVALID 0xE0000040
-/** Error referenced data not found. */
-#define RET_ERR_EXT_REFERENCED_DATA_NOT_FOUND 0xE0000050
-/** Error method blocked. */
-#define RET_ERR_EXT_METHOD_BLOCKED 0xE0000060
-/** Error conditions of use not satified. */
-#define RET_ERR_EXT_CONDITIONS_OF_USE_NOT_SATISFIED 0xE0000070
-/** Error container already registred error. */
-#define RET_ERR_EXT_ALREADY_REGISTERED 0xE0000090
-/** Error container already activated. */
-#define RET_ERR_EXT_ALREADY_ACTIVATED 0xE00000A0
-/** Error container not registred. */
-#define RET_ERR_EXT_NOT_REGISTERED 0xE00000B0
-/** Error container not activated. */
-#define RET_ERR_EXT_NOT_ACTIVATED 0xE00000C0
-/** Error container full. */
-#define RET_ERR_EXT_CONTAINER_FULL 0xE00000D0
-/** Error container not locked. */
-#define RET_ERR_EXT_NOT_LOCKED 0xE00000E0
-/** Error container locked. */
-#define RET_ERR_EXT_LOCKED 0xE00000F0
-/** Error container already locked. */
-#define RET_ERR_EXT_ALREADY_LOCKED 0xE0000100
-
-/** Internal error. */
-#define RET_ERR_EXT_INTERNAL_ERROR 0xE0001000
-/** Mapped allocation size error. */
-#define RET_ERR_EXT_SIZE 0xE0002000
-
-/** Unspecified error. */
-#define RET_ERR_EXT_UNSPECIFIED 0xEEEEEEEE
-
-#endif // TL_CM_ERROR_H_
-
-/** @} */
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup CMP_COMMON
- * @{
- * @file
- * Content management trustlet (TlCm) Uuid definition.
- */
-
-#ifndef TL_CM_UUID_H
-#define TL_CM_UUID_H
-
-/** Uuid of TlCm. */
-#define TL_CM_UUID { { 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
-
-#endif // TL_CM_UUID_H
-
-/** @} */
+++ /dev/null
-/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup CMP_COMMON
- * @{
- * @file
- * Content management trustlet (TlCm) version definition.
- */
-
-#ifndef CMP_VERSION_H_
-#define CMP_VERSION_H_
-
-/** Latest supported CMP major version number. */
-#define CMP_VERSION_MAJOR 3
-/** Latest supported CMP minor version number. */
-#define CMP_VERSION_MINOR 0
-
-#endif // CMP_VERSION_H_
-
-/** @} */
+++ /dev/null
-a548519579b1a7cddb06c56989fd01f8 *-