summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mobicore/Android.mk23
-rw-r--r--mobicore/CleanSpec.mk61
-rw-r--r--mobicore/MODULE_LICENSE_BSD0
-rw-r--r--mobicore/MobiCoreDriverLib/Android.mk (renamed from mobicore/daemon/Android.mk)80
-rw-r--r--mobicore/MobiCoreDriverLib/Application.mk (renamed from mobicore/daemon/Application.mk)7
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/Android.mk (renamed from mobicore/daemon/ClientLib/Android.mk)0
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/ClientLib.cpp (renamed from mobicore/daemon/ClientLib/ClientLib.cpp)116
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/Device.cpp (renamed from mobicore/daemon/ClientLib/Device.cpp)34
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/Device.h (renamed from mobicore/daemon/ClientLib/Device.h)17
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/GP/tee_client_api.cpp (renamed from mobicore/daemon/ClientLib/GP/tee_client_api.cpp)91
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/Session.cpp (renamed from mobicore/daemon/ClientLib/Session.cpp)15
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/Session.h (renamed from mobicore/daemon/ClientLib/Session.h)13
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_client_api.h (renamed from mobicore/daemon/ClientLib/public/GP/tee_client_api.h)0
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_client_api_imp.h (renamed from mobicore/daemon/ClientLib/public/GP/tee_client_api_imp.h)0
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_error.h131
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_type.h (renamed from mobicore/daemon/ClientLib/public/GP/tee_type.h)83
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/public/GP/uuid_attestation.h (renamed from mobicore/daemon/ClientLib/public/GP/uuid_attestation.h)36
-rw-r--r--mobicore/MobiCoreDriverLib/ClientLib/public/MobiCoreDriverApi.h (renamed from mobicore/daemon/ClientLib/public/MobiCoreDriverApi.h)105
-rw-r--r--mobicore/MobiCoreDriverLib/Common/Android.mk (renamed from mobicore/daemon/Common/Android.mk)8
-rw-r--r--mobicore/MobiCoreDriverLib/Common/CMutex.cpp (renamed from mobicore/daemon/Common/CMutex.cpp)11
-rw-r--r--mobicore/MobiCoreDriverLib/Common/CMutex.h (renamed from mobicore/daemon/Common/CMutex.h)11
-rw-r--r--mobicore/MobiCoreDriverLib/Common/CSemaphore.cpp (renamed from mobicore/daemon/Common/CSemaphore.cpp)11
-rw-r--r--mobicore/MobiCoreDriverLib/Common/CSemaphore.h (renamed from mobicore/daemon/Common/CSemaphore.h)11
-rw-r--r--mobicore/MobiCoreDriverLib/Common/CThread.cpp (renamed from mobicore/daemon/Common/CThread.cpp)15
-rw-r--r--mobicore/MobiCoreDriverLib/Common/CThread.h (renamed from mobicore/daemon/Common/CThread.h)11
-rw-r--r--mobicore/MobiCoreDriverLib/Common/CWsm.h (renamed from mobicore/daemon/Common/CWsm.h)15
-rw-r--r--mobicore/MobiCoreDriverLib/Common/Connection.cpp (renamed from mobicore/daemon/Common/Connection.cpp)44
-rw-r--r--mobicore/MobiCoreDriverLib/Common/Connection.h (renamed from mobicore/daemon/Common/Connection.h)17
-rw-r--r--mobicore/MobiCoreDriverLib/Common/McTypes.h (renamed from mobicore/daemon/Common/McTypes.h)11
-rw-r--r--mobicore/MobiCoreDriverLib/Common/NOTICE30
-rw-r--r--mobicore/MobiCoreDriverLib/Common/NetlinkConnection.cpp (renamed from mobicore/daemon/Common/NetlinkConnection.cpp)34
-rw-r--r--mobicore/MobiCoreDriverLib/Common/NetlinkConnection.h (renamed from mobicore/daemon/Common/NetlinkConnection.h)17
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Android.mk (renamed from mobicore/daemon/Daemon/Android.mk)0
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/Android.mk (renamed from mobicore/daemon/Daemon/Device/Android.mk)2
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/DeviceIrqHandler.cpp (renamed from mobicore/daemon/Daemon/Device/DeviceIrqHandler.cpp)8
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/DeviceIrqHandler.h (renamed from mobicore/daemon/Daemon/Device/DeviceIrqHandler.h)11
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/DeviceScheduler.cpp (renamed from mobicore/daemon/Daemon/Device/DeviceScheduler.cpp)8
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/DeviceScheduler.h (renamed from mobicore/daemon/Daemon/Device/DeviceScheduler.h)12
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/MobiCoreDevice.cpp (renamed from mobicore/daemon/Daemon/Device/MobiCoreDevice.cpp)205
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/NotificationQueue.cpp (renamed from mobicore/daemon/Daemon/Device/NotificationQueue.cpp)7
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/NotificationQueue.h (renamed from mobicore/daemon/Daemon/Device/NotificationQueue.h)11
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Android.mk (renamed from mobicore/daemon/Daemon/Device/Platforms/Android.mk)0
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Generic/Android.mk (renamed from mobicore/daemon/Daemon/Device/Platforms/Generic/Android.mk)0
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Generic/TrustZoneDevice.cpp (renamed from mobicore/daemon/Daemon/Device/Platforms/Generic/TrustZoneDevice.cpp)195
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Generic/TrustZoneDevice.h (renamed from mobicore/daemon/Daemon/Device/Platforms/Generic/TrustZoneDevice.h)20
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/TAExitHandler.cpp (renamed from mobicore/daemon/Daemon/Device/TAExitHandler.cpp)8
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/TAExitHandler.h (renamed from mobicore/daemon/Daemon/Device/TAExitHandler.h)13
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/TrustletSession.cpp (renamed from mobicore/daemon/Daemon/Device/TrustletSession.cpp)9
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/TrustletSession.h (renamed from mobicore/daemon/Daemon/Device/TrustletSession.h)6
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Device/public/MobiCoreDevice.h (renamed from mobicore/daemon/Daemon/Device/public/MobiCoreDevice.h)26
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/FSD/Android.mk (renamed from mobicore/daemon/Daemon/FSD/Android.mk)4
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/FSD/FSD.cpp (renamed from mobicore/daemon/Daemon/FSD/FSD.cpp)426
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/FSD/public/FSD.h (renamed from mobicore/daemon/Daemon/FSD/public/FSD.h)16
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/FSD/public/dci.h77
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/FSD/public/drSecureStorage_Api.h (renamed from mobicore/common/DrSecureStorage/drSecureStorage_Api.h)36
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/MobiCoreDriverDaemon.cpp (renamed from mobicore/daemon/Daemon/MobiCoreDriverDaemon.cpp)301
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/MobiCoreDriverDaemon.h (renamed from mobicore/daemon/Daemon/MobiCoreDriverDaemon.h)21
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Server/Android.mk (renamed from mobicore/daemon/Daemon/Server/Android.mk)0
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Server/NetlinkServer.cpp (renamed from mobicore/daemon/Daemon/Server/NetlinkServer.cpp)16
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Server/Server.cpp (renamed from mobicore/daemon/Daemon/Server/Server.cpp)40
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Server/public/ConnectionHandler.h (renamed from mobicore/daemon/Daemon/Server/public/ConnectionHandler.h)12
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Server/public/NetlinkServer.h (renamed from mobicore/daemon/Daemon/Server/public/NetlinkServer.h)20
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/Server/public/Server.h (renamed from mobicore/daemon/Daemon/Server/public/Server.h)20
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/public/MobiCoreDriverCmd.h (renamed from mobicore/daemon/Daemon/public/MobiCoreDriverCmd.h)7
-rw-r--r--mobicore/MobiCoreDriverLib/Daemon/public/mcVersion.h (renamed from mobicore/daemon/Daemon/public/mcVersion.h)3
-rw-r--r--mobicore/MobiCoreDriverLib/Kernel/Android.mk (renamed from mobicore/daemon/Kernel/Android.mk)0
-rw-r--r--mobicore/MobiCoreDriverLib/Kernel/CKMod.cpp (renamed from mobicore/daemon/Kernel/CKMod.cpp)13
-rw-r--r--mobicore/MobiCoreDriverLib/Kernel/CKMod.h (renamed from mobicore/daemon/Kernel/CKMod.h)11
-rw-r--r--mobicore/MobiCoreDriverLib/Kernel/Platforms/Generic/Android.mk (renamed from mobicore/daemon/Kernel/Platforms/Generic/Android.mk)0
-rw-r--r--mobicore/MobiCoreDriverLib/Kernel/Platforms/Generic/CMcKMod.cpp (renamed from mobicore/daemon/Kernel/Platforms/Generic/CMcKMod.cpp)66
-rw-r--r--mobicore/MobiCoreDriverLib/Kernel/Platforms/Generic/CMcKMod.h (renamed from mobicore/daemon/Kernel/Platforms/Generic/CMcKMod.h)28
-rw-r--r--mobicore/MobiCoreDriverLib/NOTICE30
-rw-r--r--mobicore/MobiCoreDriverLib/Registry/Android.mk (renamed from mobicore/daemon/Registry/Android.mk)0
-rw-r--r--mobicore/MobiCoreDriverLib/Registry/PrivateRegistry.cpp (renamed from mobicore/daemon/Registry/PrivateRegistry.cpp)503
-rw-r--r--mobicore/MobiCoreDriverLib/Registry/PrivateRegistry.h (renamed from mobicore/daemon/Registry/PrivateRegistry.h)19
-rw-r--r--mobicore/MobiCoreDriverLib/Registry/Public/MobiCoreRegistry.h (renamed from mobicore/daemon/Registry/Public/MobiCoreRegistry.h)10
-rw-r--r--mobicore/MobiCoreDriverLib/Registry/Registry.cpp (renamed from mobicore/daemon/Registry/Registry.cpp)24
-rw-r--r--mobicore/MobiCoreDriverLib/build.sh (renamed from mobicore/daemon/build.sh)0
-rw-r--r--mobicore/MobiCoreDriverLib/buildTag.h33
-rw-r--r--mobicore/NOTICE25
-rw-r--r--mobicore/common/DrSecureStorage/dci.h57
-rw-r--r--mobicore/common/DrSecureStorage/drError.h34
-rw-r--r--mobicore/common/DrSecureStorage/tee_internal_api.h1109
-rw-r--r--mobicore/common/DrSecureStorage/tlDriverApi.h96
-rw-r--r--mobicore/common/LogWrapper/Android.mk15
-rw-r--r--mobicore/common/LogWrapper/log.h77
-rw-r--r--mobicore/common/MobiCore/inc/DrApi/DrApi.h28
-rw-r--r--mobicore/common/MobiCore/inc/DrApi/DrApiCommon.h84
-rw-r--r--mobicore/common/MobiCore/inc/DrApi/DrApiError.h67
-rw-r--r--mobicore/common/MobiCore/inc/DrApi/DrApiFastCall.h117
-rw-r--r--mobicore/common/MobiCore/inc/DrApi/DrApiHeap.h78
-rw-r--r--mobicore/common/MobiCore/inc/DrApi/DrApiIpcMsg.h280
-rw-r--r--mobicore/common/MobiCore/inc/DrApi/DrApiLogging.h71
-rw-r--r--mobicore/common/MobiCore/inc/DrApi/DrApiMcSystem.h49
-rw-r--r--mobicore/common/MobiCore/inc/DrApi/DrApiMm.h305
-rw-r--r--mobicore/common/MobiCore/inc/DrApi/DrApiThread.h265
-rw-r--r--mobicore/common/MobiCore/inc/DrApi/version.h17
-rw-r--r--mobicore/common/MobiCore/inc/FwDrv/DrApiFastCall.h117
-rw-r--r--mobicore/common/MobiCore/inc/GP/tee_type.h143
-rw-r--r--mobicore/common/MobiCore/inc/GP/uuid_attestation.h60
-rw-r--r--mobicore/common/MobiCore/inc/McLib/GpTci.h6
-rw-r--r--mobicore/common/MobiCore/inc/McLib/TlApiCryptoMarshal.h388
-rw-r--r--mobicore/common/MobiCore/inc/McLib/TlApiStorageMarshal.h88
-rw-r--r--mobicore/common/MobiCore/inc/McLib/TlApiTuiMarshal.h64
-rw-r--r--mobicore/common/MobiCore/inc/McLib/mcLibWB.h16
-rw-r--r--mobicore/common/MobiCore/inc/McLib/mclib_size.h18
-rw-r--r--mobicore/common/MobiCore/inc/McLib/tplay_marshal.h72
-rw-r--r--mobicore/common/MobiCore/inc/Mci/mci.h48
-rw-r--r--mobicore/common/MobiCore/inc/Mci/mcifc.h92
-rw-r--r--mobicore/common/MobiCore/inc/Mci/mcifcfunc.h193
-rw-r--r--mobicore/common/MobiCore/inc/Mci/mcimcp.h43
-rw-r--r--mobicore/common/MobiCore/inc/Mci/mcinq.h42
-rw-r--r--mobicore/common/MobiCore/inc/Mci/version.h40
-rw-r--r--mobicore/common/MobiCore/inc/TlCm/2.0/cmp.h126
-rw-r--r--mobicore/common/MobiCore/inc/TlCm/2.0/tlCmApi.h2
-rw-r--r--mobicore/common/MobiCore/inc/TlCm/3.0/cmp.h130
-rw-r--r--mobicore/common/MobiCore/inc/TlCm/3.0/cmpMap.h134
-rw-r--r--mobicore/common/MobiCore/inc/TlCm/3.0/tlCmApi.h4
-rw-r--r--mobicore/common/MobiCore/inc/TlCm/cmpCommon.h18
-rw-r--r--mobicore/common/MobiCore/inc/TlCm/tlCmApiCommon.h4
-rw-r--r--mobicore/common/MobiCore/inc/TlCm/tlCmError.h2
-rw-r--r--mobicore/common/MobiCore/inc/TlCm/tlCmUuid.h2
-rw-r--r--mobicore/common/MobiCore/inc/TlCm/version.h2
-rw-r--r--mobicore/common/MobiCore/inc/mcContainer.h60
-rw-r--r--mobicore/common/MobiCore/inc/mcDriverId.h37
-rw-r--r--mobicore/common/MobiCore/inc/mcLoadFormat.h68
-rw-r--r--mobicore/common/MobiCore/inc/mcRootid.h38
-rw-r--r--mobicore/common/MobiCore/inc/mcSo.h47
-rw-r--r--mobicore/common/MobiCore/inc/mcSpid.h41
-rw-r--r--mobicore/common/MobiCore/inc/mcSuid.h38
-rw-r--r--mobicore/common/MobiCore/inc/mcUuid.h44
-rw-r--r--mobicore/common/MobiCore/inc/mcVersionHelper.h63
-rw-r--r--mobicore/common/MobiCore/inc/mcVersionInfo.h38
-rw-r--r--mobicore/common/MobiCore/inc/version.md51
-rw-r--r--mobicore/daemon/CleanSpec.mk61
-rw-r--r--mobicore/daemon/ClientLib/public/GP/tee_error.h177
-rw-r--r--mobicore/daemon/ClientLib/public/GP/tee_internal_api_impl.h35
-rw-r--r--mobicore/daemon/ClientLib/public/Windows/t-base_client_api.def25
-rw-r--r--mobicore/daemon/ClientLib/public/Windows/t-base_client_api.sln20
-rw-r--r--mobicore/daemon/ClientLib/public/Windows/t-base_client_api.vcxproj109
-rw-r--r--mobicore/daemon/Daemon/Device/public/ExcDevice.h72
-rw-r--r--mobicore/daemon/Daemon/FSD/public/dci.h57
-rw-r--r--mobicore/daemon/Daemon/FSD/public/drSecureStorage_Api.h101
-rw-r--r--mobicore/daemon/MODULE_LICENSE_BSD0
-rw-r--r--mobicore/daemon/NOTICE25
-rw-r--r--mobicore/daemon/README.android64
-rw-r--r--mobicore/daemon/buildTag.h28
-rw-r--r--mobicore/include/Public/mc_linux.h80
-rw-r--r--mobicore/include/Public/version.h42
-rw-r--r--mobicore/provlib/Android.mk16
-rw-r--r--mobicore/provlib/Application.mk23
-rw-r--r--mobicore/provlib/buildTag.h28
-rw-r--r--mobicore/provlib/inc_private/gdmcdevicebinding.h101
-rw-r--r--mobicore/provlib/inc_private/gdmcinstance.h28
-rw-r--r--mobicore/provlib/inc_private/gdmcprovprotocol.h127
-rw-r--r--mobicore/provlib/inc_private/mobicore.h174
-rw-r--r--mobicore/provlib/inc_public/gdmcprovlib.h424
-rw-r--r--mobicore/provlib/jni/Android.mk35
-rw-r--r--mobicore/provlib/src/crc32.c49
-rw-r--r--mobicore/provlib/src/gdmcdevicebinding.cpp533
-rw-r--r--mobicore/provlib/src/gdmcprovlib.cpp408
-rw-r--r--mobicore/provlib/src/mobicore.c294
-rw-r--r--mobicore/rootpa/Code/Android/app/Android.mk2
-rw-r--r--mobicore/rootpa/Code/Android/app/NOTICE30
-rw-r--r--mobicore/rootpa/Code/Android/app/ant.properties7
-rw-r--r--mobicore/rootpa/Code/Android/app/build.xml52
-rw-r--r--mobicore/rootpa/Code/Android/app/jni/Android.mk2
-rw-r--r--mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/Android.mk36
-rw-r--r--mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/CmpBase.cpp45
-rw-r--r--mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/CmpResponses.cpp60
-rw-r--r--mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/JniHelpers.cpp102
-rw-r--r--mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/JniHelpers.h34
-rw-r--r--mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/NOTICE30
-rw-r--r--mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/com_gd_mobicore_pa_jni_CommonPAWrapper.h35
-rw-r--r--mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/commonwrapper.cpp229
-rw-r--r--mobicore/rootpa/Code/Android/app/jni/McStub/Android.mk2
-rw-r--r--mobicore/rootpa/Code/Android/app/jni/McStub/NOTICE30
-rw-r--r--mobicore/rootpa/Code/Android/app/res/values/version.xml4
-rw-r--r--mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/jni/CommonPAWrapper.java67
-rw-r--r--mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/BaseService.java126
-rw-r--r--mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/DeveloperService.java120
-rw-r--r--mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/OemService.java68
-rw-r--r--mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/ProvisioningService.java206
-rw-r--r--mobicore/rootpa/Code/Android/lib/Android.mk4
-rw-r--r--mobicore/rootpa/Code/Android/lib/NOTICE30
-rw-r--r--mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/AbstractEnumParcel.java148
-rw-r--r--mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/BooleanResult.aidl66
-rw-r--r--mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/BooleanResult.java188
-rw-r--r--mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/CommandResult.java102
-rw-r--r--mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/IfcVersion.java35
-rw-r--r--mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/README.txt28
-rw-r--r--mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPADeveloperIfc.aidl136
-rw-r--r--mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPAProvisioningIntents.java180
-rw-r--r--mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPAServiceIfc.aidl80
-rw-r--r--mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/Version.java238
-rw-r--r--mobicore/rootpa/Code/Common/Android.mk (renamed from mobicore/rootpa/Code/Android/app/jni/Common/Android.mk)66
-rw-r--r--mobicore/rootpa/Code/Common/NOTICE30
-rw-r--r--mobicore/rootpa/Code/Common/base64.c43
-rw-r--r--mobicore/rootpa/Code/Common/commandhandler.c257
-rw-r--r--mobicore/rootpa/Code/Common/contentmanager.c21
-rw-r--r--mobicore/rootpa/Code/Common/enrollmentservicexmlschema.h32
-rw-r--r--mobicore/rootpa/Code/Common/include/logging.h43
-rw-r--r--mobicore/rootpa/Code/Common/include/provisioningagent.h131
-rw-r--r--mobicore/rootpa/Code/Common/include/rootpa.h78
-rw-r--r--mobicore/rootpa/Code/Common/include/rootpaErrors.h58
-rw-r--r--mobicore/rootpa/Code/Common/include/version.h34
-rw-r--r--mobicore/rootpa/Code/Common/include/wrapper.h30
-rw-r--r--mobicore/rootpa/Code/Common/pacmp3.c180
-rw-r--r--mobicore/rootpa/Code/Common/pacmp3.h34
-rw-r--r--mobicore/rootpa/Code/Common/pacmtl.c148
-rw-r--r--mobicore/rootpa/Code/Common/provisioningengine.c216
-rw-r--r--mobicore/rootpa/Code/Common/registry.c76
-rw-r--r--mobicore/rootpa/Code/Common/registry.h33
-rw-r--r--mobicore/rootpa/Code/Common/seclient.c245
-rw-r--r--mobicore/rootpa/Code/Common/tools.h13
-rw-r--r--mobicore/rootpa/Code/Common/trustletchannel.c160
-rw-r--r--mobicore/rootpa/Code/Common/trustletchannel.h38
-rw-r--r--mobicore/rootpa/Code/Common/xmlmessagehandler.c480
218 files changed, 5479 insertions, 11063 deletions
diff --git a/mobicore/Android.mk b/mobicore/Android.mk
index 7ac9806..85fb67c 100644
--- a/mobicore/Android.mk
+++ b/mobicore/Android.mk
@@ -5,6 +5,7 @@
# =============================================================================
MOBICORE_PROJECT_PATH := $(call my-dir)
# Setup common variables
+LOG_WRAPPER := $(MOBICORE_PROJECT_PATH)/common/LogWrapper
COMP_PATH_MobiCore := $(MOBICORE_PROJECT_PATH)/common/MobiCore
COMP_PATH_MobiCoreDriverMod := $(MOBICORE_PROJECT_PATH)/include
@@ -14,34 +15,24 @@ GLOBAL_INCLUDES := bionic \
external/stlport/stlport \
$(COMP_PATH_MobiCore)/inc \
$(COMP_PATH_MobiCoreDriverMod)/Public \
- $(COMP_PATH_MobiCore)/inc/TlCm \
- $(COMP_PATH_MobiCore)/inc/GP \
- $(MOBICORE_PROJECT_PATH)/common/DrSecureStorage
+ $(COMP_PATH_MobiCore)/inc/TlCm
GLOBAL_LIBRARIES := libstlport
# Include the Daemon
-include $(MOBICORE_PROJECT_PATH)/daemon/Android.mk
+include $(MOBICORE_PROJECT_PATH)/MobiCoreDriverLib/Android.mk
-MC_INCLUDE_DIR := \
- $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include \
- $(COMP_PATH_MobiCore)/inc \
- $(COMP_PATH_MobiCore)/inc/GP \
+MC_INCLUDE_DIR := $(COMP_PATH_MobiCore)/inc \
$(COMP_PATH_MobiCore)/inc/TlCm \
$(COMP_PATH_MobiCore)/inc/TlCm/2.0 \
- $(MOBICORE_PROJECT_PATH)/daemon/ClientLib/public \
- $(MOBICORE_PROJECT_PATH)/daemon/Registry/Public
-
+ $(MOBICORE_PROJECT_PATH)/MobiCoreDriverLib/ClientLib/public \
+ $(MOBICORE_PROJECT_PATH)/MobiCoreDriverLib/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)
+include $(MOBICORE_PROJECT_PATH)/rootpa/Code/Common/Android.mk
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
diff --git a/mobicore/CleanSpec.mk b/mobicore/CleanSpec.mk
deleted file mode 100644
index 7dd6f6c..0000000
--- a/mobicore/CleanSpec.mk
+++ /dev/null
@@ -1,61 +0,0 @@
-# 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
-# ************************************************
diff --git a/mobicore/MODULE_LICENSE_BSD b/mobicore/MODULE_LICENSE_BSD
deleted file mode 100644
index e69de29..0000000
--- a/mobicore/MODULE_LICENSE_BSD
+++ /dev/null
diff --git a/mobicore/daemon/Android.mk b/mobicore/MobiCoreDriverLib/Android.mk
index fe884ff..fb8da31 100644
--- a/mobicore/daemon/Android.mk
+++ b/mobicore/MobiCoreDriverLib/Android.mk
@@ -12,36 +12,39 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libMcClient
LOCAL_MODULE_TAGS := debug eng optional
LOCAL_C_INCLUDES += $(GLOBAL_INCLUDES)
-LOCAL_SHARED_LIBRARIES += $(GLOBAL_LIBRARIES) liblog
+LOCAL_SHARED_LIBRARIES += $(GLOBAL_LIBRARIES)
LOCAL_CFLAGS := -fvisibility=hidden -fvisibility-inlines-hidden
+LOCAL_CFLAGS += -Wno-missing-field-initializers
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
+ 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_PATH)/Common \
+ $(LOCAL_PATH)/ClientLib/public \
+ $(LOCAL_PATH)/ClientLib/public/GP \
+ $(MOBICORE_PROJECT_PATH)/include/GPD_TEE_Internal_API \
+ $(MOBICORE_PROJECT_PATH)/include/public \
+ $(COMP_PATH_MobiCore)/inc \
+ $(COMP_PATH_MobiCore)/inc/McLib
LOCAL_EXPORT_C_INCLUDE_DIRS +=\
- $(COMP_PATH_MobiCore)/inc \
- $(LOCAL_PATH)/ClientLib/public
-
-LOCAL_CFLAGS += -DLOG_ANDROID
+ $(COMP_PATH_MobiCore)/inc \
+ $(LOCAL_PATH)/ClientLib/public
include $(LOCAL_PATH)/Kernel/Android.mk
+# Import logwrapper
+include $(LOG_WRAPPER)/Android.mk
include $(BUILD_SHARED_LIBRARY)
@@ -54,34 +57,40 @@ LOCAL_MODULE_TAGS := debug eng optional
LOCAL_CFLAGS += -include buildTag.h
LOCAL_CFLAGS += -DLOG_TAG=\"McDaemon\"
LOCAL_CFLAGS += -DTBASE_API_LEVEL=3
+#remove some warnings
+LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-format
LOCAL_C_INCLUDES += $(GLOBAL_INCLUDES)
-LOCAL_SHARED_LIBRARIES += $(GLOBAL_LIBRARIES) libMcClient liblog
+LOCAL_SHARED_LIBRARIES += $(GLOBAL_LIBRARIES) libMcClient
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
+ 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
-
+ $(LOCAL_PATH)/Common \
+ $(LOCAL_PATH)/common/MobiCore/inc \
+ $(LOCAL_PATH)/ClientLib/public \
+ $(LOCAL_PATH)/ClientLib/public/GP \
+ $(MOBICORE_PROJECT_PATH)/include/public \
+ $(COMP_PATH_MobiCore)/inc \
+ $(COMP_PATH_MobiCore)/inc/McLib
# Private Registry components
LOCAL_C_INCLUDES += $(LOCAL_PATH)/Registry/Public \
- $(LOCAL_PATH)/Registry
+ $(LOCAL_PATH)/Registry
+
LOCAL_SRC_FILES += Registry/PrivateRegistry.cpp
# Common components
include $(LOCAL_PATH)/Kernel/Android.mk
-
-LOCAL_CFLAGS += -DLOG_ANDROID
+# Logwrapper
+include $(LOG_WRAPPER)/Android.mk
include $(BUILD_EXECUTABLE)
@@ -93,23 +102,22 @@ 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_SHARED_LIBRARIES += $(GLOBAL_LIBRARIES)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/Common \
- $(LOCAL_PATH)/Daemon/public \
- $(LOCAL_PATH)/ClientLib/public \
- $(LOCAL_PATH)/../common/LogWrapper
+ $(LOCAL_PATH)/Daemon/public \
+ $(LOCAL_PATH)/ClientLib/public
# Common Source files required for building the daemon
LOCAL_SRC_FILES += Common/CMutex.cpp \
- Common/Connection.cpp \
- Common/CSemaphore.cpp \
-# Common/CThread.cpp
+ Common/Connection.cpp \
+ Common/CSemaphore.cpp
#LOCAL_LDLIBS := -lthread_db
include $(LOCAL_PATH)/Registry/Android.mk
-LOCAL_CFLAGS += -DLOG_ANDROID
+# Import logwrapper
+include $(LOG_WRAPPER)/Android.mk
include $(BUILD_SHARED_LIBRARY)
diff --git a/mobicore/daemon/Application.mk b/mobicore/MobiCoreDriverLib/Application.mk
index dda3298..fddc817 100644
--- a/mobicore/daemon/Application.mk
+++ b/mobicore/MobiCoreDriverLib/Application.mk
@@ -7,7 +7,6 @@
# 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
@@ -16,6 +15,7 @@ APP_OPTIM := debug
# Application wide Cflags
GLOBAL_INCLUDES := \
$(COMP_PATH_MobiCoreDriverMod)/Public \
+ $(COMP_PATH_TlSdk)/Public/MobiCore/inc \
$(COMP_PATH_MobiCore)/inc \
$(COMP_PATH_TlCm)/Public \
$(COMP_PATH_TlCm)/Public/TlCm
@@ -23,4 +23,9 @@ GLOBAL_INCLUDES := \
# Show all warnings
APP_CFLAGS += -Wall
+LOG_WRAPPER := $(COMP_PATH_Logwrapper)
+
APP_PLATFORM := android-9
+
+# Position Independent Executable
+APP_PIE := true
diff --git a/mobicore/daemon/ClientLib/Android.mk b/mobicore/MobiCoreDriverLib/ClientLib/Android.mk
index 8081935..8081935 100644
--- a/mobicore/daemon/ClientLib/Android.mk
+++ b/mobicore/MobiCoreDriverLib/ClientLib/Android.mk
diff --git a/mobicore/daemon/ClientLib/ClientLib.cpp b/mobicore/MobiCoreDriverLib/ClientLib/ClientLib.cpp
index 20b08db..8776486 100644
--- a/mobicore/daemon/ClientLib/ClientLib.cpp
+++ b/mobicore/MobiCoreDriverLib/ClientLib/ClientLib.cpp
@@ -1,14 +1,5 @@
-/** @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
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,10 +28,17 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * <t-base Driver API.
+ *
+ * Functions for accessing <t-base functionality from the normal world.
+ * Handles sessions and notifications via MCI buffer.
+ */
#include <stdint.h>
#ifndef WIN32
#include <stdbool.h>
#include <list>
+#include <errno.h>
#include "assert.h"
#endif
@@ -151,7 +149,7 @@ bool removeDevice(uint32_t deviceId)
#define CHECK_SESSION(S,SID) \
if (NULL == S) \
{ \
- LOG_E("Session %i not found", SID); \
+ LOG_E("Session %03x not found", SID); \
mcResult = MC_DRV_ERR_UNKNOWN_SESSION; \
break; \
}
@@ -205,7 +203,8 @@ __MC_CLIENT_LIB_API mcResult_t mcOpenDevice(uint32_t deviceId)
Device *device = resolveDeviceId(deviceId);
if (device != NULL) {
LOG_E("Device %d already opened", deviceId);
- mcResult = MC_DRV_ERR_DEVICE_ALREADY_OPEN;
+ mcResult = MC_DRV_OK;
+ device->openCount++;
break;
}
@@ -259,6 +258,7 @@ __MC_CLIENT_LIB_API mcResult_t mcOpenDevice(uint32_t deviceId)
}
addDevice(device);
+ device->openCount++;
} while (false);
@@ -288,11 +288,15 @@ __MC_CLIENT_LIB_API mcResult_t mcCloseDevice(
LOG_I("===%s(%i)===", __FUNCTION__, deviceId);
do {
Device *device = resolveDeviceId(deviceId);
- // CHECK_DEVICE(device);
CHECK_DEVICE_CLOSED(device, deviceId);
Connection *devCon = device->connection;
+ if (device->openCount != 1) {
+ device->openCount--;
+ break;
+ }
+
// Check if daemon is still alive
if (!devCon->isConnectionAlive()) {
removeDevice(deviceId);
@@ -392,8 +396,8 @@ __MC_CLIENT_LIB_API mcResult_t mcOpenSession(
SEND_TO_DAEMON(devCon, MC_DRV_CMD_OPEN_SESSION,
session->deviceId,
*uuid,
- (uint32_t)(tci) & 0xFFF,
- (uint32_t)handle,
+ (uint32_t)((uintptr_t)tci & 0xFFF),
+ handle,
len);
// Read command response
@@ -493,7 +497,7 @@ __MC_CLIENT_LIB_API mcResult_t mcOpenSession(
if (bulkBuf)
sessionObj->addBulkBuf(bulkBuf);
- LOG_I(" Successfully opened session %d.", session->sessionId);
+ LOG_I(" Successfully opened session %03x.", session->sessionId);
} while (false);
@@ -574,8 +578,8 @@ __MC_CLIENT_LIB_API mcResult_t mcOpenTrustlet(
session->deviceId,
spid,
(uint32_t)tlen,
- (uint32_t)(tci) & 0xFFF,
- (uint32_t)handle,
+ (uint32_t)((uintptr_t)tci & 0xFFF),
+ handle,
len);
// Send the full trustlet data
@@ -686,7 +690,7 @@ __MC_CLIENT_LIB_API mcResult_t mcOpenTrustlet(
if (bulkBuf)
sessionObj->addBulkBuf(bulkBuf);
- LOG_I(" Successfully opened session %d.", session->sessionId);
+ LOG_I(" Successfully opened session %03x.", session->sessionId);
} while (false);
@@ -769,8 +773,8 @@ __MC_CLIENT_LIB_API mcResult_t mcOpenGPTA(
SEND_TO_DAEMON(devCon, MC_DRV_CMD_OPEN_TRUSTED_APP,
session->deviceId,
*uuid,
- (uint32_t)(tci) & 0xFFF,
- (uint32_t)handle,
+ (uint32_t)((uintptr_t)tci & 0xFFF),
+ handle,
len);
// Read command response
@@ -870,7 +874,7 @@ __MC_CLIENT_LIB_API mcResult_t mcOpenGPTA(
if (bulkBuf)
sessionObj->addBulkBuf(bulkBuf);
- LOG_I(" Successfully opened session %d.", session->sessionId);
+ LOG_I(" Successfully opened session %03x.", session->sessionId);
} while (false);
@@ -900,7 +904,7 @@ __MC_CLIENT_LIB_API mcResult_t mcCloseSession(mcSessionHandle_t *session)
devMutex.lock();
do {
CHECK_NOT_NULL(session);
- LOG_I(" Closing session %d.", session->sessionId);
+ LOG_I(" Closing session %03x.", session->sessionId);
Device *device = resolveDeviceId(session->deviceId);
CHECK_DEVICE(device);
@@ -923,7 +927,7 @@ __MC_CLIENT_LIB_API mcResult_t mcCloseSession(mcSessionHandle_t *session)
}
bool r = device->removeSession(session->sessionId);
- if (!r)
+ if (!r)
{
LOG_E("removeSession failed");
assert(0);
@@ -958,7 +962,7 @@ __MC_CLIENT_LIB_API mcResult_t mcNotify(
do {
CHECK_NOT_NULL(session);
- LOG_I(" Notifying session %d.", session->sessionId);
+ LOG_I(" Notifying session %03x.", session->sessionId);
Device *device = resolveDeviceId(session->deviceId);
CHECK_DEVICE(device);
@@ -1003,7 +1007,7 @@ __MC_CLIENT_LIB_API mcResult_t mcWaitNotification(
do {
CHECK_NOT_NULL(session);
- LOG_I(" Waiting for notification of session %d.", session->sessionId);
+ LOG_I(" Waiting for notification of session %03x.", session->sessionId);
Device *device = resolveDeviceId(session->deviceId);
CHECK_DEVICE(device);
@@ -1021,6 +1025,15 @@ __MC_CLIENT_LIB_API mcResult_t mcWaitNotification(
&notification,
sizeof(notification_t),
timeout);
+ // Check for interrupted system call and loop, but only if timeout is infinite
+ if ((numRead == -1) && (errno == EINTR)) {
+ if (timeout == MC_INFINITE_TIMEOUT) {
+ continue;
+ } else if (timeout == MC_INFINITE_TIMEOUT_INTERRUPTIBLE) {
+ mcResult = MC_DRV_ERR_INTERRUPTED_BY_SIGNAL;
+ break;
+ }
+ }
//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 ) {
@@ -1053,7 +1066,7 @@ __MC_CLIENT_LIB_API mcResult_t mcWaitNotification(
}
count++;
- LOG_I(" Received notification %d for session %d, payload=%d",
+ LOG_I(" Received notification %d for session %03x, payload=%d",
count, notification.sessionId, notification.payload);
if (notification.payload != 0) {
@@ -1205,7 +1218,7 @@ __MC_CLIENT_LIB_API mcResult_t mcMap(
Session *session = device->resolveSessionId(sessionHandle->sessionId);
CHECK_SESSION(session, sessionHandle->sessionId);
- LOG_I(" Mapping %p to session %d.", buf, sessionHandle->sessionId);
+ LOG_I(" Mapping %p to session %03x.", buf, sessionHandle->sessionId);
// Register mapped bulk buffer to Kernel Module and keep mapped bulk buffer in mind
BulkBufferDescriptor *bulkBuf;
@@ -1217,9 +1230,9 @@ __MC_CLIENT_LIB_API mcResult_t mcMap(
SEND_TO_DAEMON(devCon, MC_DRV_CMD_MAP_BULK_BUF,
session->sessionId,
- (uint32_t)bulkBuf->handle,
- (uint32_t)0,
- (uint32_t)(bulkBuf->virtAddr) & 0xFFF,
+ bulkBuf->handle,
+ 0,
+ (uint32_t)((uintptr_t)bulkBuf->virtAddr & 0xFFF),
bulkBuf->len);
// Read command response
@@ -1243,9 +1256,12 @@ __MC_CLIENT_LIB_API mcResult_t mcMap(
RECV_FROM_DAEMON(devCon, &rspMapBulkMemPayload);
// Set mapping info for internal structures
- bulkBuf->sVirtualAddr = (void *)rspMapBulkMemPayload.secureVirtualAdr;
+ bulkBuf->sVirtualAddr = (uint32_t)rspMapBulkMemPayload.secureVirtualAdr;
// Set mapping info for Trustlet
- mapInfo->sVirtualAddr = bulkBuf->sVirtualAddr;
+ // NOTE: The "nice" piece of code is needed because sVirtualAddr has 2 different
+ // types to accomodate backward compatibility but also keep the length to 32bits
+ // so on 32 bit systems it's void* but on 64 bit systems it's uint32_t
+ *(uint32_t*)&mapInfo->sVirtualAddr = bulkBuf->sVirtualAddr;
mapInfo->sVirtualLen = bufLen;
mcResult = MC_DRV_OK;
@@ -1282,8 +1298,12 @@ __MC_CLIENT_LIB_API mcResult_t mcUnmap(
do {
CHECK_NOT_NULL(sessionHandle);
CHECK_NOT_NULL(mapInfo);
- CHECK_NOT_NULL(mapInfo->sVirtualAddr);
CHECK_NOT_NULL(buf);
+ if (mapInfo->sVirtualAddr == 0) {
+ LOG_E("Invalid secure virtual address %u.", (uintptr_t)mapInfo->sVirtualAddr);
+ mcResult = MC_DRV_ERR_NULL_POINTER;
+ break;
+ }
// Determine device the session belongs to
Device *device = resolveDeviceId(sessionHandle->deviceId);
@@ -1299,19 +1319,19 @@ __MC_CLIENT_LIB_API mcResult_t mcUnmap(
Session *session = device->resolveSessionId(sessionHandle->sessionId);
CHECK_SESSION(session, sessionHandle->sessionId);
- uint32_t handle = session->getBufHandle(mapInfo->sVirtualAddr, mapInfo->sVirtualLen);
+ uint32_t handle = session->getBufHandle((uint32_t)mapInfo->sVirtualAddr, mapInfo->sVirtualLen);
if (handle == 0) {
- LOG_E("Unable to find internal handle for buffer %p.", mapInfo->sVirtualAddr);
+ LOG_E("Unable to find internal handle for buffer %u.", (uintptr_t)mapInfo->sVirtualAddr);
mcResult = MC_DRV_ERR_BLK_BUFF_NOT_FOUND;
break;
}
- LOG_I(" Unmapping %p(handle=%u) from session %d.", buf, handle, sessionHandle->sessionId);
+ LOG_I(" Unmapping %p(handle=%u) from session %03x.", buf, handle, sessionHandle->sessionId);
SEND_TO_DAEMON(devCon, MC_DRV_CMD_UNMAP_BULK_BUF,
session->sessionId,
handle,
- (uint32_t)(mapInfo->sVirtualAddr),
+ (uint32_t)mapInfo->sVirtualAddr,
mapInfo->sVirtualLen);
RECV_FROM_DAEMON(devCon, &mcResult);
@@ -1387,21 +1407,6 @@ __MC_CLIENT_LIB_API mcResult_t mcGetSessionErrorCode(
}
//------------------------------------------------------------------------------
-__MC_CLIENT_LIB_API mcResult_t mcDriverCtrl(
- mcDriverCtrl_t param,
- uint8_t *data,
- uint32_t len
-)
-{
-#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
@@ -1459,8 +1464,6 @@ __MC_CLIENT_LIB_API mcResult_t mcGetMobiCoreVersion(
// 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;
@@ -1489,4 +1492,3 @@ uint32_t getDaemonVersion(Connection *devCon, uint32_t *version)
}
#endif /* WIN32 */
-/** @} */
diff --git a/mobicore/daemon/ClientLib/Device.cpp b/mobicore/MobiCoreDriverLib/ClientLib/Device.cpp
index 2141f99..703f28d 100644
--- a/mobicore/daemon/ClientLib/Device.cpp
+++ b/mobicore/MobiCoreDriverLib/ClientLib/Device.cpp
@@ -1,13 +1,5 @@
-/** @addtogroup MCD_IMPL_LIB
- * @{
- * @file
- *
- * Client library device management.
- *
- * Device and Trustlet Session management Funtions.
- *
- *
- * Copyright (c) 2013 TRUSTONIC LIMITED
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,6 +28,11 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Client library device management.
+ *
+ * Device and Trustlet Session management Funtions.
+ */
#include <stdint.h>
#include <vector>
@@ -51,6 +48,7 @@ Device::Device(uint32_t deviceId, Connection *connection)
{
this->deviceId = deviceId;
this->connection = connection;
+ this->openCount = 0;
pMcKMod = new CMcKMod();
}
@@ -156,26 +154,23 @@ Session *Device::resolveSessionId(uint32_t sessionId)
mcResult_t Device::allocateContiguousWsm(uint32_t len, CWsm **wsm)
{
// Allocate shared memory
- addr_t virtAddr;
- uint32_t handle;
- uint64_t physAddr;
+ addr_t virtAddr = NULL;
+ uint32_t handle = 0;
mcResult_t ret;
- assert(wsm != NULL);
-
if (!len) {
return MC_DRV_ERR_INVALID_LENGTH;
}
- ret = pMcKMod->mapWsm(len, &handle, &virtAddr, &physAddr);
+ ret = pMcKMod->mapWsm(len, &handle, &virtAddr);
if (ret) {
return ret;
}
- LOG_I(" mapped handle %d to %p, phys=%#llx ", handle, virtAddr, physAddr);
+ LOG_I(" mapped handle %d to %p", handle, virtAddr);
// Register (vaddr,paddr) with device
- *wsm = new CWsm(virtAddr, len, handle, physAddr);
+ *wsm = new CWsm(virtAddr, len, handle, 0);
wsmL2List.push_back(*wsm);
@@ -242,7 +237,7 @@ CWsm_ptr Device::findContiguousWsm(addr_t virtAddr)
mcResult_t Device::mapBulkBuf(addr_t buf, uint32_t len, BulkBufferDescriptor **blkBuf)
{
uint64_t PhysWsmL2;
- uint32_t handle;
+ uint32_t handle = 0;
*blkBuf = NULL;
@@ -261,4 +256,3 @@ mcResult_t Device::mapBulkBuf(addr_t buf, uint32_t len, BulkBufferDescriptor **b
return MC_DRV_OK;
}
-/** @} */
diff --git a/mobicore/daemon/ClientLib/Device.h b/mobicore/MobiCoreDriverLib/ClientLib/Device.h
index 767f20e..2be2e97 100644
--- a/mobicore/daemon/ClientLib/Device.h
+++ b/mobicore/MobiCoreDriverLib/ClientLib/Device.h
@@ -1,12 +1,4 @@
-/** @addtogroup MCD_IMPL_LIB
- * @{
- * @file
- *
- * Client library device management.
- *
- * Device and Trustlet Session management Functions.
- *
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -36,6 +28,11 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Client library device management.
+ *
+ * Device and Trustlet Session management Functions.
+ */
#ifndef DEVICE_H_
#define DEVICE_H_
@@ -59,6 +56,7 @@ public:
uint32_t deviceId; /**< Device identifier */
Connection *connection; /**< The device connection */
CMcKMod_ptr pMcKMod;
+ uint32_t openCount;
Device(
uint32_t deviceId,
@@ -170,4 +168,3 @@ public:
#endif /* DEVICE_H_ */
-/** @} */
diff --git a/mobicore/daemon/ClientLib/GP/tee_client_api.cpp b/mobicore/MobiCoreDriverLib/ClientLib/GP/tee_client_api.cpp
index e036453..45c5adf 100644
--- a/mobicore/daemon/ClientLib/GP/tee_client_api.cpp
+++ b/mobicore/MobiCoreDriverLib/ClientLib/GP/tee_client_api.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,24 +30,18 @@
*/
#undef LOG_TAG
#define LOG_TAG "GpClient"
-
-#include <stdlib.h>
-#include <string.h>
-
#include "tee_client_api.h"
#include "log.h"
#include "MobiCoreDriverApi.h"
#include "Mci/mcinq.h"
#include <sys/mman.h>
#include "GpTci.h"
+#include "../Session.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
@@ -72,11 +66,6 @@ static TEEC_Result _TEEC_SetupOperation(
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,
@@ -116,25 +105,29 @@ static TEEC_Result _TEEC_SetupOperation(
mcResult_t mcRet = MC_DRV_OK;
TEEC_Result teecResult = TEEC_SUCCESS;
- //operation can be NULL
+ LOG_I(" %s()", __func__);
+
tci->operation.isCancelled = false;
+ tci->operation.paramTypes = 0;
+
+ //operation can be NULL
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
+ //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++) {
+ uint8_t paramType = _TEEC_GET_PARAM_TYPE(operation->paramTypes, i);
+
imp = &tci->operation.params[i];
ext = &operation->params[i];
- switch (_TEEC_GET_PARAM_TYPE(operation->paramTypes, i)) {
+ switch (paramType) {
case TEEC_VALUE_OUTPUT:
+ LOG_I(" cycle %d, TEEC_VALUE_OUTPUT", i);
break;
case TEEC_NONE:
LOG_I(" cycle %d, TEEC_NONE", i);
@@ -176,6 +169,9 @@ static TEEC_Result _TEEC_SetupOperation(
i = _TEEC_PARAMETER_NUMBER;
}
}
+ /* We don't transmit that the mem ref is the whole shared mem */
+ /* Magic number 4 means that it is a mem ref */
+ paramType = ext->memref.parent->flags | 4;
break;
}
case TEEC_MEMREF_PARTIAL_INPUT:
@@ -184,15 +180,17 @@ static TEEC_Result _TEEC_SetupOperation(
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)) ||
+ (paramType == 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))) {
+ (paramType == TEEC_MEMREF_PARTIAL_INPUT))) {
LOG_E("PARTIAL data flow inconsistency");
*returnOrigin = TEEC_ORIGIN_API;
teecResult = TEEC_ERROR_BAD_PARAMETERS;
i = _TEEC_PARAMETER_NUMBER;
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");
@@ -219,6 +217,7 @@ static TEEC_Result _TEEC_SetupOperation(
i = _TEEC_PARAMETER_NUMBER;
break;
}
+ tci->operation.paramTypes |= (paramType<<i*4);
}
if (tci->operation.isCancelled) {
@@ -231,18 +230,17 @@ static TEEC_Result _TEEC_SetupOperation(
uint32_t retOrigIgnored;
_TEEC_UnwindOperation(tci, handle, operation, false, &retOrigIgnored);
//Zeroing out tci->operation
- memset(&tci->operation, 0, sizeof(TEEC_Operation));
+ memset(&tci->operation, 0, sizeof(tci->operation));
if (teecResult != TEEC_SUCCESS) return teecResult;
return TEEC_ERROR_GENERIC;
}
}
//Copy version indicator field
- strcpy(tci->header, "TCIGP000");
+ memcpy(tci->header, "TCIGP000", sizeof(tci->header));
// Fill in invalid values for secure world to overwrite
- tci->returnStatus = 0;
- tci->returnStatus = TEE_ERROR_BAD_STATE;
+ tci->returnStatus = TEEC_ERROR_BAD_STATE;
// Signal completion of request writing
tci->ready = 1;
@@ -261,8 +259,6 @@ static TEEC_Result _TEEC_UnwindOperation(
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
@@ -295,7 +291,7 @@ static TEEC_Result _TEEC_UnwindOperation(
break;
case TEEC_VALUE_OUTPUT:
case TEEC_VALUE_INOUT: {
- LOG_I(" cycle %d, TEEC_VALUE_OUT*", i);
+ LOG_I(" cycle %d, TEEC_VALUE_*OUT", i);
if (copyValues) {
ext->value.a = imp->value.a;
ext->value.b = imp->value.b;
@@ -309,14 +305,14 @@ static TEEC_Result _TEEC_UnwindOperation(
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;
+ if ((copyValues) && (ext->memref.parent->flags != TEEC_MEM_INPUT)) {
+ ext->memref.size = imp->memref.outputSize;
+ }
buffer = (uint8_t *)ext->memref.parent->buffer;
break;
}
@@ -338,7 +334,7 @@ static TEEC_Result _TEEC_UnwindOperation(
if ((buffer != NULL) && (imp->memref.mapInfo.sVirtualLen != 0)) {
// This function assumes that we cannot handle error of mcUnmap
- mcUnmap(handle, buffer, &imp->memref.mapInfo);
+ (void)mcUnmap(handle, buffer, &imp->memref.mapInfo);
}
}
@@ -360,8 +356,6 @@ TEEC_Result TEEC_InitializeContext(
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:
@@ -433,12 +427,10 @@ static TEEC_Result _TEEC_CallTA(
// 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;
+ int32_t lastErr = SESSION_ERR_NO;
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;
@@ -446,7 +438,10 @@ static TEEC_Result _TEEC_CallTA(
LOG_E("Target is DEAD");
*returnOrigin = TEEC_ORIGIN_TEE;
- teecError = TEE_ERROR_TARGET_DEAD;
+ teecError = TEEC_ERROR_TARGET_DEAD;
+ } else {
+ LOG_E("mcWaitNotification failed (%08x)", mcRet);
+ LOG_E("mcGetSessionErrorCode returned %d", lastErr);
}
}
}
@@ -537,7 +532,7 @@ TEEC_Result TEEC_OpenSession (
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");
+ LOG_E("mmap failed on tci buffer allocation");
if (returnOrigin != NULL) *returnOrigin = TEEC_ORIGIN_API;
return TEEC_ERROR_OUT_OF_MEMORY;
}
@@ -559,7 +554,7 @@ TEEC_Result TEEC_OpenSession (
(uint8_t *)session->imp.tci,
sizeof(_TEEC_TCI));
if (mcRet != MC_DRV_OK) {
- LOG_E("mcOpenTrustlet failed (%08x)", mcRet);
+ LOG_E("mcOpenGPTA 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;
@@ -741,6 +736,14 @@ TEEC_Result TEEC_RegisterSharedMemory(
LOG_E("sharedMem->buffer is NULL");
return TEEC_ERROR_BAD_PARAMETERS;
}
+ if ((sharedMem->flags & ~(TEEC_MEM_INPUT | TEEC_MEM_OUTPUT)) != 0) {
+ 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;
@@ -765,6 +768,14 @@ TEEC_Result TEEC_AllocateSharedMemory(
LOG_E("sharedMem is NULL");
return TEEC_ERROR_BAD_PARAMETERS;
}
+ if ((sharedMem->flags & ~(TEEC_MEM_INPUT | TEEC_MEM_OUTPUT)) != 0) {
+ 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) {
diff --git a/mobicore/daemon/ClientLib/Session.cpp b/mobicore/MobiCoreDriverLib/ClientLib/Session.cpp
index 3f8dc77..7144d36 100644
--- a/mobicore/daemon/ClientLib/Session.cpp
+++ b/mobicore/MobiCoreDriverLib/ClientLib/Session.cpp
@@ -1,7 +1,5 @@
-/** @addtogroup MCD_IMPL_LIB
- * @{
- * @file
- * Copyright (c) 2013 TRUSTONIC LIMITED
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -109,7 +107,7 @@ int32_t Session::getLastErr(
mcResult_t Session::addBulkBuf(addr_t buf, uint32_t len, BulkBufferDescriptor **blkBuf)
{
uint64_t pPhysWsmL2;
- uint32_t handle;
+ uint32_t handle = 0;
assert(blkBuf != NULL);
@@ -152,9 +150,9 @@ void Session::addBulkBuf(BulkBufferDescriptor *blkBuf)
}
//------------------------------------------------------------------------------
-uint32_t Session::getBufHandle(addr_t sVirtAddr, uint32_t sVirtualLen)
+uint32_t Session::getBufHandle(uint32_t sVirtAddr, uint32_t sVirtualLen)
{
- LOG_V("getBufHandle(): Secure Virtual Address = 0x%X", (unsigned int) sVirtAddr);
+ LOG_V("getBufHandle(): Virtual Address = 0x%X", sVirtAddr);
// Search and remove bulk buffer descriptor
for ( bulkBufferDescrIterator_t iterator = bulkBufferDescriptors.begin();
@@ -188,7 +186,7 @@ mcResult_t Session::removeBulkBuf(addr_t virtAddr)
}
if (pBlkBufDescr == NULL) {
- LOG_E("%p not registered in session %d.", virtAddr, sessionId);
+ LOG_E("%p not registered in session %03x.", virtAddr, sessionId);
return MC_DRV_ERR_BLK_BUFF_NOT_FOUND;
}
LOG_V("removeBulkBuf():handle=%u", pBlkBufDescr->handle);
@@ -205,4 +203,3 @@ mcResult_t Session::removeBulkBuf(addr_t virtAddr)
return MC_DRV_OK;
}
-/** @} */
diff --git a/mobicore/daemon/ClientLib/Session.h b/mobicore/MobiCoreDriverLib/ClientLib/Session.h
index 5fc1e94..1f3529e 100644
--- a/mobicore/daemon/ClientLib/Session.h
+++ b/mobicore/MobiCoreDriverLib/ClientLib/Session.h
@@ -1,7 +1,5 @@
-/** @addtogroup MCD_IMPL_LIB
- * @{
- * @file
- * Copyright (c) 2013 TRUSTONIC LIMITED
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -46,13 +44,13 @@ 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 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 sVirtAddr,
uint32_t len,
uint32_t handle
) :
@@ -146,7 +144,7 @@ public:
*
* @return the Handle or 0 for failure
*/
- uint32_t getBufHandle(addr_t sVirtAddr, uint32_t sVirtualLen);
+ uint32_t getBufHandle(uint32_t sVirtAddr, uint32_t sVirtualLen);
/**
* Set additional error information of the last error that occured.
@@ -184,4 +182,3 @@ typedef sessionList_t::iterator sessionIterator_t;
#endif /* SESSION_H_ */
-/** @} */
diff --git a/mobicore/daemon/ClientLib/public/GP/tee_client_api.h b/mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_client_api.h
index c6f2090..c6f2090 100644
--- a/mobicore/daemon/ClientLib/public/GP/tee_client_api.h
+++ b/mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_client_api.h
diff --git a/mobicore/daemon/ClientLib/public/GP/tee_client_api_imp.h b/mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_client_api_imp.h
index 75c01fe..75c01fe 100644
--- a/mobicore/daemon/ClientLib/public/GP/tee_client_api_imp.h
+++ b/mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_client_api_imp.h
diff --git a/mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_error.h b/mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_error.h
new file mode 100644
index 0000000..e90786a
--- /dev/null
+++ b/mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_error.h
@@ -0,0 +1,131 @@
+/*
+ * 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 __TEE_ERROR_H__
+#define __TEE_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)
+
+#endif /* __TEE_ERROR_H__ */
+
diff --git a/mobicore/daemon/ClientLib/public/GP/tee_type.h b/mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_type.h
index 8cf5898..f164dab 100644
--- a/mobicore/daemon/ClientLib/public/GP/tee_type.h
+++ b/mobicore/MobiCoreDriverLib/ClientLib/public/GP/tee_type.h
@@ -1,14 +1,33 @@
-/**
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
- * 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.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
/**
* Definition of the machine-specific integer types
**/
@@ -83,15 +102,7 @@ typedef unsigned char bool;
#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;
+typedef uint32_t TEEC_Result;
/** Definition of an UUID (from RFC 4122 http://www.ietf.org/rfc/rfc4122.txt) */
typedef struct TEE_UUID {
@@ -102,42 +113,4 @@ typedef struct TEE_UUID {
} 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__ */
diff --git a/mobicore/daemon/ClientLib/public/GP/uuid_attestation.h b/mobicore/MobiCoreDriverLib/ClientLib/public/GP/uuid_attestation.h
index dd48fc2..c16f666 100644
--- a/mobicore/daemon/ClientLib/public/GP/uuid_attestation.h
+++ b/mobicore/MobiCoreDriverLib/ClientLib/public/GP/uuid_attestation.h
@@ -1,12 +1,32 @@
-/**
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved
+ * 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.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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__
@@ -42,7 +62,7 @@ const char TAG[AT_TAG_SIZE]="Trusted Application";
// Public key structure
typedef struct uuid_public_key {
- uint32_t type; // TEE TYPE RSA KEYPAIR: 0xa0000030
+ 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
diff --git a/mobicore/daemon/ClientLib/public/MobiCoreDriverApi.h b/mobicore/MobiCoreDriverLib/ClientLib/public/MobiCoreDriverApi.h
index 425f5e5..2e78520 100644
--- a/mobicore/daemon/ClientLib/public/MobiCoreDriverApi.h
+++ b/mobicore/MobiCoreDriverLib/ClientLib/public/MobiCoreDriverApi.h
@@ -1,44 +1,37 @@
-/**
- * @defgroup MCD_API MobiCore Driver API
- * @addtogroup MCD_API
- * @{
- *
- * @if DOXYGEN_MCDRV_API
- * @mainpage MobiCore Driver API.
- * @endif
- *
- * MobiCore Driver API.
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
+ * All rights reserved.
*
- * The MobiCore (MC) Driver API provides access functions to the t-base trusted execution environment and the contained Trusted Applications.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
*
- * @image html DoxyOverviewDrvApi500x.png
- * @image latex DoxyOverviewDrvApi500x.png "t-base Overview" width=12cm
- */
-/* <!-- Copyright Trustonic 2013-2014 -->
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce 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.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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 API.
+ *
+ * The MobiCore (MC) Driver API provides access functions to the t-base trusted execution environment and the contained Trusted Applications.
*/
#ifndef MCDRIVER_H_
#define MCDRIVER_H_
@@ -145,17 +138,11 @@ typedef uint32_t mcResult_t;
#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. */
+
#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.
@@ -170,14 +157,21 @@ typedef struct {
* 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! */
+#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 */
@@ -330,7 +324,7 @@ __MC_CLIENT_LIB_API mcResult_t mcNotify(
* 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)
+ * @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.
@@ -454,26 +448,6 @@ __MC_CLIENT_LIB_API mcResult_t mcUnmap(
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.
@@ -512,4 +486,3 @@ __MC_CLIENT_LIB_API mcResult_t mcGetMobiCoreVersion(
#endif
#endif /** MCDRIVER_H_ */
-/** @} */
diff --git a/mobicore/daemon/Common/Android.mk b/mobicore/MobiCoreDriverLib/Common/Android.mk
index 55747b7..39f050e 100644
--- a/mobicore/daemon/Common/Android.mk
+++ b/mobicore/MobiCoreDriverLib/Common/Android.mk
@@ -21,11 +21,7 @@ LOCAL_MODULE := Common
# 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
+# Import logwrapper
+#include $(COMP_PATH_Logwrapper)/Android.mk
include $(BUILD_STATIC_LIBRARY)
diff --git a/mobicore/daemon/Common/CMutex.cpp b/mobicore/MobiCoreDriverLib/Common/CMutex.cpp
index dc9e24f..c64a5e9 100644
--- a/mobicore/daemon/Common/CMutex.cpp
+++ b/mobicore/MobiCoreDriverLib/Common/CMutex.cpp
@@ -1,9 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * Mutex implementation (pthread wrapper).
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Mutex implementation (pthread wrapper).
+ */
#include "CMutex.h"
#include "log.h"
@@ -83,4 +81,3 @@ int32_t CMutex::unlock(
return pthread_mutex_unlock(&m_mutex);
}
-/** @} */
diff --git a/mobicore/daemon/Common/CMutex.h b/mobicore/MobiCoreDriverLib/Common/CMutex.h
index 22beacb..f79f3b3 100644
--- a/mobicore/daemon/Common/CMutex.h
+++ b/mobicore/MobiCoreDriverLib/Common/CMutex.h
@@ -1,9 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * Mutex implementation (pthread wrapper).
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Mutex implementation (pthread wrapper).
+ */
#ifndef CMUTEX_H_
#define CMUTEX_H_
@@ -64,4 +62,3 @@ private:
#endif /* CMUTEX_H_ */
-/** @} */
diff --git a/mobicore/daemon/Common/CSemaphore.cpp b/mobicore/MobiCoreDriverLib/Common/CSemaphore.cpp
index efa06c4..23ef649 100644
--- a/mobicore/daemon/Common/CSemaphore.cpp
+++ b/mobicore/MobiCoreDriverLib/Common/CSemaphore.cpp
@@ -1,9 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * Semaphore implementation (pthread wrapper).
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Semaphore implementation (pthread wrapper).
+ */
#include <time.h>
#include <limits.h>
#include "CSemaphore.h"
@@ -113,4 +111,3 @@ void CSemaphore::signal()
pthread_mutex_unlock(&m_mutex);
}
-/** @} */
diff --git a/mobicore/daemon/Common/CSemaphore.h b/mobicore/MobiCoreDriverLib/Common/CSemaphore.h
index fa08b70..02057b6 100644
--- a/mobicore/daemon/Common/CSemaphore.h
+++ b/mobicore/MobiCoreDriverLib/Common/CSemaphore.h
@@ -1,9 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * Semaphore implementation (pthread wrapper).
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Semaphore implementation (pthread wrapper).
+ */
#ifndef CSEMAPHORE_H_
#define CSEMAPHORE_H_
@@ -71,4 +69,3 @@ private:
#endif /*CSEMAPHORE_H_*/
-/** @} */
diff --git a/mobicore/daemon/Common/CThread.cpp b/mobicore/MobiCoreDriverLib/Common/CThread.cpp
index 566dafd..7c19fcd 100644
--- a/mobicore/daemon/Common/CThread.cpp
+++ b/mobicore/MobiCoreDriverLib/Common/CThread.cpp
@@ -1,10 +1,5 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * Thread implementation (pthread abstraction).
- *
- * Copyright (c) 2013 TRUSTONIC LIMITED
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,6 +28,9 @@
* 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 "CThread.h"
#include "log.h"
@@ -88,7 +86,7 @@ void CThread::exit(
)
{
setExiting();
- pthread_exit((void *)exitcode);
+ pthread_exit((void*)(uintptr_t)exitcode);
}
@@ -163,4 +161,3 @@ void *CThreadStartup(
return NULL;
}
-/** @} */
diff --git a/mobicore/daemon/Common/CThread.h b/mobicore/MobiCoreDriverLib/Common/CThread.h
index ad2e4e7..002c7ee 100644
--- a/mobicore/daemon/Common/CThread.h
+++ b/mobicore/MobiCoreDriverLib/Common/CThread.h
@@ -1,9 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * Thread implementation (pthread abstraction).
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -33,6 +28,9 @@
* 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).
+ */
#ifndef CTHREAD_H_
#define CTHREAD_H_
@@ -89,4 +87,3 @@ extern "C" void *CThreadStartup(void *);
#endif /*CTHREAD_H_*/
-/** @} */
diff --git a/mobicore/daemon/Common/CWsm.h b/mobicore/MobiCoreDriverLib/Common/CWsm.h
index 33d82ab..bc92baf 100644
--- a/mobicore/daemon/Common/CWsm.h
+++ b/mobicore/MobiCoreDriverLib/Common/CWsm.h
@@ -1,10 +1,5 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * World shared memory definitions.
- *
- * Copyright (c) 2013 TRUSTONIC LIMITED
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * World shared memory definitions.
+ */
#ifndef CWSM_H_
#define CWSM_H_
@@ -53,7 +51,7 @@ public:
uint32_t len,
uint32_t handle,
// this may be unknown, so is can be omitted.
- uint64_t physAddr = NULL) :
+ uint64_t physAddr = 0x0) :
virtAddr(virtAddr),
len(len),
handle(handle),
@@ -68,4 +66,3 @@ typedef wsmList_t::iterator wsmIterator_t;
#endif /* CWSM_H_ */
-/** @} */
diff --git a/mobicore/daemon/Common/Connection.cpp b/mobicore/MobiCoreDriverLib/Common/Connection.cpp
index 7613a6b..51520f8 100644
--- a/mobicore/daemon/Common/Connection.cpp
+++ b/mobicore/MobiCoreDriverLib/Common/Connection.cpp
@@ -1,10 +1,5 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * Connection data.
- *
- * Copyright (c) 2013 TRUSTONIC LIMITED
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Connection data.
+ */
#include <unistd.h>
#include <assert.h>
#include <cstring>
@@ -64,12 +62,12 @@ Connection::Connection(void)
//------------------------------------------------------------------------------
Connection::Connection(int socketDescriptor, sockaddr_un *remote)
{
- assert(NULL != remote);
assert(-1 != socketDescriptor);
this->socketDescriptor = socketDescriptor;
this->remote = *remote;
connectionData = NULL;
+ detached = false;
}
@@ -92,7 +90,6 @@ 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;
@@ -118,21 +115,21 @@ bool Connection::connect(const char *dest)
//------------------------------------------------------------------------------
-size_t Connection::readData(void *buffer, uint32_t len)
+ssize_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)
+ssize_t Connection::readData(void *buffer, uint32_t len, int32_t timeout)
{
- size_t ret = 0;
+ int ret_s;
+ ssize_t ret = 0;
struct timeval tv;
struct timeval *ptv = NULL;
fd_set readfds;
- assert(NULL != buffer);
assert(socketDescriptor != -1);
if (timeout >= 0) {
@@ -144,16 +141,16 @@ size_t Connection::readData(void *buffer, uint32_t len, int32_t timeout)
FD_ZERO(&readfds);
FD_SET(socketDescriptor, &readfds);
- ret = select(socketDescriptor + 1, &readfds, NULL, NULL, ptv);
+ ret_s = select(socketDescriptor + 1, &readfds, NULL, NULL, ptv);
// check for read error
- if ((int)ret == -1) {
+ if (ret_s == -1) {
LOG_ERRNO("select");
return -1;
}
// Handle case of no descriptor ready
- if (ret == 0) {
+ if (ret_s == 0) {
LOG_W(" Timeout during select() / No more notifications.");
return -2;
}
@@ -163,7 +160,7 @@ size_t Connection::readData(void *buffer, uint32_t len, int32_t timeout)
// finally check if fd has been selected -> must socketDescriptor
if (!FD_ISSET(socketDescriptor, &readfds)) {
LOG_ERRNO("no fd is set, select");
- return ret;
+ return ret_s;
}
ret = recv(socketDescriptor, buffer, len, MSG_DONTWAIT);
@@ -176,15 +173,14 @@ size_t Connection::readData(void *buffer, uint32_t len, int32_t timeout)
//------------------------------------------------------------------------------
-size_t Connection::writeData(void *buffer, uint32_t len)
+ssize_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) {
+ ssize_t ret = send(socketDescriptor, buffer, len, 0);
+ if ((uint32_t)ret != len) {
LOG_ERRNO("could not send all data, because send");
- LOG_E("ret = %d", ret);
+ LOG_E("ret = %d", (uint32_t)ret);
ret = -1;
}
@@ -246,7 +242,7 @@ bool Connection::isConnectionAlive(void)
bool Connection::getPeerCredentials(struct ucred &cr)
{
struct ucred cred;
- int len = sizeof (cred);
+ socklen_t len = sizeof (cred);
assert(socketDescriptor != -1);
int ret = getsockopt(socketDescriptor, SOL_SOCKET, SO_PEERCRED, &cred,
&len);
@@ -260,4 +256,4 @@ bool Connection::getPeerCredentials(struct ucred &cr)
}
return false;
}
-/** @} */
+
diff --git a/mobicore/daemon/Common/Connection.h b/mobicore/MobiCoreDriverLib/Common/Connection.h
index 89bc585..243168c 100644
--- a/mobicore/daemon/Common/Connection.h
+++ b/mobicore/MobiCoreDriverLib/Common/Connection.h
@@ -1,9 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * Connection data.
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Connection data.
+ */
#ifndef CONNECTION_H_
#define CONNECTION_H_
@@ -78,7 +76,7 @@ public:
* @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);
+ virtual ssize_t readData(void *buffer, uint32_t len, int32_t timeout);
/**
* Read bytes from the connection.
@@ -87,7 +85,7 @@ public:
* @param len Number of bytes to read.
* @return Number of bytes read.
*/
- virtual size_t readData(void *buffer, uint32_t len);
+ virtual ssize_t readData(void *buffer, uint32_t len);
/**
* Write bytes to the connection.
@@ -97,7 +95,7 @@ public:
* @return Number of bytes written.
* @return -1 if written bytes not equal to len.
*/
- virtual size_t writeData(void *buffer, uint32_t len);
+ virtual ssize_t writeData(void *buffer, uint32_t len);
/**
* Wait for data to be available.
@@ -130,4 +128,3 @@ typedef connectionList_t::iterator connectionIterator_t;
#endif /* CONNECTION_H_ */
-/** @} */
diff --git a/mobicore/daemon/Common/McTypes.h b/mobicore/MobiCoreDriverLib/Common/McTypes.h
index 6e8989e..743174a 100644
--- a/mobicore/daemon/Common/McTypes.h
+++ b/mobicore/MobiCoreDriverLib/Common/McTypes.h
@@ -1,9 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * MobiCore types redefinition.
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * MobiCore types redefinition.
+ */
#ifndef MCTYPES_H_
#define MCTYPES_H_
@@ -40,4 +38,3 @@ typedef void *addr_t;
#endif /* MCTYPES_H_ */
-/** @} */
diff --git a/mobicore/MobiCoreDriverLib/Common/NOTICE b/mobicore/MobiCoreDriverLib/Common/NOTICE
new file mode 100644
index 0000000..627167a
--- /dev/null
+++ b/mobicore/MobiCoreDriverLib/Common/NOTICE
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
diff --git a/mobicore/daemon/Common/NetlinkConnection.cpp b/mobicore/MobiCoreDriverLib/Common/NetlinkConnection.cpp
index f91d4e9..3e911d4 100644
--- a/mobicore/daemon/Common/NetlinkConnection.cpp
+++ b/mobicore/MobiCoreDriverLib/Common/NetlinkConnection.cpp
@@ -1,10 +1,5 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * Connection data.
- *
- * Copyright (c) 2013 TRUSTONIC LIMITED
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Connection data.
+ */
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
@@ -168,7 +166,7 @@ void NetlinkConnection::handleMessage(
}
//------------------------------------------------------------------------------
-size_t NetlinkConnection::readData(
+ssize_t NetlinkConnection::readData(
void *buffer,
uint32_t len
)
@@ -178,14 +176,13 @@ size_t NetlinkConnection::readData(
//------------------------------------------------------------------------------
-size_t NetlinkConnection::readData(
+ssize_t NetlinkConnection::readData(
void *buffer,
uint32_t len,
int32_t timeout
)
{
- size_t ret = -1;
- assert(NULL != buffer);
+ ssize_t ret = -1;
if (!dataLeft.wait(timeout)) {
return -2;
@@ -200,15 +197,14 @@ size_t NetlinkConnection::readData(
//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;
+ ret = (ssize_t)dataLen;
memcpy(buffer, dataStart, dataLen);
dataLen = 0;
} else {
- ret = len;
+ ret = (ssize_t)len;
memcpy(buffer, dataStart, len);
dataLen -= len;
dataStart += len;
@@ -229,18 +225,17 @@ size_t NetlinkConnection::readData(
}
//------------------------------------------------------------------------------
-size_t NetlinkConnection::writeData(
+ssize_t NetlinkConnection::writeData(
void *buffer,
uint32_t len
)
{
- size_t ret;
+ ssize_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);
@@ -279,12 +274,12 @@ size_t NetlinkConnection::writeData(
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));
+ __FUNCTION__, (uint32_t)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;
+ ret = (ssize_t)len;
}
free(nlh);
@@ -292,4 +287,3 @@ size_t NetlinkConnection::writeData(
return ret;
}
-/** @} */
diff --git a/mobicore/daemon/Common/NetlinkConnection.h b/mobicore/MobiCoreDriverLib/Common/NetlinkConnection.h
index 5be3f30..45b3952 100644
--- a/mobicore/daemon/Common/NetlinkConnection.h
+++ b/mobicore/MobiCoreDriverLib/Common/NetlinkConnection.h
@@ -1,9 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * Connection data.
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Connection data.
+ */
#ifndef NETLINKCONNECTION_H_
#define NETLINKCONNECTION_H_
@@ -167,7 +165,7 @@ public:
* @return -1 if select() failed (returned -1)
* @return -2 if no data available, i.e. timeout
*/
- virtual size_t readData(
+ virtual ssize_t readData(
void *buffer,
uint32_t len,
int32_t timeout
@@ -180,7 +178,7 @@ public:
* @param len Number of bytes to read.
* @return Number of bytes read.
*/
- virtual size_t readData(
+ virtual ssize_t readData(
void *buffer,
uint32_t len
);
@@ -192,7 +190,7 @@ public:
* @param len Number of bytes to read.
* @return Number of bytes written.
*/
- virtual size_t writeData(
+ virtual ssize_t writeData(
void *buffer,
uint32_t len
);
@@ -220,4 +218,3 @@ typedef std::map<uint64_t, NetlinkConnection *> connectionMap_t;
#endif /* NETLINKCONNECTION_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/Android.mk b/mobicore/MobiCoreDriverLib/Daemon/Android.mk
index e9873bd..e9873bd 100644
--- a/mobicore/daemon/Daemon/Android.mk
+++ b/mobicore/MobiCoreDriverLib/Daemon/Android.mk
diff --git a/mobicore/daemon/Daemon/Device/Android.mk b/mobicore/MobiCoreDriverLib/Daemon/Device/Android.mk
index 6a22222..e830526 100644
--- a/mobicore/daemon/Daemon/Device/Android.mk
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/Android.mk
@@ -22,4 +22,4 @@ LOCAL_SRC_FILES += $(DEVICE_PATH)/DeviceIrqHandler.cpp \
$(DEVICE_PATH)/TAExitHandler.cpp \
$(DEVICE_PATH)/MobiCoreDevice.cpp \
$(DEVICE_PATH)/NotificationQueue.cpp \
- $(DEVICE_PATH)/TrustletSession.cpp
+ $(DEVICE_PATH)/TrustletSession.cpp \
diff --git a/mobicore/daemon/Daemon/Device/DeviceIrqHandler.cpp b/mobicore/MobiCoreDriverLib/Daemon/Device/DeviceIrqHandler.cpp
index 877e2da..9eb5722 100644
--- a/mobicore/daemon/Daemon/Device/DeviceIrqHandler.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/DeviceIrqHandler.cpp
@@ -1,8 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- *
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -32,7 +28,6 @@
* 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"
@@ -45,4 +40,3 @@ void DeviceIrqHandler::run(
this->exit(-1);
}
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/DeviceIrqHandler.h b/mobicore/MobiCoreDriverLib/Daemon/Device/DeviceIrqHandler.h
index 449e2af..b6c5eab 100644
--- a/mobicore/daemon/Daemon/Device/DeviceIrqHandler.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/DeviceIrqHandler.h
@@ -1,9 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- *
- * IRQ handler thread.
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * IRQ handler thread.
+ */
#ifndef DEVICEIRQHANDLER_H_
#define DEVICEIRQHANDLER_H_
@@ -52,4 +50,3 @@ public:
#endif /* DEVICEIRQHANDLER_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/DeviceScheduler.cpp b/mobicore/MobiCoreDriverLib/Daemon/Device/DeviceScheduler.cpp
index 1481c3c..3e25598 100644
--- a/mobicore/daemon/Daemon/Device/DeviceScheduler.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/DeviceScheduler.cpp
@@ -1,8 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- *
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -32,7 +28,6 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
#include "DeviceScheduler.h"
@@ -45,4 +40,3 @@ void DeviceScheduler::run(
exit(-1);
}
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/DeviceScheduler.h b/mobicore/MobiCoreDriverLib/Daemon/Device/DeviceScheduler.h
index 3b818bf..9b76c66 100644
--- a/mobicore/daemon/Daemon/Device/DeviceScheduler.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/DeviceScheduler.h
@@ -1,9 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- *
- * Scheduler thread
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -33,7 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+/**
+ * Scheduler thread
+ */
#ifndef DEVICESCHEDULER_H_
#define DEVICESCHEDULER_H_
@@ -53,4 +50,3 @@ public:
#endif /* DEVICESCHEDULER_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/MobiCoreDevice.cpp b/mobicore/MobiCoreDriverLib/Daemon/Device/MobiCoreDevice.cpp
index 72cf665..503496e 100644
--- a/mobicore/daemon/Daemon/Device/MobiCoreDevice.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/MobiCoreDevice.cpp
@@ -1,10 +1,5 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- */
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,7 +28,6 @@
* 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>
@@ -41,7 +35,6 @@
#include "DeviceScheduler.h"
#include "DeviceIrqHandler.h"
-#include "ExcDevice.h"
#include "Connection.h"
#include "TrustletSession.h"
@@ -95,24 +88,26 @@ TrustletSession *MobiCoreDevice::getTrustletSession(
//------------------------------------------------------------------------------
-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;
-}
+//Connection *MobiCoreDevice::getSessionConnection(
+// uint32_t sessionId,
+// notification_t *notification
+//) {
+// Connection *con = NULL;
+//
+// mutex_tslist.lock();
+// TrustletSession *session = getTrustletSession(sessionId);
+// if (session != NULL)
+// {
+// con = session->notificationConnection;
+// if (con == NULL)
+// {
+// session->queueNotification(notification);
+// }
+// }
+// mutex_tslist.unlock();
+//
+// return con;
+//}
//------------------------------------------------------------------------------
@@ -120,20 +115,22 @@ TrustletSession* MobiCoreDevice::findSession(
Connection *deviceConnection,
uint32_t sessionId
) {
+ mutex_tslist.lock();
TrustletSession *session = getTrustletSession(sessionId);
if (session == NULL)
{
- LOG_E("no session found with id=%d", sessionId);
+ LOG_E("no session found with id %03x", sessionId);
}
else
{
// check is connection own this session
if (session->deviceConnection != deviceConnection)
{
- LOG_E("connection does not own session id=%d", sessionId);
+ LOG_E("connection does not own session id %03x", sessionId);
session = NULL;
}
}
+ mutex_tslist.unlock();
return session;
}
@@ -184,14 +181,19 @@ mcResult_t MobiCoreDevice::sendSessionCloseCmd(
mcResult_t MobiCoreDevice::closeSessionInternal(
TrustletSession *session
) {
- LOG_I("closing session with id=%d", session->sessionId);
+ LOG_I("closing session %03x", 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);
+ switch(mcRet){
+ case MC_MCP_RET_OK:
+ return mcRet;
+ case MC_MCP_RET_ERR_CLOSE_TASK_FAILED:
+ LOG_I("sendSessionCloseCmd failed");
+ break;
+ default:
+ LOG_E("sendSessionCloseCmd error %d", mcRet);
+ break;
}
-
// // clean session WSM
// LOG_I("unlocking session buffers!");
// CWsm_ptr pWsm = session->popBulkBuff();
@@ -202,7 +204,7 @@ mcResult_t MobiCoreDevice::closeSessionInternal(
// pWsm = session->popBulkBuff();
// }
- return MC_DRV_OK;
+ return MAKE_MC_DRV_MCP_ERROR(mcRet);
}
//------------------------------------------------------------------------------
@@ -272,7 +274,7 @@ void MobiCoreDevice::close(
// After the trustlet is done make sure to tell the driver to cleanup
// all the orphaned drivers
- cleanupWsmL2();
+ //cleanupWsmL2();
@@ -306,11 +308,12 @@ void MobiCoreDevice::start(void)
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);
+ // Remove all pending sessions. In <t-base-301, there is a maximum of 32 sessions.
+ // Few sessions in the start are reserved by the system.
+#define LOG_SOURCE_TASK_SHIFT 8
+ for (int sessionNumber = 3; sessionNumber<32; sessionNumber++) {
+ int sessionId = ((sessionNumber<<LOG_SOURCE_TASK_SHIFT)+1);
+ LOG_I("invalidating session %03x", sessionId);
mcResult_t mcRet = sendSessionCloseCmd(sessionId);
if (mcRet != MC_MCP_RET_OK) {
LOG_I("sendSessionCloseCmd error %d", mcRet);
@@ -361,33 +364,46 @@ bool MobiCoreDevice::waitMcpNotification(void)
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;
+ } // while(1)
+
+ // Check healthiness state of the device
+ if (DeviceIrqHandler::isExiting() ||
+ DeviceScheduler::isExiting() ||
+ TAExitHandler::isExiting())
+ {
+ LOG_I("waitMcpNotification(): Threads state:");
+ LOG_I("Irq handler : %s", (DeviceIrqHandler::isExiting()==true)?"running":"exit");
+ LOG_I("Scheduler : %s", (DeviceScheduler::isExiting()==true)?"running":"exit");
+ LOG_I("Exit handler: %s", (TAExitHandler::isExiting()==true)?"running":"exit");
+
+ //There is no CThread::wait() so no need to wake up
+ LOG_I("waitMcpNotification(): IrqHandler thread should exit automatically");
+
+ DeviceScheduler::terminate();
+ //Cancel waiting just in case.
+ DeviceScheduler::wakeup();
+ LOG_I("waitMcpNotification(): terminate Scheduler thread");
+
+ TAExitHandler::terminate();
+ //Cancel waiting just in case.
+ TAExitHandler::wakeup();
+ LOG_I("waitMcpNotification(): terminate Exit handler thread");
+
+ DeviceIrqHandler::join();
+ LOG_I("waitMcpNotification(): IrqHandler joined");
+ LOG_E("IrqHandler thread died!");
+
+ DeviceScheduler::join();
+ LOG_I("waitMcpNotification(): Scheduler Joined");
+ LOG_E("Scheduler thread died!");
+
+ TAExitHandler::join();
+ LOG_I("waitMcpNotification(): Exit handler Joined");
+ LOG_E("TAExitHandler thread died!");
+
+ return false;
+ }
+ return true;
}
@@ -512,18 +528,22 @@ mcResult_t MobiCoreDevice::openSession(
deviceConnection,
mcpMessage->rspOpen.sessionId);
+ // Security TODO: device connection peer has to match the NQ connection peer
+ // The check here is not 100% correct
pRspOpenSessionPayload->sessionId = trustletSession->sessionId;
- pRspOpenSessionPayload->deviceSessionId = (uint32_t)trustletSession;
+ pRspOpenSessionPayload->deviceSessionId = (uint32_t)((uintptr_t)trustletSession & UINT_MAX);
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;
+ mutex_tslist.lock();
trustletSessions.push_back(trustletSession);
+ mutex_tslist.unlock();
if (tciHandle != 0 && tciLen != 0) {
- trustletSession->addBulkBuff(new CWsm((void *)pLoadDataOpenSession->offs, pLoadDataOpenSession->len, tciHandle, 0));
+ trustletSession->addBulkBuff(new CWsm(NULL, pLoadDataOpenSession->len, tciHandle, 0));
}
// We have some queued notifications and we need to send them to them
@@ -594,19 +614,20 @@ TrustletSession *MobiCoreDevice::registerTrustletConnection(
MC_DRV_CMD_NQ_CONNECT_struct *cmdNqConnect
)
{
- LOG_I(" Registering notification socket with Service session %d.",
+ LOG_I(" Registering notification socket with Service session %03x.",
cmdNqConnect->sessionId);
- LOG_V(" Searching sessionId %d with sessionMagic %d",
+ LOG_V(" Searching sessionId %03x with sessionMagic %d",
cmdNqConnect->sessionId,
cmdNqConnect->sessionMagic);
+
for (trustletSessionIterator_t iterator = trustletSessions.begin();
iterator != trustletSessions.end();
++iterator)
{
TrustletSession *session = *iterator;
- if (session != (TrustletSession *) (cmdNqConnect->deviceSessionId)) {
+ if (((uintptr_t)session & UINT_MAX) != cmdNqConnect->deviceSessionId) {
continue;
}
@@ -619,9 +640,11 @@ TrustletSession *MobiCoreDevice::registerTrustletConnection(
LOG_I(" Found Service session, registered connection.");
+
return session;
}
+
LOG_I("registerTrustletConnection(): search failed");
return NULL;
}
@@ -638,7 +661,7 @@ mcResult_t MobiCoreDevice::closeSession(
) {
TrustletSession *session = findSession(deviceConnection,sessionId);
if (session == NULL) {
- LOG_E("cannot close session with id=%d", sessionId);
+ LOG_E("cannot close session %03x", sessionId);
return MC_DRV_ERR_DAEMON_UNKNOWN_SESSION;
}
@@ -678,7 +701,15 @@ mcResult_t MobiCoreDevice::closeSession(
return MAKE_MC_DRV_MCP_ERROR(mcRet);
}
+ freeSession(session);
+
+ return MC_MCP_RET_OK;
+}
+
+void MobiCoreDevice::freeSession(
+ TrustletSession *session
+) {
// clean session WSM
LOG_I("unlocking session buffers!");
CWsm_ptr pWsm = session->popBulkBuff();
@@ -689,20 +720,11 @@ mcResult_t MobiCoreDevice::closeSession(
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;
+ // remove session from list.
+ mutex_tslist.lock();
+ trustletSessions.remove(session);
+ mutex_tslist.unlock();
+ delete session;
}
@@ -721,7 +743,7 @@ mcResult_t MobiCoreDevice::notify(
TrustletSession *session = findSession(deviceConnection,sessionId);
if (session == NULL)
{
- LOG_E("cannot notify session with id=%d", sessionId);
+ LOG_E("cannot notify session %03x", sessionId);
return MC_DRV_ERR_DAEMON_UNKNOWN_SESSION;
}
@@ -742,14 +764,14 @@ mcResult_t MobiCoreDevice::mapBulk(
) {
TrustletSession *session = findSession(deviceConnection,sessionId);
if (session == NULL) {
- LOG_E("cannot mapBulk on session with id=%d", sessionId);
+ LOG_E("cannot mapBulk on session %03x", 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 *)offsetPayload,
+ new CWsm(NULL,
lenBulkMem,
handle,
pAddrL2));
@@ -797,7 +819,7 @@ mcResult_t MobiCoreDevice::unmapBulk(
) {
TrustletSession *session = findSession(deviceConnection,sessionId);
if (session == NULL) {
- LOG_E("cannot unmapBulk on session with id=%d", sessionId);
+ LOG_E("cannot unmapBulk on session %03x", sessionId);
return MC_DRV_ERR_DAEMON_UNKNOWN_SESSION;
}
@@ -928,4 +950,3 @@ mcResult_t MobiCoreDevice::loadToken(Connection *deviceConnection,
return MC_DRV_OK;
}
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/NotificationQueue.cpp b/mobicore/MobiCoreDriverLib/Daemon/Device/NotificationQueue.cpp
index a034c4c..5b4d872 100644
--- a/mobicore/daemon/Daemon/Device/NotificationQueue.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/NotificationQueue.cpp
@@ -1,8 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- *
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -79,4 +75,3 @@ notification_t *NotificationQueue::getNotification(
return ret;
}
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/NotificationQueue.h b/mobicore/MobiCoreDriverLib/Daemon/Device/NotificationQueue.h
index cd004bb..0f4aee8 100644
--- a/mobicore/daemon/Daemon/Device/NotificationQueue.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/NotificationQueue.h
@@ -1,9 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- *
- * MobiCore Notification Queue handling.
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -33,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * MobiCore Notification Queue handling.
+ */
#ifndef NOTIFICATIONQUEUE_H_
#define NOTIFICATIONQUEUE_H_
@@ -87,4 +85,3 @@ private:
#endif /* NOTIFICATIONQUEUE_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/Platforms/Android.mk b/mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Android.mk
index 48dd98a..48dd98a 100644
--- a/mobicore/daemon/Daemon/Device/Platforms/Android.mk
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Android.mk
diff --git a/mobicore/daemon/Daemon/Device/Platforms/Generic/Android.mk b/mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Generic/Android.mk
index a6607de..a6607de 100644
--- a/mobicore/daemon/Daemon/Device/Platforms/Generic/Android.mk
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Generic/Android.mk
diff --git a/mobicore/daemon/Daemon/Device/Platforms/Generic/TrustZoneDevice.cpp b/mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Generic/TrustZoneDevice.cpp
index 1f8359a..c1fc978 100644
--- a/mobicore/daemon/Daemon/Device/Platforms/Generic/TrustZoneDevice.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Generic/TrustZoneDevice.cpp
@@ -1,10 +1,5 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- */
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,7 +28,6 @@
* 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>
@@ -61,6 +55,12 @@
#define MCI_BUFFER_SIZE (NQ_BUFFER_SIZE + MCP_BUFFER_SIZE)
//------------------------------------------------------------------------------
+MC_CHECK_VERSION(MCI, 0, 2);
+
+//------------------------------------------------------------------------------
+#define LOG_I_RELEASE(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+
+//------------------------------------------------------------------------------
__attribute__ ((weak)) MobiCoreDevice *getDeviceInstance(
void
)
@@ -128,6 +128,12 @@ bool TrustZoneDevice::initDevice(
}
mciBuffer = pWsmMcp->virtAddr;
+ if (!checkMciVersion())
+ {
+ LOG_E("checkMciVersion failed");
+ return false;
+ }
+
// Only do a fastcall if MCI has not been reused (MC already initialized)
if (!mciReused)
{
@@ -257,7 +263,7 @@ bool TrustZoneDevice::nsiq(
return false;
}
// now we have to wake the scheduler, so <t-base gets CPU time.
- schedSync.signal();
+ DeviceScheduler::wakeup();
return true;
}
@@ -269,14 +275,13 @@ void TrustZoneDevice::notify(
{
// 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);
+// // 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 %03x", sessionId);
+// return;
+// }
+ LOG_I(" Sending notification for session %03x to <t-base", sessionId);
} else {
LOG_I(" Sending MCP notification to <t-base");
}
@@ -290,13 +295,13 @@ void TrustZoneDevice::notify(
//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();
+ (void)nsiq();
}
//------------------------------------------------------------------------------
uint32_t TrustZoneDevice::getMobicoreStatus(void)
{
- uint32_t status;
+ uint32_t status = MC_STATUS_NOT_INITIALIZED;
//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);
@@ -305,53 +310,76 @@ uint32_t TrustZoneDevice::getMobicoreStatus(void)
}
//------------------------------------------------------------------------------
+bool TrustZoneDevice::checkMciVersion(void)
+{
+ uint32_t version = 0;
+ int ret;
+ char *errmsg;
+
+ ret = pMcKMod->fcInfo(MC_EXT_INFO_ID_MCI_VERSION, NULL, &version);
+ if (ret != 0) {
+ LOG_E("pMcKMod->fcInfo() failed with %d", ret);
+ return false;
+ }
+
+ // Run-time check.
+ if (!checkVersionOkMCI(version, &errmsg)) {
+ LOG_E("%s", errmsg);
+ return false;
+ }
+ LOG_I("%s", errmsg);
+ return true;
+}
+
+//------------------------------------------------------------------------------
void TrustZoneDevice::dumpMobicoreStatus(
void
) {
- uint32_t status, info;
+ uint32_t status = MC_STATUS_NOT_INITIALIZED;
+ uint32_t info = 0;
// 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);
+ LOG_I_RELEASE(" flags = 0x%08x", info);
pMcKMod->fcInfo(2, &status, &info);
- LOG_W(" haltCode = 0x%08x", info);
+ LOG_I_RELEASE(" haltCode = 0x%08x", info);
pMcKMod->fcInfo(3, &status, &info);
- LOG_W(" haltIp = 0x%08x", info);
+ LOG_I_RELEASE(" haltIp = 0x%08x", info);
pMcKMod->fcInfo(4, &status, &info);
- LOG_W(" faultRec.cnt = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.cnt = 0x%08x", info);
pMcKMod->fcInfo(5, &status, &info);
- LOG_W(" faultRec.cause = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.cause = 0x%08x", info);
pMcKMod->fcInfo(6, &status, &info);
- LOG_W(" faultRec.meta = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.meta = 0x%08x", info);
pMcKMod->fcInfo(7, &status, &info);
- LOG_W(" faultRec.thread = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.thread = 0x%08x", info);
pMcKMod->fcInfo(8, &status, &info);
- LOG_W(" faultRec.ip = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.ip = 0x%08x", info);
pMcKMod->fcInfo(9, &status, &info);
- LOG_W(" faultRec.sp = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.sp = 0x%08x", info);
pMcKMod->fcInfo(10, &status, &info);
- LOG_W(" faultRec.arch.dfsr = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.arch.dfsr = 0x%08x", info);
pMcKMod->fcInfo(11, &status, &info);
- LOG_W(" faultRec.arch.adfsr = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.arch.adfsr = 0x%08x", info);
pMcKMod->fcInfo(12, &status, &info);
- LOG_W(" faultRec.arch.dfar = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.arch.dfar = 0x%08x", info);
pMcKMod->fcInfo(13, &status, &info);
- LOG_W(" faultRec.arch.ifsr = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.arch.ifsr = 0x%08x", info);
pMcKMod->fcInfo(14, &status, &info);
- LOG_W(" faultRec.arch.aifsr = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.arch.aifsr = 0x%08x", info);
pMcKMod->fcInfo(15, &status, &info);
- LOG_W(" faultRec.arch.ifar = 0x%08x", info);
+ LOG_I_RELEASE(" faultRec.arch.ifar = 0x%08x", info);
pMcKMod->fcInfo(16, &status, &info);
- LOG_W(" mcData.flags = 0x%08x", info);
+ LOG_I_RELEASE(" mcData.flags = 0x%08x", info);
pMcKMod->fcInfo(19, &status, &info);
- LOG_W(" mcExcep.partner = 0x%08x", info);
+ LOG_I_RELEASE(" mcExcep.partner = 0x%08x", info);
pMcKMod->fcInfo(20, &status, &info);
- LOG_W(" mcExcep.peer = 0x%08x", info);
+ LOG_I_RELEASE(" mcExcep.peer = 0x%08x", info);
pMcKMod->fcInfo(21, &status, &info);
- LOG_W(" mcExcep.message = 0x%08x", info);
+ LOG_I_RELEASE(" mcExcep.cause = 0x%08x", info);
pMcKMod->fcInfo(22, &status, &info);
- LOG_W(" mcExcep.data = 0x%08x", info);
+ LOG_I_RELEASE(" mcExcep.meta = 0x%08x", info);
}
//------------------------------------------------------------------------------
@@ -370,22 +398,20 @@ bool TrustZoneDevice::waitSsiq(void)
//------------------------------------------------------------------------------
bool TrustZoneDevice::getMciInstance(uint32_t len, CWsm_ptr *mci, bool *reused)
{
- addr_t virtAddr;
- uint32_t handle;
- uint64_t physAddr;
+ addr_t virtAddr = NULL;
bool isReused = true;
if (len == 0) {
LOG_E("allocateWsm() length is 0");
return false;
}
- mcResult_t ret = pMcKMod->mapMCI(len, &handle, &virtAddr, &physAddr, &isReused);
+ mcResult_t ret = pMcKMod->mapMCI(len, &virtAddr, &isReused);
if (ret != MC_DRV_OK) {
LOG_E("pMcKMod->mmap() failed: %x", ret);
return false;
}
- *mci = new CWsm(virtAddr, len, handle, physAddr);
+ *mci = new CWsm(virtAddr, len, 0, 0);
*reused = isReused;
return true;
}
@@ -407,8 +433,8 @@ bool TrustZoneDevice::getMciInstance(uint32_t len, CWsm_ptr *mci, bool *reused)
//------------------------------------------------------------------------------
CWsm_ptr TrustZoneDevice::registerWsmL2(addr_t buffer, uint32_t len, uint32_t pid)
{
- uint64_t physAddr;
- uint32_t handle;
+ uint64_t physAddr = 0;
+ uint32_t handle = 0;
int ret = pMcKMod->registerWsmL2(
buffer,
@@ -430,18 +456,17 @@ CWsm_ptr TrustZoneDevice::allocateContiguousPersistentWsm(uint32_t len)
{
CWsm_ptr pWsm = NULL;
// Allocate shared memory
- addr_t virtAddr;
- uint32_t handle;
- uint64_t physAddr;
+ addr_t virtAddr = NULL;
+ uint32_t handle = 0;
if (len == 0 )
return NULL;
- if (pMcKMod->mapWsm(len, &handle, &virtAddr, &physAddr))
+ if (pMcKMod->mapWsm(len, &handle, &virtAddr))
return NULL;
// Register (vaddr,paddr) with device
- pWsm = new CWsm(virtAddr, len, handle, physAddr);
+ pWsm = new CWsm(virtAddr, len, handle, 0);
// Return pointer to the allocated memory
return pWsm;
@@ -452,12 +477,13 @@ CWsm_ptr TrustZoneDevice::allocateContiguousPersistentWsm(uint32_t len)
bool TrustZoneDevice::unregisterWsmL2(CWsm_ptr pWsm)
{
int ret = pMcKMod->unregisterWsmL2(pWsm->handle);
+ /* Free pWsm in all the cases */
+ delete pWsm;
+
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;
}
@@ -549,7 +575,9 @@ void TrustZoneDevice::schedule(void)
{
// <t-base is IDLE. Prevent unnecessary consumption of CPU cycles
// and wait for S-SIQ
- schedSync.wait(); // check return code?
+ DeviceScheduler::sleep();
+ if (DeviceScheduler::shouldTerminate())
+ break;
continue;
}
@@ -585,7 +613,9 @@ void TrustZoneDevice::handleTaExit(void)
LOG_I("Starting Trusted Application Exit handler...");
for (;;) {
// Wait until we get a notification without CA
- taExitNotification.wait();
+ TAExitHandler::sleep();
+ if (TAExitHandler::shouldTerminate())
+ break;
// Wait until socket server frees MCP
// Make sure we don't interfere with handleConnection/dropConnection
@@ -593,29 +623,32 @@ void TrustZoneDevice::handleTaExit(void)
// 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);
+ for (;;) {
+ mutex_tslist.lock();
+ TrustletSession* ts = NULL;
+ for (trustletSessionList_t::iterator it = trustletSessions.begin(); it != trustletSessions.end(); it++) {
+ if ((*it)->sessionState == TrustletSession::TS_TA_DEAD) {
+ ts = *it;
+ break;
}
}
- ++iterator;
+ mutex_tslist.unlock();
+ if (!ts) {
+ break;
+ }
+#ifndef NDEBUG
+ uint32_t sessionId = ts->sessionId;
+#endif
+ LOG_I("Cleaning up session %03x", sessionId);
+ // Tell t-base to close the session (list gets locked in handleIrq() when MCP replies)
+ mcResult_t mcRet = closeSessionInternal(ts);
+ // If ok, remove objects
+ if (mcRet == MC_DRV_OK) {
+ freeSession(ts);
+ LOG_I("TA session %03x finally closed", sessionId);
+ } else {
+ LOG_I("TA session %03x could not be closed yet.", sessionId);
+ }
}
mutex_mcp.unlock();
}
@@ -667,12 +700,13 @@ void TrustZoneDevice::handleIrq(
continue;
}
- LOG_I(" Notification for session %d, payload=%d",
+ LOG_I(" Notification for session %03x, payload=%d",
notification->sessionId, notification->payload);
// Get the Trustlet session for the session ID
TrustletSession *ts = NULL;
+ mutex_tslist.lock();
ts = getTrustletSession(notification->sessionId);
if (ts == NULL) {
/* Couldn't find the session for this notifications
@@ -691,7 +725,7 @@ void TrustZoneDevice::handleIrq(
ts->queueNotification(notification);
if (ts->deviceConnection == NULL) {
LOG_I(" Notification for disconnected client, scheduling cleanup of sessions.");
- taExitNotification.signal();
+ TAExitHandler::wakeup();
}
} else {
LOG_I(" Forward notification to McClient.");
@@ -702,13 +736,14 @@ void TrustZoneDevice::handleIrq(
}
mutex_connection.unlock();
}
+ mutex_tslist.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();
+ DeviceScheduler::wakeup();
} //for (;;)
@@ -719,4 +754,4 @@ void TrustZoneDevice::handleIrq(
DeviceIrqHandler::setExiting();
signalMcpNotification();
}
-/** @} */
+
diff --git a/mobicore/daemon/Daemon/Device/Platforms/Generic/TrustZoneDevice.h b/mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Generic/TrustZoneDevice.h
index a895fa2..36c5e37 100644
--- a/mobicore/daemon/Daemon/Device/Platforms/Generic/TrustZoneDevice.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/Platforms/Generic/TrustZoneDevice.h
@@ -1,12 +1,5 @@
-/** @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
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +28,11 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Class for TrustZone Devices.
+ * TrustZone device implements communication functions needed for
+ * accessing MobiCore located in an TrustZone environment.
+ */
#ifndef TRUSTZONEDEVICE_H_
#define TRUSTZONEDEVICE_H_
@@ -47,7 +45,6 @@
#include "CMcKMod.h"
#include "CWsm.h"
-#include "ExcDevice.h"
#include "MobiCoreDevice.h"
@@ -58,7 +55,6 @@ 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 */
@@ -112,6 +108,7 @@ public:
CWsm_ptr registerWsmL2(addr_t buffer, uint32_t len, uint32_t pid);
+ /* pWsm is freed even in case of error */
bool unregisterWsmL2(CWsm_ptr pWsm);
bool lockWsmL2(uint32_t handle);
@@ -145,4 +142,3 @@ public:
#endif /* TRUSTZONEDEVICE_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/TAExitHandler.cpp b/mobicore/MobiCoreDriverLib/Daemon/Device/TAExitHandler.cpp
index cf60b04..93c66e9 100644
--- a/mobicore/daemon/Daemon/Device/TAExitHandler.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/TAExitHandler.cpp
@@ -1,8 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- *
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -32,7 +28,6 @@
* 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"
@@ -45,4 +40,3 @@ void TAExitHandler::run(
this->exit(-1);
}
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/TAExitHandler.h b/mobicore/MobiCoreDriverLib/Daemon/Device/TAExitHandler.h
index 037cd12..ac69a5c 100644
--- a/mobicore/daemon/Daemon/Device/TAExitHandler.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/TAExitHandler.h
@@ -1,10 +1,5 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- *
- * Trusted Application exit handler thread.
- *
- * Copyright (c) 2013 TRUSTONIC LIMITED
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,7 +28,6 @@
* 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_
@@ -45,8 +39,6 @@
class TAExitHandler: public CThread
{
public:
- CSemaphore taExitNotification;
-
virtual void handleTaExit() = 0;
void run();
@@ -54,4 +46,3 @@ public:
#endif /* TAEXITHANDLER_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/TrustletSession.cpp b/mobicore/MobiCoreDriverLib/Daemon/Device/TrustletSession.cpp
index d0bd1e0..1d05645 100644
--- a/mobicore/daemon/Daemon/Device/TrustletSession.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/TrustletSession.cpp
@@ -1,7 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -31,7 +28,6 @@
* 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>
@@ -73,7 +69,7 @@ void TrustletSession::queueNotification(notification_t *notification)
return;
}
if ((gp_level == 1) && (notification->payload != 0)) {
- LOG_I(" Mark session %i dead", sessionId);
+ LOG_I(" Mark session %03x dead", sessionId);
sessionState = TS_TA_DEAD;
}
// Note this is a very subtle synchronization requirement:
@@ -158,4 +154,3 @@ CWsm_ptr TrustletSession::popBulkBuff()
return pWsm;
}
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/TrustletSession.h b/mobicore/MobiCoreDriverLib/Daemon/Device/TrustletSession.h
index 76deba1..1555660 100644
--- a/mobicore/daemon/Daemon/Device/TrustletSession.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/TrustletSession.h
@@ -1,7 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
- * @{
- * @file
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -83,4 +80,3 @@ typedef trustletSessionList_t::iterator trustletSessionIterator_t;
#endif /* TRUSTLETSESSION_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/Device/public/MobiCoreDevice.h b/mobicore/MobiCoreDriverLib/Daemon/Device/public/MobiCoreDevice.h
index 5d05028..e7348b4 100644
--- a/mobicore/daemon/Daemon/Device/public/MobiCoreDevice.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/Device/public/MobiCoreDevice.h
@@ -1,12 +1,4 @@
-/** @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.
*
@@ -36,6 +28,12 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * 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.
+ */
#ifndef MOBICOREDEVICE_H_
#define MOBICOREDEVICE_H_
@@ -52,7 +50,6 @@
#include "Connection.h"
#include "CWsm.h"
-#include "ExcDevice.h"
#include "DeviceScheduler.h"
#include "DeviceIrqHandler.h"
#include "TAExitHandler.h"
@@ -98,6 +95,7 @@ protected:
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
@@ -141,11 +139,12 @@ private:
virtual bool waitSsiq(void) = 0;
public:
- CMutex mutex_mcp; // This mutex should be taken before any access to below functions
+ CMutex mutex_mcp; // This mutex should be taken before any access to below functions
+ CMutex mutex_tslist; // Mutex to share Trustlet session list ==> WARNING, do not CI, temporary fix.
virtual ~MobiCoreDevice();
- Connection *getSessionConnection(uint32_t sessionId, notification_t *notification);
+ //Connection *getSessionConnection(uint32_t sessionId, notification_t *notification);
bool open(Connection *connection);
@@ -166,6 +165,8 @@ public:
MC_DRV_CMD_NQ_CONNECT_struct *cmdNqConnect);
+ void freeSession(TrustletSession *session);
+
mcResult_t closeSession(Connection *deviceConnection, uint32_t sessionId);
virtual mcResult_t notify(Connection *deviceConnection, uint32_t sessionId);
@@ -250,4 +251,3 @@ public:
#endif /* MOBICOREDEVICE_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/FSD/Android.mk b/mobicore/MobiCoreDriverLib/Daemon/FSD/Android.mk
index 8c8f578..144d141 100644
--- a/mobicore/daemon/Daemon/FSD/Android.mk
+++ b/mobicore/MobiCoreDriverLib/Daemon/FSD/Android.mk
@@ -11,7 +11,7 @@ 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
+ $(LOCAL_PATH)/ClientLib/public/GP \
# Add new source files here
-LOCAL_SRC_FILES += $(FSD_PATH)/FSD.cpp \ No newline at end of file
+LOCAL_SRC_FILES += $(FSD_PATH)/FSD.cpp \ \ No newline at end of file
diff --git a/mobicore/daemon/Daemon/FSD/FSD.cpp b/mobicore/MobiCoreDriverLib/Daemon/FSD/FSD.cpp
index 31821ae..046b98e 100644
--- a/mobicore/daemon/Daemon/FSD/FSD.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/FSD/FSD.cpp
@@ -1,12 +1,5 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * FSD server.
- *
- * Handles incoming storage requests from TA through STH
- */
-/* Copyright (c) 2013 TRUSTONIC LIMITED
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,28 +28,35 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * FSD server.
+ *
+ * Handles incoming storage requests from TA through STH
+ */
#include "public/FSD.h"
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <cstdlib>
#include <stdio.h>
-
+#include <assert.h>
//#define LOG_VERBOSE
#include "log.h"
-extern string getRegistryPath();
+/* The following definitions are not exported in the header files of the
+ client API. */
+#define TEE_DATA_FLAG_EXCLUSIVE 0x00000400
+#define TEE_ERROR_STORAGE_NO_SPACE ((TEEC_Result)0xFFFF3041)
+#define TEE_ERROR_CORRUPT_OBJECT ((TEEC_Result)0xF0100001)
-extern pthread_mutex_t syncMutex;
-extern pthread_cond_t syncCondition;
-extern bool Th_sync;
+extern string getTbStoragePath();
//------------------------------------------------------------------------------
FSD::FSD(
void
)
{
- sessionHandle = {0,0};
+ memset(&sessionHandle, 0, sizeof(mcSessionHandle_t));
dci = NULL;
}
@@ -74,27 +74,19 @@ void FSD::run(
{
struct stat st = {0};
mcResult_t ret;
- string storage = getRegistryPath()+"/TbStorage";
+ string storage = getTbStoragePath();
const char* tbstpath = storage.c_str();
/*Create Tbase storage directory*/
if (stat(tbstpath, &st) == -1) {
- LOG_I("%s: Create <t-base storage folder %s", TAG_LOG, tbstpath);
- if(mkdir(tbstpath, 0600)==-1)
+ LOG_I("%s: Creating <t-base storage Folder %s\n",TAG_LOG,tbstpath);
+ if(mkdir(tbstpath, 0700)==-1)
{
- LOG_ERRNO("Failed to create storage folder");
+ 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);
-
+ LOG_I("%s: starting File Storage Daemon", TAG_LOG);
ret = FSD_Open();
if (ret != MC_DRV_OK)
break;
@@ -248,37 +240,90 @@ void FSD::FSD_listenDci(void){
}
}
+// Output FileName is guaranteed to be 0 ended.
void FSD_HexFileName(
unsigned char* fn,
char* FileName,
- uint32_t elems
+ uint32_t fnSize,
+ uint32_t FileNameSize
){
-
- char tmp[elems * 2 + 1];
+ assert (FileNameSize == fnSize *2 +1);
+ char tmp[fnSize * 2 + 1];
uint32_t i=0;
- for (i = 0; i < elems; i++) {
- sprintf(&tmp[i * 2], "%02x", fn[i]);
+ // tmp is size-variabled array, have to init it with memset
+ memset(tmp, 0, fnSize * 2 + 1);
+ for (i = 0; i < fnSize; i++) {
+ // the implementation of snprintf counts also the trailing "\0"
+ snprintf(&tmp[i * 2], 2 + sizeof("\0"), "%02x", fn[i]);
}
- strcpy(FileName,tmp);
+ tmp[fnSize * 2 + 1] = '\0';
+ strncpy(FileName,tmp,FileNameSize);
}
-void FSD_CreateTaDirName(
+// Output DirName is guaranteed to be 0 ended.
+static void FSD_CreateTaDirName(
TEE_UUID* ta_uuid,
char* DirName,
- uint32_t elems
+ uint32_t DirNameSize
){
- char tmp[elems * 2 + 1];
- unsigned char* fn;
+ assert (DirNameSize == sizeof(TEE_UUID) *2 +1);
+ char tmp[sizeof(TEE_UUID) * 2 + 1];
+ unsigned char* fn;
uint32_t i=0;
+ memset(tmp, 0, sizeof(tmp));
fn = (unsigned char*)ta_uuid;
- for (i = 0; i < elems; i++) {
- sprintf(&tmp[i * 2], "%02x", fn[i]);
+ for (i = 0; i < sizeof(TEE_UUID); i++) {
+ // the implementation of snprintf counts also the trailing "\0"
+ snprintf(&tmp[i * 2], 2 + sizeof("\0"), "%02x", fn[i]);
}
- strcat(DirName,tmp);
+ strncpy(DirName,tmp,DirNameSize);
+}
+
+void FSD_CreateTaDirPath(
+ string storage,
+ STH_FSD_message_t *sth_request,
+ char *TAdirpath,
+ size_t TAdirpathSize //sizeof(TAdirpathSize)
+){
+ const char* tbstpath = storage.c_str();
+ size_t tbstpathSize = storage.length();
+ char tadirname[TEE_UUID_STRING_SIZE+1] = {0};
+ assert (TAdirpathSize == tbstpathSize+1+TEE_UUID_STRING_SIZE+1);
+
+ FSD_CreateTaDirName(&sth_request->uuid,tadirname,sizeof(tadirname));
+
+ strncpy(TAdirpath, tbstpath, tbstpathSize);
+ strncat(TAdirpath, "/", strlen(("/")));
+ strncat(TAdirpath, tadirname, strlen(tadirname));
+
+ LOG_I("%s: Storage %s\n", __func__, tbstpath);
+ LOG_I("%s: TA dirname %s\n", __func__, tadirname);
+
+}
+
+void FSD_CreateFilePath(
+ STH_FSD_message_t *sth_request,
+ char *Filepath,
+ size_t FilepathSize, // sizeof(FilepathSize)
+ char *TAdirpath,
+ size_t TAdirpathSize // sizeof(TAdirpath)
+
+){
+ char filename[2*FILENAMESIZE+1] = {0};
+ assert (FilepathSize == TAdirpathSize + 2*FILENAMESIZE+1);
+ FSD_HexFileName(sth_request->filename,filename,FILENAMESIZE,sizeof(filename));
+
+ strncpy(Filepath, TAdirpath, TAdirpathSize-1);
+ strncat(Filepath, "/", strlen("/"));
+ strncat(Filepath, filename, strlen(filename));
+
+ LOG_I("%s: filename %s\n", __func__, filename);
+ LOG_I("%s: fullpath %s\n", __func__, Filepath);
+
}
//------------------------------------------------------------------------------
@@ -325,94 +370,106 @@ mcResult_t FSD::FSD_ExecuteCommand(void){
mcResult_t FSD::FSD_LookFile(void){
FILE * pFile=NULL;
STH_FSD_message_t* sth_request=NULL;
- uint32_t res=0;
- string storage = getRegistryPath()+"/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];
+ size_t res;
+ string storage = getTbStoragePath();
+ char TAdirpath[storage.length()+1+TEE_UUID_STRING_SIZE+1];
+ char Filepath[storage.length()+1+TEE_UUID_STRING_SIZE+1+2*FILENAMESIZE+1];
+ memset(TAdirpath, 0, storage.length()+1+TEE_UUID_STRING_SIZE+1);
+ memset(Filepath, 0, storage.length()+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);
+ FSD_CreateTaDirPath(
+ storage,
+ sth_request,
+ TAdirpath,
+ sizeof(TAdirpath));
+
+ FSD_CreateFilePath(
+ sth_request,
+ Filepath,
+ sizeof(Filepath),
+ TAdirpath,
+ sizeof(TAdirpath));
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;
+ LOG_E("%s: Error looking for file 0x%.8x\n",__func__,TEEC_ERROR_ITEM_NOT_FOUND);
+ return TEEC_ERROR_ITEM_NOT_FOUND;
}
res = fread(sth_request->payload,sizeof(char),sth_request->payloadLen,pFile);
- fclose(pFile);
- if (res != sth_request->payloadLen)
+ if (ferror(pFile))
{
LOG_E("%s: Error reading file res is %d and errno is %s\n",__func__,res,strerror(errno));
- return TEE_ERROR_ITEM_NOT_FOUND;
+ fclose(pFile);
+ return TEEC_ERROR_ITEM_NOT_FOUND;
}
- return TEE_SUCCESS;
+
+ if (res < sth_request->payloadLen)
+ {
+ //File is shorter than expected
+ if (feof(pFile)) {
+ LOG_I("%s: EOF reached: res is %d, payloadLen is %d\n",__func__,res, sth_request->payloadLen);
+ }
+ }
+
+ fclose(pFile);
+
+ return TEEC_SUCCESS;
}
mcResult_t FSD::FSD_ReadFile(void){
FILE * pFile=NULL;
STH_FSD_message_t* sth_request=NULL;
- uint32_t res=0;
- string storage = getRegistryPath()+"/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];
+ size_t res;
+ string storage = getTbStoragePath();
+ char TAdirpath[storage.length()+1+TEE_UUID_STRING_SIZE+1];
+ char Filepath[storage.length()+1+TEE_UUID_STRING_SIZE+1+2*FILENAMESIZE+1];
+ memset(TAdirpath, 0, storage.length()+1+TEE_UUID_STRING_SIZE+1);
+ memset(Filepath, 0, storage.length()+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);
+ FSD_CreateTaDirPath(
+ storage,
+ sth_request,
+ TAdirpath,
+ sizeof(TAdirpath));
+
+ FSD_CreateFilePath(
+ sth_request,
+ Filepath,
+ sizeof(Filepath),
+ TAdirpath,
+ sizeof(TAdirpath));
+
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;
+ LOG_E("%s: Error looking for file 0x%.8x\n", __func__,TEEC_ERROR_ITEM_NOT_FOUND);
+ return TEEC_ERROR_ITEM_NOT_FOUND;
}
res = fread(sth_request->payload,sizeof(char),sth_request->payloadLen,pFile);
- fclose(pFile);
-
- if (res != sth_request->payloadLen)
+ if (ferror(pFile))
{
LOG_E("%s: Error reading file res is %d and errno is %s\n",__func__,res,strerror(errno));
- return TEE_ERROR_ITEM_NOT_FOUND;
+ fclose(pFile);
+ return TEE_ERROR_CORRUPT_OBJECT;
}
- return TEE_SUCCESS;
+
+ if (res < sth_request->payloadLen)
+ {
+ //File is shorter than expected
+ if (feof(pFile)) {
+ LOG_I("%s: EOF reached: res is %d, payloadLen is %d\n",__func__,res, sth_request->payloadLen);
+ }
+ }
+
+ fclose(pFile);
+
+ return TEEC_SUCCESS;
}
@@ -420,51 +477,48 @@ mcResult_t FSD::FSD_WriteFile(void){
FILE * pFile=NULL;
int fd=0;
STH_FSD_message_t* sth_request=NULL;
- uint32_t res=0;
+ size_t res=0;
int stat=0;
- string storage = getRegistryPath()+"/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];
-
+ string storage = getTbStoragePath();
+ char TAdirpath[storage.length()+1+TEE_UUID_STRING_SIZE+1];
+ char Filepath[storage.length()+1+TEE_UUID_STRING_SIZE+1+2*FILENAMESIZE+1];
+ char Filepath_new[storage.length()+TEE_UUID_STRING_SIZE+2*FILENAMESIZE+strlen(NEW_EXT)+1];
+
+ memset(TAdirpath, 0, storage.length()+1+TEE_UUID_STRING_SIZE+1);
+ memset(Filepath, 0, storage.length()+1+TEE_UUID_STRING_SIZE+1+2*FILENAMESIZE+1);
+ memset(Filepath_new, 0, storage.length()+TEE_UUID_STRING_SIZE+2*FILENAMESIZE+strlen(NEW_EXT)+1);
sth_request= &dci->sth_request;
+ FSD_CreateTaDirPath(
+ storage,
+ sth_request,
+ TAdirpath,
+ sizeof(TAdirpath));
- 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);
+ stat = mkdir(TAdirpath, 0700);
if((stat==-1) && (errno!=EEXIST))
{
- LOG_I("%s: error when creating TA dir: %s (%s)\n",__func__,TAdirpath,strerror(errno));
+ LOG_E("%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);
+ FSD_CreateFilePath(
+ sth_request,
+ Filepath,
+ sizeof(Filepath),
+ TAdirpath,
+ sizeof(TAdirpath));
+ strncpy(Filepath_new,Filepath,sizeof(Filepath) - 1);
+ strncat(Filepath_new,NEW_EXT,strlen(NEW_EXT));
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);
+ 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;
+ LOG_E("%s: error creating file: %s \n",__func__,strerror(errno));
+ return TEE_ERROR_CORRUPT_OBJECT;
}
else
{
@@ -475,110 +529,118 @@ mcResult_t FSD::FSD_WriteFile(void){
LOG_I("%s: opening file for writing\n",__func__);
if(pFile==NULL)
{
- remove(Filepath);
+ if(remove(Filepath)==-1)
+ {
+ LOG_E("%s: remove failed: %s\n",__func__, strerror(errno));
+ }
return TEE_ERROR_STORAGE_NO_SPACE;
}
res = fwrite(sth_request->payload,sizeof(char),sth_request->payloadLen,pFile);
-
- if (res != sth_request->payloadLen)
+ if (ferror(pFile))
{
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;
+ if(remove(Filepath)==-1)
+ {
+ LOG_E("%s: remove failed: %s\n",__func__, strerror(errno));
+ }
+ if(remove(Filepath_new)==-1)
+ {
+ LOG_E("%s: remove failed: %s\n",__func__, strerror(errno));
+ }
+ return TEE_ERROR_STORAGE_NO_SPACE;
}
else
{
res = fclose(pFile);
- if (res < 0)
+ if ((int32_t) 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);
+ if(remove(Filepath)==-1)
+ {
+ LOG_E("%s: remove failed: %s\n",__func__, strerror(errno));
+ }
+ if(remove(Filepath_new)==-1)
+ {
+ LOG_E("%s: remove failed: %s\n",__func__, strerror(errno));
+ }
return TEE_ERROR_STORAGE_NO_SPACE;
}
res = rename(Filepath_new,Filepath);
- if (res < 0)
+ if ((int32_t) res < 0)
{
- LOG_E("%s: Error renaming %s: %s\n",__func__,Filepath_new,strerror(errno));
- remove(Filepath);
- remove(Filepath_new);
+ LOG_E("%s: Error renaming: %s\n",__func__,strerror(errno));
+ if(remove(Filepath)==-1)
+ {
+ LOG_E("%s: remove failed: %s\n",__func__, strerror(errno));
+ }
+ if(remove(Filepath_new)==-1)
+ {
+ LOG_E("%s: remove failed: %s\n",__func__, strerror(errno));
+ }
return TEE_ERROR_STORAGE_NO_SPACE;
}
}
- return TEE_SUCCESS;
+ return TEEC_SUCCESS;
}
mcResult_t FSD::FSD_DeleteFile(void){
FILE * pFile=NULL;
- uint32_t res=0;
+ mcResult_t ret;
+ size_t res;
STH_FSD_message_t* sth_request=NULL;
- string storage = getRegistryPath()+"/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];
+ string storage = getTbStoragePath();
+ char TAdirpath[storage.length()+1+TEE_UUID_STRING_SIZE+1];
+ char Filepath[storage.length()+1+TEE_UUID_STRING_SIZE+1+2*FILENAMESIZE+1];
+ memset(TAdirpath, 0, storage.length()+1+TEE_UUID_STRING_SIZE+1);
+ memset(Filepath, 0, storage.length()+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);
+ FSD_CreateTaDirPath(
+ storage,
+ sth_request,
+ TAdirpath,
+ sizeof(TAdirpath));
+
+ FSD_CreateFilePath(
+ sth_request,
+ Filepath,
+ sizeof(Filepath),
+ TAdirpath,
+ sizeof(TAdirpath));
pFile = fopen(Filepath, "r");
if (pFile==NULL)
{
LOG_I("%s: file not found: %s (%s)\n",__func__, Filepath, strerror(errno));
- res = TEE_SUCCESS;
+ ret = TEEC_SUCCESS;
}
else
{
fclose(pFile);
if(remove(Filepath)==-1)
{
- res = TEE_ERROR_STORAGE_NO_SPACE;
+ ret = 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))
+ if (((int32_t) 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));
+ ret = TEE_ERROR_STORAGE_NO_SPACE;
+ LOG_E("%s: rmdir failed: %s (%s)\n",__func__, TAdirpath, strerror(errno));
}
else
{
- res = TEE_SUCCESS;
+ ret = TEEC_SUCCESS;
}
- return res;
+ return ret;
}
//------------------------------------------------------------------------------
-/** @} */
diff --git a/mobicore/daemon/Daemon/FSD/public/FSD.h b/mobicore/MobiCoreDriverLib/Daemon/FSD/public/FSD.h
index 9a44fa6..0c7f97a 100644
--- a/mobicore/daemon/Daemon/FSD/public/FSD.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/FSD/public/FSD.h
@@ -1,12 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * FSD server.
- *
- * Handles incoming storage requests from TA through STH
- *
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -36,6 +28,11 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * FSD server.
+ *
+ * Handles incoming storage requests from TA through STH
+ */
#ifndef FSD_H_
#define FSD_H_
@@ -166,4 +163,3 @@ private:
#endif /* FSD_H_ */
-/** @} */
diff --git a/mobicore/MobiCoreDriverLib/Daemon/FSD/public/dci.h b/mobicore/MobiCoreDriverLib/Daemon/FSD/public/dci.h
new file mode 100644
index 0000000..cf0b8c2
--- /dev/null
+++ b/mobicore/MobiCoreDriverLib/Daemon/FSD/public/dci.h
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/**
+ * @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__
diff --git a/mobicore/common/DrSecureStorage/drSecureStorage_Api.h b/mobicore/MobiCoreDriverLib/Daemon/FSD/public/drSecureStorage_Api.h
index 0ca7549..46cc36f 100644
--- a/mobicore/common/DrSecureStorage/drSecureStorage_Api.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/FSD/public/drSecureStorage_Api.h
@@ -1,12 +1,32 @@
/*
* Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved
+ * 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.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -19,8 +39,8 @@
#define __DRTEMPLATEAPI_H__
#include "dci.h"
-#include "tee_internal_api.h"
-
+#include "tee_type.h"
+#include "tee_error.h"
#define RW_DATA_SIZE 4096
diff --git a/mobicore/daemon/Daemon/MobiCoreDriverDaemon.cpp b/mobicore/MobiCoreDriverLib/Daemon/MobiCoreDriverDaemon.cpp
index 576dc88..f3e0b72 100644
--- a/mobicore/daemon/Daemon/MobiCoreDriverDaemon.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/MobiCoreDriverDaemon.cpp
@@ -1,12 +1,5 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_CONHDLR
- * @{
- * @file
- *
- * Entry of the MobiCore Driver.
- */
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,7 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+/**
+ * Entry of the MobiCore Driver.
+ */
#include <cstdlib>
#include <signal.h>
#include <fcntl.h>
@@ -66,10 +61,6 @@ 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,
@@ -97,7 +88,8 @@ MobiCoreDriverDaemon::~MobiCoreDriverDaemon(
for (it = driverResources.begin(); it != driverResources.end(); it++) {
MobicoreDriverResources *res = *it;
mobiCoreDevice->closeSession(res->conn, res->sessionId);
- mobiCoreDevice->unregisterWsmL2(res->pTciWsm);
+ (void)mobiCoreDevice->unregisterWsmL2(res->pTciWsm);
+ res->pTciWsm = NULL;
}
delete mobiCoreDevice;
for (int i = 0; i < MAX_SERVERS; i++) {
@@ -112,8 +104,6 @@ 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);
@@ -134,59 +124,26 @@ void MobiCoreDriverDaemon::run(
// initialize device (setupo MCI)
if (!mobiCoreDevice->initDevice(
- devNode,
+ "/dev/" MC_ADMIN_DEVNODE,
enableScheduler)) {
- LOG_E("Could not initialize <t-base (because %s could not be openend)!", devNode);
+ LOG_E("Could not initialize <t-base!");
return;
}
// start device (scheduler)
mobiCoreDevice->start();
+ LOG_I_RELEASE("Checking version of <t-base");
+ checkMobiCoreVersion(mobiCoreDevice);
+
// 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");
- }
- }
+ // Look for tokens and send it to <t-base if any
+ installEndorsementToken();
LOG_I("Creating socket servers");
// Start listening for incoming TLC connections
@@ -199,18 +156,10 @@ void MobiCoreDriverDaemon::run(
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;
}
//------------------------------------------------------------------------------
@@ -315,7 +264,7 @@ bool MobiCoreDriverDaemon::loadDeviceDriver(
// Initialize information data of open session command
loadDataOpenSession_t loadDataOpenSession;
loadDataOpenSession.baseAddr = pWsm->physAddr;
- loadDataOpenSession.offs = ((uint32_t) regObj->value) & 0xFFF;
+ loadDataOpenSession.offs = ((uintptr_t) regObj->value) & 0xFFF;
loadDataOpenSession.len = regObj->len;
loadDataOpenSession.tlHeader = (mclfHeader_ptr) (regObj->value + regObj->tlStartOffset);
@@ -336,7 +285,12 @@ bool MobiCoreDriverDaemon::loadDeviceDriver(
// Unregister physical memory from kernel module.
// This will also destroy the WSM object.
- mobiCoreDevice->unregisterWsmL2(pWsm);
+ if (!mobiCoreDevice->unregisterWsmL2(pWsm))
+ {
+ pWsm = NULL;
+ LOG_E("unregistering of WsmL2 failed.");
+ break;
+ }
pWsm = NULL;
// Free memory occupied by Trustlet data
@@ -355,9 +309,9 @@ bool MobiCoreDriverDaemon::loadDeviceDriver(
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;
+ LOG_E("unregisterWsmL2 failed");
}
+ pWsm = NULL;
}
// No matter if we free NULL objects
free(regObj);
@@ -375,7 +329,7 @@ bool MobiCoreDriverDaemon::loadDeviceDriver(
#define RECV_PAYLOAD_FROM_CLIENT(CONNECTION, CMD_BUFFER) \
{ \
- void *payload = (void*)((uint32_t)CMD_BUFFER + sizeof(mcDrvCommandHeader_t)); \
+ 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) { \
@@ -384,7 +338,7 @@ bool MobiCoreDriverDaemon::loadDeviceDriver(
writeResult(CONNECTION, MC_DRV_ERR_DAEMON_SOCKET); \
return; \
} \
- if (rlen != payload_len) {\
+ if ((uint32_t)rlen != payload_len) {\
LOG_E("wrong buffer length %i received from Client", rlen); \
writeResult(CONNECTION, MC_DRV_ERR_DAEMON_SOCKET); \
return; \
@@ -498,7 +452,7 @@ void MobiCoreDriverDaemon::processOpenSession(Connection *connection, bool isGpU
// Initialize information data of open session command
loadDataOpenSession_t loadDataOpenSession;
loadDataOpenSession.baseAddr = pWsm->physAddr;
- loadDataOpenSession.offs = ((uint32_t) regObj->value) & 0xFFF;
+ loadDataOpenSession.offs = ((uintptr_t) regObj->value) & 0xFFF;
loadDataOpenSession.len = regObj->len;
loadDataOpenSession.tlHeader = (mclfHeader_ptr) (regObj->value + regObj->tlStartOffset);
@@ -516,12 +470,13 @@ void MobiCoreDriverDaemon::processOpenSession(Connection *connection, bool isGpU
// This will also destroy the WSM object.
if (!device->unregisterWsmL2(pWsm)) {
+ pWsm = NULL;
// 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;
}
-
+ pWsm = NULL;
// Free memory occupied by Trustlet data
free(regObj);
@@ -571,7 +526,7 @@ mcResult_t MobiCoreDriverDaemon::processLoadCheck(mcSpid_t spid, void *blob, uin
// Initialize information data of open session command
loadDataOpenSession_t loadDataOpenSession;
loadDataOpenSession.baseAddr = pWsm->physAddr;
- loadDataOpenSession.offs = ((uint32_t) regObj->value) & 0xFFF;
+ loadDataOpenSession.offs = ((uintptr_t) regObj->value) & 0xFFF;
loadDataOpenSession.len = regObj->len;
loadDataOpenSession.tlHeader = (mclfHeader_ptr) (regObj->value + regObj->tlStartOffset);
@@ -585,11 +540,13 @@ mcResult_t MobiCoreDriverDaemon::processLoadCheck(mcSpid_t spid, void *blob, uin
// This will also destroy the WSM object.
if (!device->unregisterWsmL2(pWsm)) {
+ pWsm = NULL;
// Free memory occupied by Trustlet data
free(regObj);
LOG_E("deallocating WSM for Trustlet failed");
return MC_DRV_ERR_DAEMON_KMOD_ERROR;
}
+ pWsm = NULL;
// Free memory occupied by Trustlet data
free(regObj);
@@ -662,7 +619,7 @@ void MobiCoreDriverDaemon::processOpenTrustlet(Connection *connection)
// Initialize information data of open session command
loadDataOpenSession_t loadDataOpenSession;
loadDataOpenSession.baseAddr = pWsm->physAddr;
- loadDataOpenSession.offs = ((uint32_t) regObj->value) & 0xFFF;
+ loadDataOpenSession.offs = ((uintptr_t) regObj->value) & 0xFFF;
loadDataOpenSession.len = regObj->len;
loadDataOpenSession.tlHeader = (mclfHeader_ptr) (regObj->value + regObj->tlStartOffset);
@@ -680,11 +637,13 @@ void MobiCoreDriverDaemon::processOpenTrustlet(Connection *connection)
// This will also destroy the WSM object.
if (!device->unregisterWsmL2(pWsm)) {
+ pWsm = NULL;
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;
}
+ pWsm = NULL;
// Free memory occupied by Trustlet data
free(regObj);
@@ -750,16 +709,25 @@ void MobiCoreDriverDaemon::processNqConnect(Connection *connection)
return;
}
+ /*
+ * The fix extends the range of the trustlet_session_list mutex over the
+ * sending of the nq-socket message that confirms the creation of the session.
+ * That way an arriving SSIQ/notification-from-driver will not use the nq-socket before the ok message was sent.
+ */
+ device->mutex_tslist.lock();
TrustletSession *ts = device->registerTrustletConnection(
connection,
&cmd);
if (!ts) {
LOG_E("registerTrustletConnection() failed!");
writeResult(connection, MC_DRV_ERR_UNKNOWN);
+ device->mutex_tslist.unlock();
return;
}
writeResult(connection, MC_DRV_OK);
+ device->mutex_tslist.unlock();
+
ts->processQueuedNotifications();
}
@@ -770,7 +738,7 @@ void MobiCoreDriverDaemon::processNotify(Connection *connection)
// Read entire command data
MC_DRV_CMD_NOTIFY_struct cmd;
//RECV_PAYLOAD_FROM_CLIENT(connection, &cmd);
- void *payload = (void *)((uint32_t)&cmd + sizeof(mcDrvCommandHeader_t));
+ 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) {
@@ -926,6 +894,8 @@ mcDrvResponseHeader_t rspRegistry = { responseId :
mcSpid_t spid;
mcUuid_t uuid;
+ memset(&spid, 0, sizeof(spid));
+
if (!checkPermission(connection)) {
connection->writeData(&rspRegistry, sizeof(rspRegistry));
return;
@@ -966,7 +936,7 @@ void MobiCoreDriverDaemon::processRegistryWriteData(uint32_t commandId, Connecti
mcDrvResponseHeader_t rspRegistry = { responseId :
MC_DRV_ERR_INVALID_OPERATION
};
- uint32_t soSize;
+ uint32_t soSize = 0;
void *so;
if (!checkPermission(connection)) {
@@ -993,12 +963,32 @@ mcDrvResponseHeader_t rspRegistry = { responseId :
if (!getData(connection, so, soSize))
break;
rspRegistry.responseId = mcRegistryStoreAuthToken(so, soSize);
+ if (rspRegistry.responseId != MC_DRV_OK) {
+ LOG_E("mcRegistryStoreAuthToken() failed");
+ break;
+ }
+ /* Load authentication token. Need to update <t-base to avoid
+ * reboot */
+ LOG_I("Auth Token stored. Updating <t-base.");
+ if (!loadToken((uint8_t *)so, sizeof(mcSoAuthTokenCont_t))) {
+ LOG_E("Failed to pass Auth Token to <t-base.");
+ }
break;
}
case MC_DRV_REG_WRITE_ROOT_CONT: {
if (!getData(connection, so, soSize))
break;
rspRegistry.responseId = mcRegistryStoreRoot(so, soSize);
+ if (rspRegistry.responseId != MC_DRV_OK) {
+ LOG_E("mcRegistryStoreRoot() failed");
+ break;
+ }
+ /* Load Root container. Need to update <t-base to avoid
+ * reboot */
+ LOG_I("Root container stored. Updating <t-base.");
+ if (!loadToken((uint8_t *)so, sizeof(mcSoRootCont_t))) {
+ LOG_E("Failed to pass Root container to <t-base.");
+ }
break;
}
case MC_DRV_REG_WRITE_SP_CONT: {
@@ -1013,6 +1003,7 @@ mcDrvResponseHeader_t rspRegistry = { responseId :
case MC_DRV_REG_WRITE_TL_CONT: {
mcUuid_t uuid;
mcSpid_t spid;
+ memset(&spid, 0, sizeof(spid));
if (!getData(connection, &uuid, sizeof(uuid)))
break;
if (!getData(connection, &spid, sizeof(spid)))
@@ -1032,6 +1023,7 @@ mcDrvResponseHeader_t rspRegistry = { responseId :
uint32_t blobSize = soSize;
mcSpid_t spid;
void *blob;
+ memset(&spid, 0, sizeof(spid));
if (!getData(connection, &spid, sizeof(spid)))
break;
blob = malloc(blobSize);
@@ -1069,7 +1061,7 @@ void MobiCoreDriverDaemon::processRegistryDeleteData(uint32_t commandId, Connect
mcDrvResponseHeader_t rspRegistry = { responseId :
MC_DRV_ERR_INVALID_OPERATION
};
- mcSpid_t spid;
+ mcSpid_t spid = MC_SPID_RESERVED; /* MC_SPID_RESERVED = 0 */
if (!checkPermission(connection)) {
connection->writeData(&rspRegistry, sizeof(rspRegistry));
@@ -1080,9 +1072,16 @@ mcDrvResponseHeader_t rspRegistry = { responseId :
case MC_DRV_REG_DELETE_AUTH_TOKEN:
rspRegistry.responseId = mcRegistryDeleteAuthToken();
break;
- case MC_DRV_REG_DELETE_ROOT_CONT:
+ case MC_DRV_REG_DELETE_ROOT_CONT: {
rspRegistry.responseId = mcRegistryCleanupRoot();
+ if (rspRegistry.responseId != MC_DRV_OK) {
+ LOG_E("mcRegistryCleanupRoot() failed");
+ break;
+ }
+ // Look for tokens and send it to <t-base if any
+ installEndorsementToken();
break;
+ }
case MC_DRV_REG_DELETE_SP_CONT:
if (!getData(connection, &spid, sizeof(spid)))
break;
@@ -1111,7 +1110,8 @@ bool MobiCoreDriverDaemon::handleConnection(
bool ret = false;
// This is the big lock around everything the Daemon does, including socket and MCI access
- static CMutex mutex;
+ static CMutex reg_mutex;
+ static CMutex siq_mutex;
/* In case of RTM fault do not try to signal anything to MobiCore
* just answer NO to all incoming connections! */
@@ -1120,9 +1120,6 @@ bool MobiCoreDriverDaemon::handleConnection(
return false;
}
- mutex.lock();
- mobiCoreDevice->mutex_mcp.lock();
-
LOG_I("handleConnection()==== %p", connection);
do {
// Read header
@@ -1148,43 +1145,63 @@ bool MobiCoreDriverDaemon::handleConnection(
switch (mcDrvCommandHeader.commandId) {
//-----------------------------------------
case MC_DRV_CMD_OPEN_DEVICE:
+ mobiCoreDevice->mutex_mcp.lock();
processOpenDevice(connection);
+ mobiCoreDevice->mutex_mcp.unlock();
break;
//-----------------------------------------
case MC_DRV_CMD_CLOSE_DEVICE:
+ mobiCoreDevice->mutex_mcp.lock();
processCloseDevice(connection);
+ mobiCoreDevice->mutex_mcp.unlock();
break;
//-----------------------------------------
case MC_DRV_CMD_OPEN_SESSION:
+ mobiCoreDevice->mutex_mcp.lock();
processOpenSession(connection, false);
+ mobiCoreDevice->mutex_mcp.unlock();
break;
//-----------------------------------------
case MC_DRV_CMD_OPEN_TRUSTLET:
+ mobiCoreDevice->mutex_mcp.lock();
processOpenTrustlet(connection);
+ mobiCoreDevice->mutex_mcp.unlock();
break;
//-----------------------------------------
case MC_DRV_CMD_OPEN_TRUSTED_APP:
+ mobiCoreDevice->mutex_mcp.lock();
processOpenSession(connection, true);
+ mobiCoreDevice->mutex_mcp.unlock();
break;
//-----------------------------------------
case MC_DRV_CMD_CLOSE_SESSION:
+ mobiCoreDevice->mutex_mcp.lock();
processCloseSession(connection);
+ mobiCoreDevice->mutex_mcp.unlock();
break;
//-----------------------------------------
case MC_DRV_CMD_NQ_CONNECT:
+ siq_mutex.lock();
processNqConnect(connection);
+ siq_mutex.unlock();
break;
//-----------------------------------------
case MC_DRV_CMD_NOTIFY:
+ siq_mutex.lock();
processNotify(connection);
+ siq_mutex.unlock();
break;
//-----------------------------------------
case MC_DRV_CMD_MAP_BULK_BUF:
+ mobiCoreDevice->mutex_mcp.lock();
processMapBulkBuf(connection);
+ mobiCoreDevice->mutex_mcp.unlock();
break;
//-----------------------------------------
case MC_DRV_CMD_UNMAP_BULK_BUF:
+ mobiCoreDevice->mutex_mcp.lock();
processUnmapBulkBuf(connection);
+ mobiCoreDevice->mutex_mcp.unlock();
break;
//-----------------------------------------
case MC_DRV_CMD_GET_VERSION:
@@ -1192,7 +1209,9 @@ bool MobiCoreDriverDaemon::handleConnection(
break;
//-----------------------------------------
case MC_DRV_CMD_GET_MOBICORE_VERSION:
+ mobiCoreDevice->mutex_mcp.lock();
processGetMobiCoreVersion(connection);
+ mobiCoreDevice->mutex_mcp.unlock();
break;
//-----------------------------------------
/* Registry functionality */
@@ -1203,7 +1222,9 @@ bool MobiCoreDriverDaemon::handleConnection(
case MC_DRV_REG_WRITE_TL_CONT:
case MC_DRV_REG_WRITE_SO_DATA:
case MC_DRV_REG_STORE_TA_BLOB:
+ reg_mutex.lock();
processRegistryWriteData(mcDrvCommandHeader.commandId, connection);
+ reg_mutex.unlock();
break;
//-----------------------------------------
// Read Registry Data
@@ -1211,7 +1232,9 @@ bool MobiCoreDriverDaemon::handleConnection(
case MC_DRV_REG_READ_ROOT_CONT:
case MC_DRV_REG_READ_SP_CONT:
case MC_DRV_REG_READ_TL_CONT:
+ reg_mutex.lock();
processRegistryReadData(mcDrvCommandHeader.commandId, connection);
+ reg_mutex.unlock();
break;
//-----------------------------------------
// Delete registry data
@@ -1219,7 +1242,9 @@ bool MobiCoreDriverDaemon::handleConnection(
case MC_DRV_REG_DELETE_ROOT_CONT:
case MC_DRV_REG_DELETE_SP_CONT:
case MC_DRV_REG_DELETE_TL_CONT:
+ reg_mutex.lock();
processRegistryDeleteData(mcDrvCommandHeader.commandId, connection);
+ reg_mutex.unlock();
break;
//-----------------------------------------
default:
@@ -1230,8 +1255,7 @@ bool MobiCoreDriverDaemon::handleConnection(
break;
}
} while (0);
- mobiCoreDevice->mutex_mcp.unlock();
- mutex.unlock();
+
LOG_I("handleConnection()<-------");
return ret;
@@ -1297,10 +1321,6 @@ int main(int argc, char *args[])
// 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 */
@@ -1336,25 +1356,12 @@ int main(int argc, char *args[])
/* 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);
+ /* become a daemon */
+ if (daemon(0, 0) < 0) {
+ fprintf(stderr, "Fork failed, exiting.\n");
+ return 1;
}
- // 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);
@@ -1381,9 +1388,6 @@ int main(int argc, char *args[])
delete mobiCoreDriverDaemon;
- pthread_mutex_destroy(&syncMutex);
- pthread_cond_destroy(&syncCondition);
-
// This should not happen
LOG_E("Exiting <t-base Daemon");
@@ -1410,29 +1414,28 @@ static void checkMobiCoreVersion(
// Check <t-base version info.
char *msg;
if (!checkVersionOkMCI(versionPayload.versionInfo.versionMci, &msg)) {
- LOG_E("checkVersionOkMCI failed - %s", msg);
+ LOG_E("%s", msg);
failed = true;
}
- LOG_I_RELEASE("versionMci - %s", msg);
+ LOG_I_RELEASE("%s", msg);
if (!checkVersionOkSO(versionPayload.versionInfo.versionSo, &msg)) {
- LOG_E("checkVersionOkSO failed - %s", msg);
+ LOG_E("%s", msg);
failed = true;
}
- LOG_I_RELEASE("versionSo - %s", msg);
+ LOG_I_RELEASE("%s", msg);
if (!checkVersionOkMCLF(versionPayload.versionInfo.versionMclf, &msg)) {
- LOG_E("checkVersionOkMCLF failed - %s", msg);
+ LOG_E("%s", msg);
failed = true;
}
- LOG_I_RELEASE("versionInfo - %s", msg);
+ LOG_I_RELEASE("%s", msg);
if (!checkVersionOkCONTAINER(versionPayload.versionInfo.versionContainer, &msg)) {
- LOG_E("checkVersionOkCONTAINER failed - %s", msg);
+ LOG_E("%s", msg);
failed = true;
}
- LOG_I_RELEASE("versionContainer - %s", msg);
+ LOG_I_RELEASE("%s", msg);
}
if (failed) {
- LOG_E("Failed to check mobiCore version");
exit(1);
}
}
@@ -1456,7 +1459,7 @@ bool MobiCoreDriverDaemon::loadToken(uint8_t *token, uint32_t sosize)
/* Initialize information data of LOAD_TOKEN command */
loadTokenData_t loadTokenData;
loadTokenData.addr = pWsm->physAddr;
- loadTokenData.offs = ((uint32_t) token) & 0xFFF;
+ loadTokenData.offs = ((uintptr_t) token) & 0xFFF;
loadTokenData.len = sosize;
conn = new Connection();
@@ -1465,7 +1468,11 @@ bool MobiCoreDriverDaemon::loadToken(uint8_t *token, uint32_t sosize)
/* Unregister physical memory from kernel module. This will also destroy
* the WSM object.
*/
- mobiCoreDevice->unregisterWsmL2(pWsm);
+ if (!mobiCoreDevice->unregisterWsmL2(pWsm)) {
+ LOG_E("Unregistering of WsmL2 failed.");
+ pWsm = NULL;
+ break;
+ }
pWsm = NULL;
if (mcRet != MC_MCP_RET_OK) {
@@ -1482,4 +1489,58 @@ bool MobiCoreDriverDaemon::loadToken(uint8_t *token, uint32_t sosize)
return ret;
}
-/** @} */
+//------------------------------------------------------------------------------
+void MobiCoreDriverDaemon::installEndorsementToken(void)
+{
+ /* Look for tokens in the registry and pass them to <t-base for endorsement
+ * purposes.
+ */
+ LOG_I("Looking for suitable tokens");
+
+ mcSoAuthTokenCont_t authtoken;
+ mcSoAuthTokenCont_t authtokenbackup;
+ mcSoRootCont_t rootcont;
+ uint32_t sosize;
+ uint8_t *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_I("Failed to read AuthToken (ret=%u). Trying AuthToken backup", ret);
+
+ ret = mcRegistryReadAuthTokenBackup(&authtokenbackup);
+ if (ret != MC_DRV_OK) {
+ LOG_I("Failed to read AuthToken backup (ret=%u). Trying Root Cont", 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 backup.");
+ p = (uint8_t *) &authtokenbackup;
+ sosize = sizeof(authtokenbackup);
+ }
+
+ } 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");
+ }
+ }
+}
diff --git a/mobicore/daemon/Daemon/MobiCoreDriverDaemon.h b/mobicore/MobiCoreDriverLib/Daemon/MobiCoreDriverDaemon.h
index b13c8fa..2c4b807 100644
--- a/mobicore/daemon/Daemon/MobiCoreDriverDaemon.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/MobiCoreDriverDaemon.h
@@ -1,11 +1,4 @@
-/** @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.
*
@@ -35,6 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * <t-base driver class.
+ * The <t-base driver class implements the ConnectionHandler interface.
+ */
#ifndef MOBICOREDRIVER_H_
#define MOBICOREDRIVER_H_
@@ -262,8 +259,14 @@ private:
* @param sosize the size of the token
*/
bool loadToken(uint8_t *token, uint32_t sosize);
+
+ /**
+ * 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);
};
#endif /* MOBICOREDRIVER_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/Server/Android.mk b/mobicore/MobiCoreDriverLib/Daemon/Server/Android.mk
index 3f92d73..3f92d73 100644
--- a/mobicore/daemon/Daemon/Server/Android.mk
+++ b/mobicore/MobiCoreDriverLib/Daemon/Server/Android.mk
diff --git a/mobicore/daemon/Daemon/Server/NetlinkServer.cpp b/mobicore/MobiCoreDriverLib/Daemon/Server/NetlinkServer.cpp
index 5ffd41b..0e88cce 100644
--- a/mobicore/daemon/Daemon/Server/NetlinkServer.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/Server/NetlinkServer.cpp
@@ -1,11 +1,3 @@
-/** @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.
@@ -36,6 +28,11 @@
* 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 clients using the MobiCore driver.
+ */
#include "public/NetlinkServer.h"
#include <unistd.h>
#include <string.h>
@@ -82,7 +79,7 @@ void NetlinkServer::run(
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) {
+ if (bind(serverSock, (struct sockaddr *)&src_addr, sizeof(src_addr)) < 0) {
LOG_ERRNO("Binding to server socket failed, because bind");
close(serverSock);
serverSock = -1;
@@ -284,4 +281,3 @@ void NetlinkServer::cleanupConnections(
}
}
-/** @} */
diff --git a/mobicore/daemon/Daemon/Server/Server.cpp b/mobicore/MobiCoreDriverLib/Daemon/Server/Server.cpp
index 540e666..418d8b0 100644
--- a/mobicore/daemon/Daemon/Server/Server.cpp
+++ b/mobicore/MobiCoreDriverLib/Daemon/Server/Server.cpp
@@ -1,11 +1,3 @@
-/** @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.
@@ -36,6 +28,11 @@
* 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 clients using the MobiCore driver.
+ */
#include "public/Server.h"
#include <unistd.h>
#include <string.h>
@@ -43,10 +40,7 @@
//#define LOG_VERBOSE
#include "log.h"
-
-extern pthread_mutex_t syncMutex;
-extern pthread_cond_t syncCondition;
-extern bool Th_sync;
+#include "FSD.h"
//------------------------------------------------------------------------------
Server::Server(
@@ -64,8 +58,10 @@ void Server::run(
void
)
{
+ bool isFSDStarted=false;
+ FSD *FileStorageDaemon=NULL;
+
do {
- pthread_mutex_lock(&syncMutex);
LOG_I("Server: start listening on socket %s", socketAddr.c_str());
@@ -120,9 +116,14 @@ void Server::run(
}
}
- pthread_cond_signal(&syncCondition);
- Th_sync=true;
- pthread_mutex_unlock(&syncMutex);
+ if (!isFSDStarted) {
+ // Create the <t-base File Storage Daemon
+ FileStorageDaemon = new FSD();
+ // Start File Storage Daemon
+ FileStorageDaemon->start("McDaemon.FSD");
+
+ isFSDStarted=true;
+ }
// Wait for activities, select() returns the number of sockets
// which require processing
@@ -208,6 +209,12 @@ void Server::run(
} while (false);
+ //Wait for File Storage Daemon to exit
+ if (FileStorageDaemon) {
+ FileStorageDaemon->join();
+ delete FileStorageDaemon;
+ }
+
LOG_ERRNO("Exiting Server, because");
}
@@ -252,4 +259,3 @@ Server::~Server(
}
}
-/** @} */
diff --git a/mobicore/daemon/Daemon/Server/public/ConnectionHandler.h b/mobicore/MobiCoreDriverLib/Daemon/Server/public/ConnectionHandler.h
index f647398..8c769e2 100644
--- a/mobicore/daemon/Daemon/Server/public/ConnectionHandler.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/Server/public/ConnectionHandler.h
@@ -1,10 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_SRV
- * @{
- * @file
- *
- * Interface for connection handlers used by Server.
- *
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -34,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Interface for connection handlers used by Server.
+ */
#ifndef CONNECTIONHANDLER_H_
#define CONNECTIONHANDLER_H_
@@ -70,4 +67,3 @@ public:
#endif /* CONNECTIONHANDLER_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/Server/public/NetlinkServer.h b/mobicore/MobiCoreDriverLib/Daemon/Server/public/NetlinkServer.h
index 14e8b85..f272368 100644
--- a/mobicore/daemon/Daemon/Server/public/NetlinkServer.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/Server/public/NetlinkServer.h
@@ -1,14 +1,4 @@
-/** @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.
*
@@ -38,6 +28,13 @@
* 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 clients using the MobiCore driver.
+ *
+ * Iterative socket server using Netlink dgram protocol.
+ */
#ifndef NETLINKSERVER_H_
#define NETLINKSERVER_H_
@@ -158,4 +155,3 @@ private:
#endif /* SERVER_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/Server/public/Server.h b/mobicore/MobiCoreDriverLib/Daemon/Server/public/Server.h
index fb09f23..28b74cc 100644
--- a/mobicore/daemon/Daemon/Server/public/Server.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/Server/public/Server.h
@@ -1,14 +1,4 @@
-/** @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.
*
@@ -38,6 +28,13 @@
* 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 clients using the MobiCore driver.
+ *
+ * Iterative socket server using UNIX domain stream protocol.
+ */
#ifndef SERVER_H_
#define SERVER_H_
@@ -109,4 +106,3 @@ private:
#endif /* SERVER_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/public/MobiCoreDriverCmd.h b/mobicore/MobiCoreDriverLib/Daemon/public/MobiCoreDriverCmd.h
index 4ec72b5..5b02c80 100644
--- a/mobicore/daemon/Daemon/public/MobiCoreDriverCmd.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/public/MobiCoreDriverCmd.h
@@ -1,8 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON
- * @{
- * @file
- *
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -289,4 +285,3 @@ typedef union {
#endif /* MCDAEMON_H_ */
-/** @} */
diff --git a/mobicore/daemon/Daemon/public/mcVersion.h b/mobicore/MobiCoreDriverLib/Daemon/public/mcVersion.h
index a6cd02d..07d40ac 100644
--- a/mobicore/daemon/Daemon/public/mcVersion.h
+++ b/mobicore/MobiCoreDriverLib/Daemon/public/mcVersion.h
@@ -1,5 +1,4 @@
-/**
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
diff --git a/mobicore/daemon/Kernel/Android.mk b/mobicore/MobiCoreDriverLib/Kernel/Android.mk
index a01b410..a01b410 100644
--- a/mobicore/daemon/Kernel/Android.mk
+++ b/mobicore/MobiCoreDriverLib/Kernel/Android.mk
diff --git a/mobicore/daemon/Kernel/CKMod.cpp b/mobicore/MobiCoreDriverLib/Kernel/CKMod.cpp
index a2fe40f..442656e 100644
--- a/mobicore/daemon/Kernel/CKMod.cpp
+++ b/mobicore/MobiCoreDriverLib/Kernel/CKMod.cpp
@@ -1,10 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_KERNEL
- * @{
- * @file
- *
- * Kernel Module Interface.
- *
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -34,7 +28,11 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Kernel Module Interface.
+ */
#include <cstdlib>
+#include <string.h>
#include <fcntl.h>
#include <sys/mman.h>
@@ -105,4 +103,3 @@ void CKMod::close(
}
}
-/** @} */
diff --git a/mobicore/daemon/Kernel/CKMod.h b/mobicore/MobiCoreDriverLib/Kernel/CKMod.h
index d0022e2..5f0ef97 100644
--- a/mobicore/daemon/Kernel/CKMod.h
+++ b/mobicore/MobiCoreDriverLib/Kernel/CKMod.h
@@ -1,10 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_KERNEL
- * @{
- * @file
- *
- * Kernel Module Interface.
- *
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -34,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * Kernel Module Interface.
+ */
#ifndef CKMOD_H_
#define CKMOD_H_
diff --git a/mobicore/daemon/Kernel/Platforms/Generic/Android.mk b/mobicore/MobiCoreDriverLib/Kernel/Platforms/Generic/Android.mk
index 8b4b8b4..8b4b8b4 100644
--- a/mobicore/daemon/Kernel/Platforms/Generic/Android.mk
+++ b/mobicore/MobiCoreDriverLib/Kernel/Platforms/Generic/Android.mk
diff --git a/mobicore/daemon/Kernel/Platforms/Generic/CMcKMod.cpp b/mobicore/MobiCoreDriverLib/Kernel/Platforms/Generic/CMcKMod.cpp
index 9bee65f..0e57874 100644
--- a/mobicore/daemon/Kernel/Platforms/Generic/CMcKMod.cpp
+++ b/mobicore/MobiCoreDriverLib/Kernel/Platforms/Generic/CMcKMod.cpp
@@ -1,11 +1,5 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_KERNEL
- * @{
- * @file
- *
- * <t-base Driver Kernel Module Interface.
- */
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * <t-base Driver Kernel Module Interface.
+ */
#include <cstdlib>
#include <sys/mman.h>
@@ -57,8 +54,7 @@ MC_CHECK_VERSION(MCDRVMODULEAPI, 1, 1);
mcResult_t CMcKMod::mapWsm(
uint32_t len,
uint32_t *pHandle,
- addr_t *pVirtAddr,
- uint64_t *pPhysAddr)
+ addr_t *pVirtAddr)
{
int ret = 0;
LOG_V(" mapWsm(): len=%d", len);
@@ -81,12 +77,13 @@ mcResult_t CMcKMod::mapWsm(
fdKMod, mapParams.phys_addr);
if (virtAddr == MAP_FAILED) {
LOG_ERRNO("mmap");
+ (void)ioctl(fdKMod, MC_IO_FREE, mapParams.handle);
return MAKE_MC_DRV_KMOD_WITH_ERRNO(errno);
}
- LOG_V(" mapped to %p, handle=%d, phys=0x%llX ", virtAddr,
- mapParams.handle, mapParams.phys_addr);
+ LOG_V(" mapped to %p, handle=%d", virtAddr,
+ mapParams.handle);
if (pVirtAddr != NULL) {
*pVirtAddr = virtAddr;
@@ -96,19 +93,13 @@ mcResult_t CMcKMod::mapWsm(
*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);
@@ -126,51 +117,28 @@ mcResult_t CMcKMod::mapMCI(
return MAKE_MC_DRV_KMOD_WITH_ERRNO(errno);
}
+ // MCI is defined as offset 0, so we do not pass the mapParams.phys_addr to mmap.
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);
}
- mapParams.addr = (unsigned long)virtAddr;
+
*pReuse = mapParams.reused;
- LOG_V(" MCI mapped to %p, handle=%d, phys=0x%llx, reused=%s",
- (void *)mapParams.addr, mapParams.handle, mapParams.phys_addr,
- mapParams.reused ? "true" : "false");
+ LOG_V(" MCI mapped to %p, handle=%d, reused=%s",
+ (void *)virtAddr, mapParams.handle,
+ mapParams.reused ? "true" : "false");
if (pVirtAddr != NULL) {
- *pVirtAddr = (void *)mapParams.addr;
- }
-
- if (pHandle != NULL) {
- *pHandle = mapParams.handle;
- }
-
- if (pPhysAddr != NULL) {
- *pPhysAddr = mapParams.phys_addr;
+ *pVirtAddr = (void *)virtAddr;
}
- // clean memory
- //memset(pMmapResp, 0, sizeof(*pMmapResp));
-
return MC_DRV_OK;
}
//------------------------------------------------------------------------------
-mcResult_t CMcKMod::mapPersistent(
- uint32_t len,
- uint32_t *pHandle,
- addr_t *pVirtAddr,
- addr_t *pPhysAddr)
-{
- // 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;
@@ -281,6 +249,7 @@ int CMcKMod::fcYield(void)
//------------------------------------------------------------------------------
+
int CMcKMod::fcNSIQ(void)
{
int ret = 0;
@@ -313,7 +282,7 @@ mcResult_t CMcKMod::free(uint32_t handle, addr_t buffer, uint32_t len)
// 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");
+ LOG_ERRNO("munmap failed");
}
int ret = ioctl(fdKMod, MC_IO_FREE, handle);
@@ -343,7 +312,7 @@ mcResult_t CMcKMod::registerWsmL2(
struct mc_ioctl_reg_wsm params = {
buffer :
- (uint32_t) buffer,
+ (uintptr_t) buffer,
len :
len,
pid :
@@ -557,4 +526,3 @@ bool CMcKMod::checkVersion(void)
return true;
}
-/** @} */
diff --git a/mobicore/daemon/Kernel/Platforms/Generic/CMcKMod.h b/mobicore/MobiCoreDriverLib/Kernel/Platforms/Generic/CMcKMod.h
index a326468..366fbbd 100644
--- a/mobicore/daemon/Kernel/Platforms/Generic/CMcKMod.h
+++ b/mobicore/MobiCoreDriverLib/Kernel/Platforms/Generic/CMcKMod.h
@@ -1,10 +1,4 @@
-/** @addtogroup MCD_MCDIMPL_DAEMON_KERNEL
- * @{
- * @file
- *
- * <t-base Driver Kernel Module Interface.
- *
- *
+/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
*
@@ -34,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * <t-base Driver Kernel Module Interface.
+ */
#ifndef CMCKMOD_H_
#define CMCKMOD_H_
@@ -55,7 +52,6 @@ public:
* @param len
* @param pHandle
* @param pVirtAddr
- * @param pPhysAddr
*
* @return 0 if all went fine
* @return MC_DRV_ERR_KMOD_NOT_OPEN
@@ -63,15 +59,12 @@ public:
*/
mcResult_t mapWsm(uint32_t len,
uint32_t *pHandle,
- addr_t *pVirtAddr,
- uint64_t *pPhysAddr);
+ addr_t *pVirtAddr);
/**
* 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
@@ -80,20 +73,9 @@ public:
*/
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);
diff --git a/mobicore/MobiCoreDriverLib/NOTICE b/mobicore/MobiCoreDriverLib/NOTICE
new file mode 100644
index 0000000..627167a
--- /dev/null
+++ b/mobicore/MobiCoreDriverLib/NOTICE
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
diff --git a/mobicore/daemon/Registry/Android.mk b/mobicore/MobiCoreDriverLib/Registry/Android.mk
index d83160c..d83160c 100644
--- a/mobicore/daemon/Registry/Android.mk
+++ b/mobicore/MobiCoreDriverLib/Registry/Android.mk
diff --git a/mobicore/daemon/Registry/PrivateRegistry.cpp b/mobicore/MobiCoreDriverLib/Registry/PrivateRegistry.cpp
index 6d69ff9..f51571b 100644
--- a/mobicore/daemon/Registry/PrivateRegistry.cpp
+++ b/mobicore/MobiCoreDriverLib/Registry/PrivateRegistry.cpp
@@ -1,13 +1,5 @@
-/** Mobicore Driver Registry.
- *
- * Implements the MobiCore driver registry which maintains trustlets.
- *
- * @file
- * @ingroup MCD_MCDIMPL_DAEMON_REG
- */
-
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,7 +28,13 @@
* 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 <dirent.h>
#include <stdio.h>
@@ -67,13 +65,13 @@
/** 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_ALL 0
+#define MC_REGISTRY_WRITABLE 1
-#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 MC_REGISTRY_SYSTEM_PATH "/system/app/mcRegistry"
+#define MC_REGISTRY_DATA_PATH "/data/app/mcRegistry"
#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"
@@ -116,43 +114,9 @@ static bool doesDirExist(const char *path)
}
//------------------------------------------------------------------------------
-string getRegistryPath()
+string getTbStoragePath()
{
- 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;
+ return MC_REGISTRY_DATA_PATH "/TbStorage";
}
//------------------------------------------------------------------------------
@@ -167,7 +131,7 @@ static string getAuthTokenFilePath()
LOG_I("getAuthTokenFilePath(): Using MC_AUTH_TOKEN_PATH %s", path);
authTokenPath = path;
} else {
- authTokenPath = getRegistryPath();
+ authTokenPath = MC_REGISTRY_DATA_PATH;
LOG_I("getAuthTokenFilePath(): Using path %s", authTokenPath.c_str());
}
@@ -175,34 +139,40 @@ static string getAuthTokenFilePath()
}
//------------------------------------------------------------------------------
+static string getAuthTokenFilePathBackup()
+{
+ return getAuthTokenFilePath() + AUTH_TOKEN_FILE_NAME_BACKUP_SUFFIX;
+}
+
+//------------------------------------------------------------------------------
static string getRootContFilePath()
{
- return getRegistryPath() + "/" + ROOT_FILE_NAME;
+ return MC_REGISTRY_DATA_PATH "/" ROOT_FILE_NAME;
}
//------------------------------------------------------------------------------
static string getSpDataPath(mcSpid_t spid)
{
- return getRegistryPath() + "/" + uint32ToString(spid);
+ return MC_REGISTRY_DATA_PATH "/" + uint32ToString(spid);
}
//------------------------------------------------------------------------------
static string getSpContFilePath(mcSpid_t spid)
{
- return getRegistryPath() + "/" + uint32ToString(spid) + SP_CONT_FILE_EXT;
+ return MC_REGISTRY_DATA_PATH "/" + uint32ToString(spid) + SP_CONT_FILE_EXT;
}
//------------------------------------------------------------------------------
static string getTlContFilePath(const mcUuid_t *uuid, const mcSpid_t spid)
{
- return getRegistryPath() + "/" + byteArrayToString(uuid, sizeof(*uuid))
+ return MC_REGISTRY_DATA_PATH "/" + byteArrayToString(uuid, sizeof(*uuid))
+ "." + uint32ToString(spid) + TL_CONT_FILE_EXT;
}
//------------------------------------------------------------------------------
static string getTlDataPath(const mcUuid_t *uuid)
{
- return getRegistryPath() + "/" + byteArrayToString(uuid, sizeof(*uuid));
+ return MC_REGISTRY_DATA_PATH "/" + byteArrayToString(uuid, sizeof(*uuid));
}
//------------------------------------------------------------------------------
@@ -212,26 +182,54 @@ static string getTlDataFilePath(const mcUuid_t *uuid, mcPid_t pid)
}
//------------------------------------------------------------------------------
-static string getTlBinFilePath(const mcUuid_t *uuid)
+static string getTlBinFilePath(const mcUuid_t *uuid, int registry)
{
- return getTlRegistryPath() + "/" + byteArrayToString(uuid, sizeof(*uuid)) + TL_BIN_FILE_EXT;
+ string path_ro_registry = MC_REGISTRY_SYSTEM_PATH"/" + byteArrayToString(uuid, sizeof(*uuid)) + TL_BIN_FILE_EXT;
+ string path_rw_registry = MC_REGISTRY_DATA_PATH"/" + byteArrayToString(uuid, sizeof(*uuid)) + TL_BIN_FILE_EXT;
+
+ if (registry == MC_REGISTRY_ALL) {
+ struct stat tmp;
+ if (stat(path_ro_registry.c_str(), &tmp) == 0) {
+ return path_ro_registry;
+ }
+ }
+ return path_rw_registry;
}
//------------------------------------------------------------------------------
-static string getTABinFilePath(const mcUuid_t *uuid)
+static string getTABinFilePath(const mcUuid_t *uuid, int registry)
{
- return getTlRegistryPath() + "/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_BIN_FILE_EXT;
+ string path_ro_registry = MC_REGISTRY_SYSTEM_PATH"/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_BIN_FILE_EXT;
+ string path_rw_registry = MC_REGISTRY_DATA_PATH"/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_BIN_FILE_EXT;
+
+ if (registry == MC_REGISTRY_ALL) {
+ struct stat tmp;
+ if (stat(path_ro_registry.c_str(), &tmp) == 0) {
+ return path_ro_registry;
+ }
+ }
+ return path_rw_registry;
}
//------------------------------------------------------------------------------
-static string getTASpidFilePath(const mcUuid_t *uuid)
+static string getTASpidFilePath(const mcUuid_t *uuid, int registry)
{
- return getTlRegistryPath() + "/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_SPID_FILE_EXT;
+ string path_ro_registry = MC_REGISTRY_SYSTEM_PATH"/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_SPID_FILE_EXT;
+ string path_rw_registry = MC_REGISTRY_DATA_PATH"/" + byteArrayToString(uuid, sizeof(*uuid)) + GP_TA_SPID_FILE_EXT;
+
+ if (registry == MC_REGISTRY_ALL) {
+ struct stat tmp;
+ if (stat(path_ro_registry.c_str(), &tmp) == 0) {
+ return path_ro_registry;
+ }
+ }
+ return path_rw_registry;
}
//------------------------------------------------------------------------------
mcResult_t mcRegistryStoreAuthToken(void *so, uint32_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;
@@ -240,12 +238,22 @@ mcResult_t mcRegistryStoreAuthToken(void *so, uint32_t size)
LOG_I("store AuthToken: %s", authTokenFilePath.c_str());
FILE *fs = fopen(authTokenFilePath.c_str(), "wb");
- if (!fs) {
+ if (fs==NULL) {
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);
+ res = fseek(fs, 0, SEEK_SET);
+ if (res!=0) {
+ LOG_E("mcRegistry store So.Soc failed: %d", MC_DRV_ERR_INVALID_PARAMETER);
+ fclose(fs);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
fwrite((char *)so, 1, size, fs);
+ if (ferror(fs)) {
+ LOG_E("mcRegistry store So.Soc failed %d", MC_DRV_ERR_OUT_OF_RESOURCES);
+ fclose(fs);
+ return MC_DRV_ERR_OUT_OF_RESOURCES;
+ }
fflush(fs);
fclose(fs);
@@ -256,6 +264,7 @@ mcResult_t mcRegistryStoreAuthToken(void *so, uint32_t size)
//------------------------------------------------------------------------------
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;
@@ -264,23 +273,99 @@ mcResult_t mcRegistryReadAuthToken(mcSoAuthTokenCont_t *so)
LOG_I("read AuthToken: %s", authTokenFilePath.c_str());
FILE *fs = fopen(authTokenFilePath.c_str(), "rb");
- if (!fs) {
+ if (fs==NULL) {
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);
+ 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;
+ }
int32_t 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;
}
- fseek(fs, 0, SEEK_SET);
- if (fread((char *)so, 1, sizeof(mcSoAuthTokenCont_t), fs) !=
- sizeof(mcSoAuthTokenCont_t))
- {
+ 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;
+ }
+ res = fread((char *)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 ((unsigned)res<sizeof(mcSoAuthTokenCont_t)) {
+ //File is shorter than expected
+ if (feof(fs)) {
+ LOG_E("%s(): EOF reached: res is %u, size of mcSoAuthTokenCont_t is %u", __func__, (unsigned)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 string &authTokenFilePath = getAuthTokenFilePathBackup();
+ LOG_I("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;
+ }
+ int32_t 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;
+ }
+ res = fread((char *)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 ((unsigned)res<sizeof(mcSoAuthTokenCont_t)) {
+ //File is shorter than expected
+ if (feof(fs)) {
+ LOG_E("%s(): EOF reached: res is %u, size of mcSoAuthTokenCont_t is %u", __func__,
+ (unsigned)res, 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);
@@ -291,8 +376,8 @@ mcResult_t mcRegistryReadAuthToken(mcSoAuthTokenCont_t *so)
//------------------------------------------------------------------------------
mcResult_t mcRegistryDeleteAuthToken(void)
{
- if (remove(getAuthTokenFilePath().c_str())) {
- LOG_ERRNO("Delete Auth token file!");
+ if (rename(getAuthTokenFilePath().c_str(), getAuthTokenFilePathBackup().c_str())) {
+ LOG_ERRNO("Rename Auth token file!");
return MC_DRV_ERR_UNKNOWN;
} else
return MC_DRV_OK;
@@ -302,6 +387,7 @@ mcResult_t mcRegistryDeleteAuthToken(void)
//------------------------------------------------------------------------------
mcResult_t mcRegistryStoreRoot(void *so, uint32_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;
@@ -311,12 +397,22 @@ mcResult_t mcRegistryStoreRoot(void *so, uint32_t size)
LOG_I("store Root: %s", rootContFilePath.c_str());
FILE *fs = fopen(rootContFilePath.c_str(), "wb");
- if (!fs) {
+ if (fs==NULL) {
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);
+ 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((char *)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);
@@ -337,11 +433,16 @@ mcResult_t mcRegistryReadRoot(void *so, uint32_t *size)
LOG_I(" Opening %s", rootContFilePath.c_str());
FILE *fs = fopen(rootContFilePath.c_str(), "rb");
- if (!fs) {
+ 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((char *)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) {
@@ -357,6 +458,7 @@ mcResult_t mcRegistryReadRoot(void *so, uint32_t *size)
//------------------------------------------------------------------------------
mcResult_t mcRegistryStoreSp(mcSpid_t spid, void *so, uint32_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;
@@ -366,12 +468,22 @@ mcResult_t mcRegistryStoreSp(mcSpid_t spid, void *so, uint32_t size)
LOG_I("store SP: %s", spContFilePath.c_str());
FILE *fs = fopen(spContFilePath.c_str(), "wb");
- if (!fs) {
+ 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;
}
- fseek(fs, 0, SEEK_SET);
+ 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((char *)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);
@@ -391,11 +503,16 @@ mcResult_t mcRegistryReadSp(mcSpid_t spid, void *so, uint32_t *size)
LOG_I(" Reading %s", spContFilePath.c_str());
FILE *fs = fopen(spContFilePath.c_str(), "rb");
- if (!fs) {
+ 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((char *)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) {
@@ -411,6 +528,7 @@ mcResult_t mcRegistryReadSp(mcSpid_t spid, void *so, uint32_t *size)
//------------------------------------------------------------------------------
mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_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;
@@ -420,12 +538,22 @@ mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid,
LOG_I("store TLc: %s", tlContFilePath.c_str());
FILE *fs = fopen(tlContFilePath.c_str(), "wb");
- if (!fs) {
+ 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;
}
- fseek(fs, 0, SEEK_SET);
+ 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((char *)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);
@@ -443,7 +571,7 @@ static uint32_t getAsUint32BE(
mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, void *blob, uint32_t size)
{
-
+ int res = 0;
LOG_I("mcRegistryStoreTABlob started");
// Check blob size
@@ -517,33 +645,53 @@ mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, void *blob, uint32_t size)
return MC_DRV_ERR_INVALID_PARAMETER;
}
}
- const string tlBinFilePath = getTABinFilePath((mcUuid_t *)&uuid);
+ const string taBinFilePath = getTABinFilePath((mcUuid_t *)&uuid, MC_REGISTRY_WRITABLE);
- LOG_I("Store TA blob at: %s", tlBinFilePath.c_str());
+ LOG_I("Store TA blob at: %s", taBinFilePath.c_str());
- FILE *fs = fopen(tlBinFilePath.c_str(), "wb");
- if (!fs) {
+ 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;
}
- fseek(fs, 0, SEEK_SET);
+ 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 string taspidFilePath = getTASpidFilePath((mcUuid_t *)&uuid);
+ const string taspidFilePath = getTASpidFilePath((mcUuid_t *)&uuid, MC_REGISTRY_WRITABLE);
LOG_I("Store spid file at: %s", taspidFilePath.c_str());
FILE *fs = fopen(taspidFilePath.c_str(), "wb");
- if (!fs) {
+ if (fs==NULL) {
//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);
+ 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);
}
@@ -553,6 +701,7 @@ mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, void *blob, uint32_t size)
//------------------------------------------------------------------------------
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;
@@ -562,12 +711,22 @@ mcResult_t mcRegistryReadTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid,
LOG_I("read TLc: %s", tlContFilePath.c_str());
FILE *fs = fopen(tlContFilePath.c_str(), "rb");
- if (!fs) {
+ 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;
}
- fseek(fs, 0, SEEK_SET);
+ 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((char *)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) {
@@ -584,6 +743,7 @@ mcResult_t mcRegistryReadTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid,
mcResult_t mcRegistryStoreData(void *so, uint32_t size)
{
mcSoDataCont_t *dataCont = (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);
@@ -613,12 +773,22 @@ mcResult_t mcRegistryStoreData(void *so, uint32_t size)
LOG_I("store DT: %s", filename.c_str());
FILE *fs = fopen(filename.c_str(), "wb");
- if (!fs) {
+ 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;
}
- fseek(fs, 0, SEEK_SET);
+ 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((char *)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);
@@ -630,6 +800,7 @@ mcResult_t mcRegistryStoreData(void *so, uint32_t size)
mcResult_t mcRegistryReadData(uint32_t context, const mcCid_t *cid, mcPid_t pid,
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);
@@ -651,36 +822,61 @@ mcResult_t mcRegistryReadData(uint32_t context, const mcCid_t *cid, mcPid_t pid,
LOG_I("read DT: %s", filename.c_str());
FILE *fs = fopen(filename.c_str(), "rb");
- if (!fs) {
+ 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;
}
- fseek(fs, 0, SEEK_END);
+ 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;
+ }
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);
+ 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 = (char *) so;
- if (fread(p, 1, sizeof(mcSoHeader_t), fs) != sizeof(mcSoHeader_t))
- {
+ 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 ((unsigned)res<sizeof(mcSoHeader_t)) {
+ //File is shorter than expected
+ if (feof(fs)) {
+ LOG_E("%s(): EOF reached: res is %u, size of mcSoHeader_t is %u", __func__, (unsigned)res, sizeof(mcSoHeader_t));
+ }
+ fclose(fs);
+ return MC_DRV_ERR_INVALID_PARAMETER;
+ }
p += sizeof(mcSoHeader_t);
- if (fread(p, 1, MC_SO_SIZE(so->soHeader.plainLen,
+ res = 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))
- {
+ - 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 ((unsigned)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 %u, size of secure object is %u", __func__, (unsigned)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;
@@ -695,6 +891,7 @@ static size_t getFileContent(
FILE *pStream;
long filesize;
uint8_t *content = NULL;
+ int res = 0;
/* Open the file */
pStream = fopen(pPath, "rb");
@@ -733,10 +930,18 @@ static size_t getFileContent(
}
/* Read data from the file into the buffer */
- if (fread(content, (size_t)filesize, 1, pStream) != 1) {
+ res = fread(content, (size_t)filesize, 1, pStream);
+ if (ferror(pStream)) {
LOG_E("Error: Cannot read file: %s.", pPath);
goto error;
}
+ if ((unsigned)res<1) {
+ //File is shorter than expected
+ if (feof(pStream)) {
+ LOG_E("Error: EOF reached: %s.", pPath);
+ }
+ goto error;
+ }
/* Close the file */
fclose(pStream);
@@ -796,13 +1001,12 @@ static bool mcCheckUuid(const mcUuid_t *uuid, const char *filename)
//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)
+static int CleanupGPTAStorage(const char *uuid)
{
DIR *dp;
struct dirent *de;
int e;
- string TAPath = getRegistryPath()+"/TbStorage/"+ basename;
-
+ string TAPath = getTbStoragePath() + "/" + uuid;
if (NULL != (dp = opendir(TAPath.c_str()))) {
while (NULL != (de = readdir(dp))) {
if (de->d_name[0] != '.') {
@@ -825,21 +1029,20 @@ static int CleanupGPTAStorage(const char *basename)
return MC_DRV_OK;
}
-static void deleteSPTA(const mcUuid_t *uuid, const mcSpid_t spid, bool checkUuid)
+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
- string pathname = getRegistryPath();
- if (NULL != (dp = opendir(pathname.c_str()))) {
+ if (NULL != (dp = opendir(MC_REGISTRY_DATA_PATH))) {
while (NULL != (de = readdir(dp))) {
string spidFile;
string tabinFile;
string tabinUuid;
size_t pch_dot, pch_slash;
- spidFile = pathname + '/' + string(de->d_name);
+ spidFile = MC_REGISTRY_DATA_PATH "/" + string(de->d_name);
pch_dot = spidFile.find_last_of('.');
if (pch_dot == string::npos) continue;
pch_slash = spidFile.find_last_of('/');
@@ -857,28 +1060,31 @@ static void deleteSPTA(const mcUuid_t *uuid, const mcSpid_t spid, bool checkUuid
}
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 (mcCheckUuid(uuid, tabinFile.c_str())) {
+ tabinUuid = spidFile.substr(0, pch_dot);
+ tabinUuid = tabinUuid.substr(tabinUuid.find_last_of('/')+1);
+ LOG_I("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_I("Remove TA file %s", tabinFile.c_str());
if (0 != (e = remove(tabinFile.c_str()))) {
- LOG_E("remove TA file failed! errno: %d", e);
- //return MC_DRV_ERR_UNKNOWN;
+ LOG_E("Remove TA file failed! errno: %d", e);
+ /* Discard error */
}
+ LOG_I("Remove spid file %s", spidFile.c_str());
if (0 != (e = remove(spidFile.c_str()))) {
- LOG_E("remove SPID file failed! errno: %d", e);
- //return MC_DRV_ERR_UNKNOWN;
+ LOG_E("Remove spid file failed! errno: %d", e);
+ /* Discard error */
}
- if (checkUuid) break;
+ break;
}
}
}
if (dp) {
closedir(dp);
}
-
}
}
@@ -916,23 +1122,27 @@ mcResult_t mcRegistryCleanupTrustlet(const mcUuid_t *uuid, const mcSpid_t spid)
}
}
- // 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)
- }
+ string tlBinFilePath = getTlBinFilePath(uuid, MC_REGISTRY_WRITABLE);
+ struct stat tmp;
+ string tlContFilePath = getTlContFilePath(uuid, spid);;
- // Delete TABIN and SPID files - we loop searching required spid file
- deleteSPTA(uuid,spid,true);
+ if (stat(tlBinFilePath.c_str(), &tmp) == 0) {
+ /* Legacy TA */
+ LOG_I("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);
+ }
- string tlContFilePath = getTlContFilePath(uuid, spid);
- LOG_I("delete Tlc: %s", tlContFilePath.c_str());
+ LOG_I("Remove TA container %s", tlContFilePath.c_str());
if (0 != (e = remove(tlContFilePath.c_str()))) {
- LOG_E("remove Tlc failed! errno: %d", e);
+ LOG_E("Remove TA container failed! errno: %d", e);
return MC_DRV_ERR_UNKNOWN;
}
+
return MC_DRV_OK;
}
@@ -967,9 +1177,6 @@ mcResult_t mcRegistryCleanupSp(mcSpid_t spid)
return ret;
}
- // Delete remaining TABIN and SPID files
- deleteSPTA(NULL,spid,false);
-
string pathname = getSpDataPath(spid);
if (NULL != (dp = opendir(pathname.c_str()))) {
@@ -1057,9 +1264,6 @@ regObject_t *mcRegistryMemGetServiceBlob(mcSpid_t spid, void *trustlet, uint32_t
LOG_E("mcRegistryMemGetServiceBlob() failed: wrong header magic value: %d", pIntro->magic);
return NULL;
}
- LOG_I(" Service intro version %u.%u",
- MC_GET_MAJOR_VERSION(pIntro->version),
- MC_GET_MINOR_VERSION(pIntro->version));
// Get service type.
mclfHeaderV2_t *pHeader = (mclfHeaderV2_t *)trustlet;
@@ -1073,11 +1277,7 @@ regObject_t *mcRegistryMemGetServiceBlob(mcSpid_t spid, void *trustlet, uint32_t
}
#endif
- LOG_I(" Trustlet version %u.%u text %u data %u ",
- MC_GET_MAJOR_VERSION(pIntro->version),
- MC_GET_MINOR_VERSION(pIntro->version),
- pHeader->text.len,
- pHeader->data.len);
+ 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) {
@@ -1239,15 +1439,15 @@ regObject_t *mcRegistryGetServiceBlob(const mcUuid_t *uuid, bool isGpUuid)
// Open service blob file.
string tlBinFilePath;
if (isGpUuid) {
- tlBinFilePath = getTABinFilePath(uuid);
+ tlBinFilePath = getTABinFilePath(uuid, MC_REGISTRY_ALL);
} else {
- tlBinFilePath = getTlBinFilePath(uuid);
+ tlBinFilePath = getTlBinFilePath(uuid, MC_REGISTRY_ALL);
}
LOG_I("Loading %s", tlBinFilePath.c_str());
mcSpid_t spid = 0;
if (isGpUuid) {
- string taspidFilePath = getTASpidFilePath(uuid);
+ string taspidFilePath = getTASpidFilePath(uuid, MC_REGISTRY_ALL);
int fd = open(taspidFilePath.c_str(), O_RDONLY);
if (fd == -1) {
// This can be ok for System TAs
@@ -1290,4 +1490,3 @@ regObject_t *mcRegistryGetDriverBlob(const char *filename)
return regobj;
}
-/** @} */
diff --git a/mobicore/daemon/Registry/PrivateRegistry.h b/mobicore/MobiCoreDriverLib/Registry/PrivateRegistry.h
index 9404939..e885d8c 100644
--- a/mobicore/daemon/Registry/PrivateRegistry.h
+++ b/mobicore/MobiCoreDriverLib/Registry/PrivateRegistry.h
@@ -1,12 +1,3 @@
-/**
- * @addtogroup MCD_MCDIMPL_DAEMON_REG
- * @{
- * G&D MobiCore Registry Private implementation
- *
- * @file
- * Mobicore Driver Registry.
- */
-
/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
@@ -37,6 +28,9 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/**
+ * MobiCore Registry Private implementation
+ */
#ifndef MOBICORE_REGISTRY_H_
#define MOBICORE_REGISTRY_H_
@@ -71,6 +65,12 @@ extern "C" {
*/
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.
*/
@@ -213,4 +213,3 @@ extern "C" {
#endif // MOBICORE_REGISTRY_H_
-/** @} */
diff --git a/mobicore/daemon/Registry/Public/MobiCoreRegistry.h b/mobicore/MobiCoreDriverLib/Registry/Public/MobiCoreRegistry.h
index c629b14..ccdb756 100644
--- a/mobicore/daemon/Registry/Public/MobiCoreRegistry.h
+++ b/mobicore/MobiCoreDriverLib/Registry/Public/MobiCoreRegistry.h
@@ -1,12 +1,3 @@
-/**
- * @addtogroup MCD_MCDIMPL_DAEMON_REG
- * @{
- * G&D MobiCore Registry
- *
- * @file
- * Mobicore Driver Registry.
- */
-
/*
* Copyright (c) 2013 TRUSTONIC LIMITED
* All rights reserved.
@@ -147,4 +138,3 @@ extern "C" {
#endif // MOBICORE_REGISTRY_H_
-/** @} */
diff --git a/mobicore/daemon/Registry/Registry.cpp b/mobicore/MobiCoreDriverLib/Registry/Registry.cpp
index a900529..6f193fa 100644
--- a/mobicore/daemon/Registry/Registry.cpp
+++ b/mobicore/MobiCoreDriverLib/Registry/Registry.cpp
@@ -1,11 +1,3 @@
-/** 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.
@@ -36,6 +28,13 @@
* 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 <stdlib.h>
#include <dirent.h>
@@ -128,7 +127,7 @@ mcDrvResponseHeader_t rsp = { responseId :
//------------------------------------------------------------------------------
mcResult_t mcRegistryStoreAuthToken(void *so, uint32_t size)
{
- typedef struct {
+ typedef struct __attribute ((packed)) {
uint32_t commandId;
uint32_t soSize;
uint8_t so;
@@ -179,7 +178,7 @@ mcDrvCommandHeader_t cmd = { commandId :
//------------------------------------------------------------------------------
mcResult_t mcRegistryStoreRoot(void *so, uint32_t size)
{
- typedef struct {
+ typedef struct __attribute ((packed)) {
uint32_t commandId;
uint32_t soSize;
uint8_t so;
@@ -227,7 +226,7 @@ mcDrvCommandHeader_t cmd = { commandId :
//------------------------------------------------------------------------------
mcResult_t mcRegistryStoreSp(mcSpid_t spid, void *so, uint32_t size)
{
- typedef struct {
+ typedef struct __attribute ((packed)) {
uint32_t commandId;
uint32_t soSize;
mcSpid_t spid;
@@ -288,7 +287,7 @@ mcResult_t mcRegistryCleanupSp(mcSpid_t spid)
//------------------------------------------------------------------------------
mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid, mcSpid_t spid, void *so, uint32_t size)
{
- typedef struct {
+ typedef struct __attribute ((packed)) {
uint32_t commandId;
uint32_t soSize;
mcUuid_t uuid;
@@ -395,4 +394,3 @@ mcResult_t mcRegistryReadData(uint32_t context, const mcCid_t *cid, mcPid_t pid,
return MC_DRV_ERR_INVALID_PARAMETER;
}
-/** @} */
diff --git a/mobicore/daemon/build.sh b/mobicore/MobiCoreDriverLib/build.sh
index 55a1593..55a1593 100644
--- a/mobicore/daemon/build.sh
+++ b/mobicore/MobiCoreDriverLib/build.sh
diff --git a/mobicore/MobiCoreDriverLib/buildTag.h b/mobicore/MobiCoreDriverLib/buildTag.h
new file mode 100644
index 0000000..b1d9959
--- /dev/null
+++ b/mobicore/MobiCoreDriverLib/buildTag.h
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+/** Build tag created during build by /home/buildserver/jenkins/workspace/CI_Trunk_BuildAndTest_TestRun-Arndale/dev/components/MobiCoreDriver/Linux/Daemon/../../../../../build/tools/Scripts/setBuildTag.sh. */
+#define MOBICORE_COMPONENT_BUILD_TAG \
+ " t-base-Qualcomm-MSM8994-Android-301B-V001"
diff --git a/mobicore/NOTICE b/mobicore/NOTICE
deleted file mode 100644
index d742e22..0000000
--- a/mobicore/NOTICE
+++ /dev/null
@@ -1,25 +0,0 @@
- 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
diff --git a/mobicore/common/DrSecureStorage/dci.h b/mobicore/common/DrSecureStorage/dci.h
deleted file mode 100644
index c805f5c..0000000
--- a/mobicore/common/DrSecureStorage/dci.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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__
diff --git a/mobicore/common/DrSecureStorage/drError.h b/mobicore/common/DrSecureStorage/drError.h
deleted file mode 100644
index d686bc1..0000000
--- a/mobicore/common/DrSecureStorage/drError.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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__
-
-
diff --git a/mobicore/common/DrSecureStorage/tee_internal_api.h b/mobicore/common/DrSecureStorage/tee_internal_api.h
deleted file mode 100644
index 05119a3..0000000
--- a/mobicore/common/DrSecureStorage/tee_internal_api.h
+++ /dev/null
@@ -1,1109 +0,0 @@
-/*
- * 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__ */
diff --git a/mobicore/common/DrSecureStorage/tlDriverApi.h b/mobicore/common/DrSecureStorage/tlDriverApi.h
deleted file mode 100644
index 6f42056..0000000
--- a/mobicore/common/DrSecureStorage/tlDriverApi.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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__
diff --git a/mobicore/common/LogWrapper/Android.mk b/mobicore/common/LogWrapper/Android.mk
new file mode 100644
index 0000000..b869c2b
--- /dev/null
+++ b/mobicore/common/LogWrapper/Android.mk
@@ -0,0 +1,15 @@
+# =============================================================================
+#
+# MobiCore log wrapper to be included by Android components / products
+#
+# =============================================================================
+
+# This is not a separate module.
+# Only for inclusion by other modules.
+
+LOCAL_SHARED_LIBRARIES += liblog
+
+# Enable logging to logcat per default
+LOCAL_CFLAGS += -DLOG_ANDROID
+
+LOCAL_C_INCLUDES += $(call my-dir) \ No newline at end of file
diff --git a/mobicore/common/LogWrapper/log.h b/mobicore/common/LogWrapper/log.h
index 07d0872..0894827 100644
--- a/mobicore/common/LogWrapper/log.h
+++ b/mobicore/common/LogWrapper/log.h
@@ -1,41 +1,40 @@
-/** Log wrapper for Android.
- * @{
- * @file
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
+ * All rights reserved.
*
- * 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.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
*
- * <!-- Copyright Trustonic 2012-2013 -->
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce 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.
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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 <errno.h>
-#include <string.h>
#ifndef WIN32
#include <unistd.h>
#define GETPID getpid
@@ -78,10 +77,11 @@
#define LOG_W(fmt, args...) DUMMY_FUNCTION()
#else
// add LINE
- #define LOG_I(fmt, args...) LOG_i(fmt , ## args)
- #define LOG_W(fmt, args...) LOG_w(fmt , ## args)
+ #define LOG_I(fmt, args...) LOG_i(fmt";%d", ## args, __LINE__)
+ #define LOG_W(fmt, args...) LOG_w(fmt";%d", ## args, __LINE__)
#endif
- #define LOG_E(fmt, args...) LOG_e("ERROR - %s():\n***** " fmt, __FUNCTION__, ## args)
+ // 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__)
@@ -107,10 +107,10 @@
#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__)
+ #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_E(...) _LOG_x("E",__VA_ARGS__)
#define LOG_i(...) printf(__VA_ARGS__)
#define LOG_w(...) printf(__VA_ARGS__)
@@ -124,7 +124,6 @@
#define LOG_V(...) DUMMY_FUNCTION()
#endif
-#if 0
/** LOG_E() needs to be more prominent:
* Display "*********** ERROR ***********" before actual error message.
*/
@@ -132,14 +131,13 @@
do \
{ \
_LOG_E(" *****************************"); \
- _LOG_E(" *** ERROR: ", __VA_ARGS__); \
+ _LOG_E(" *** ERROR: " __VA_ARGS__); \
_LOG_E(" *** Detected in %s/%u()", __FUNCTION__, __LINE__); \
_LOG_E(" *****************************"); \
} while(1!=1)
-#endif
#define LOG_ERRNO(MESSAGE) \
- LOG_E("%s -- %s (errno %d)", MESSAGE, strerror(errno), errno);
+ LOG_E("%s failed with \"%s\"(errno %i)", MESSAGE, strerror(errno), errno);
#define LOG_I_BUF LOG_I_Buf
@@ -175,13 +173,13 @@ static void LOG_I_Buf(
{
index += sprintf(&buffer[index], "memory dump");
}
- index += sprintf(&buffer[index], " (0x%08x, %d bytes)", (uint32_t)blob,sizeOfBlob);
+ index += sprintf(&buffer[index], " (%p, %zu bytes)", blob,sizeOfBlob);
LOG_I("%s", buffer);
index = 0;
}
else if (NULL == szDescriptor)
{
- index += sprintf(&buffer[index], "Data at 0x%08x: ", (uint32_t)blob);
+ index += sprintf(&buffer[index], "Data at %p: ", blob);
}
if(sizeOfBlob == 0) {
@@ -235,4 +233,3 @@ static void LOG_I_Buf(
#endif /** TLCWRAPPERANDROIDLOG_H_ */
-/** @} */
diff --git a/mobicore/common/MobiCore/inc/DrApi/DrApi.h b/mobicore/common/MobiCore/inc/DrApi/DrApi.h
deleted file mode 100644
index 9ae1187..0000000
--- a/mobicore/common/MobiCore/inc/DrApi/DrApi.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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__
diff --git a/mobicore/common/MobiCore/inc/DrApi/DrApiCommon.h b/mobicore/common/MobiCore/inc/DrApi/DrApiCommon.h
deleted file mode 100644
index 973d86d..0000000
--- a/mobicore/common/MobiCore/inc/DrApi/DrApiCommon.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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__
-
diff --git a/mobicore/common/MobiCore/inc/DrApi/DrApiError.h b/mobicore/common/MobiCore/inc/DrApi/DrApiError.h
deleted file mode 100644
index fbac0b1..0000000
--- a/mobicore/common/MobiCore/inc/DrApi/DrApiError.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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__
-
diff --git a/mobicore/common/MobiCore/inc/DrApi/DrApiFastCall.h b/mobicore/common/MobiCore/inc/DrApi/DrApiFastCall.h
deleted file mode 100644
index 6477fe3..0000000
--- a/mobicore/common/MobiCore/inc/DrApi/DrApiFastCall.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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_ */
diff --git a/mobicore/common/MobiCore/inc/DrApi/DrApiHeap.h b/mobicore/common/MobiCore/inc/DrApi/DrApiHeap.h
deleted file mode 100644
index 8f93a24..0000000
--- a/mobicore/common/MobiCore/inc/DrApi/DrApiHeap.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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__) */
diff --git a/mobicore/common/MobiCore/inc/DrApi/DrApiIpcMsg.h b/mobicore/common/MobiCore/inc/DrApi/DrApiIpcMsg.h
deleted file mode 100644
index 410a6e3..0000000
--- a/mobicore/common/MobiCore/inc/DrApi/DrApiIpcMsg.h
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * 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__ */
-
diff --git a/mobicore/common/MobiCore/inc/DrApi/DrApiLogging.h b/mobicore/common/MobiCore/inc/DrApi/DrApiLogging.h
deleted file mode 100644
index 8e59d5b..0000000
--- a/mobicore/common/MobiCore/inc/DrApi/DrApiLogging.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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__
-
diff --git a/mobicore/common/MobiCore/inc/DrApi/DrApiMcSystem.h b/mobicore/common/MobiCore/inc/DrApi/DrApiMcSystem.h
deleted file mode 100644
index d9a4f04..0000000
--- a/mobicore/common/MobiCore/inc/DrApi/DrApiMcSystem.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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__
-
diff --git a/mobicore/common/MobiCore/inc/DrApi/DrApiMm.h b/mobicore/common/MobiCore/inc/DrApi/DrApiMm.h
deleted file mode 100644
index 0ccd991..0000000
--- a/mobicore/common/MobiCore/inc/DrApi/DrApiMm.h
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * 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__
diff --git a/mobicore/common/MobiCore/inc/DrApi/DrApiThread.h b/mobicore/common/MobiCore/inc/DrApi/DrApiThread.h
deleted file mode 100644
index 45c297f..0000000
--- a/mobicore/common/MobiCore/inc/DrApi/DrApiThread.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * 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__
diff --git a/mobicore/common/MobiCore/inc/DrApi/version.h b/mobicore/common/MobiCore/inc/DrApi/version.h
deleted file mode 100644
index b8621b4..0000000
--- a/mobicore/common/MobiCore/inc/DrApi/version.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * 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_ */
diff --git a/mobicore/common/MobiCore/inc/FwDrv/DrApiFastCall.h b/mobicore/common/MobiCore/inc/FwDrv/DrApiFastCall.h
deleted file mode 100644
index 6477fe3..0000000
--- a/mobicore/common/MobiCore/inc/FwDrv/DrApiFastCall.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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_ */
diff --git a/mobicore/common/MobiCore/inc/GP/tee_type.h b/mobicore/common/MobiCore/inc/GP/tee_type.h
deleted file mode 100644
index 8cf5898..0000000
--- a/mobicore/common/MobiCore/inc/GP/tee_type.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * 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__ */
diff --git a/mobicore/common/MobiCore/inc/GP/uuid_attestation.h b/mobicore/common/MobiCore/inc/GP/uuid_attestation.h
deleted file mode 100644
index ab8f1be..0000000
--- a/mobicore/common/MobiCore/inc/GP/uuid_attestation.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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__ */
diff --git a/mobicore/common/MobiCore/inc/McLib/GpTci.h b/mobicore/common/MobiCore/inc/McLib/GpTci.h
index 3a561fb..47df0f2 100644
--- a/mobicore/common/MobiCore/inc/McLib/GpTci.h
+++ b/mobicore/common/MobiCore/inc/McLib/GpTci.h
@@ -28,7 +28,6 @@
* 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_
@@ -78,11 +77,6 @@ typedef struct {
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
*/
diff --git a/mobicore/common/MobiCore/inc/McLib/TlApiCryptoMarshal.h b/mobicore/common/MobiCore/inc/McLib/TlApiCryptoMarshal.h
deleted file mode 100644
index 641a0ce..0000000
--- a/mobicore/common/MobiCore/inc/McLib/TlApiCryptoMarshal.h
+++ /dev/null
@@ -1,388 +0,0 @@
- /*
- * 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__
-
-/** @} */
diff --git a/mobicore/common/MobiCore/inc/McLib/TlApiStorageMarshal.h b/mobicore/common/MobiCore/inc/McLib/TlApiStorageMarshal.h
deleted file mode 100644
index b1848eb..0000000
--- a/mobicore/common/MobiCore/inc/McLib/TlApiStorageMarshal.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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__
diff --git a/mobicore/common/MobiCore/inc/McLib/TlApiTuiMarshal.h b/mobicore/common/MobiCore/inc/McLib/TlApiTuiMarshal.h
deleted file mode 100644
index 28c7808..0000000
--- a/mobicore/common/MobiCore/inc/McLib/TlApiTuiMarshal.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/** @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__
-
-/** @} */
diff --git a/mobicore/common/MobiCore/inc/McLib/mcLibWB.h b/mobicore/common/MobiCore/inc/McLib/mcLibWB.h
deleted file mode 100644
index 91b8cdf..0000000
--- a/mobicore/common/MobiCore/inc/McLib/mcLibWB.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/** @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)
diff --git a/mobicore/common/MobiCore/inc/McLib/mclib_size.h b/mobicore/common/MobiCore/inc/McLib/mclib_size.h
deleted file mode 100644
index a9fbb48..0000000
--- a/mobicore/common/MobiCore/inc/McLib/mclib_size.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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_ */
diff --git a/mobicore/common/MobiCore/inc/McLib/tplay_marshal.h b/mobicore/common/MobiCore/inc/McLib/tplay_marshal.h
deleted file mode 100644
index 955aa89..0000000
--- a/mobicore/common/MobiCore/inc/McLib/tplay_marshal.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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__
-
-
diff --git a/mobicore/common/MobiCore/inc/Mci/mci.h b/mobicore/common/MobiCore/inc/Mci/mci.h
index b9011e5..2ecbedb 100644
--- a/mobicore/common/MobiCore/inc/Mci/mci.h
+++ b/mobicore/common/MobiCore/inc/Mci/mci.h
@@ -1,32 +1,34 @@
/*
* Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce 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.
- *
*
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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.
@@ -70,9 +72,9 @@
* <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-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>
+ * <tr><td>2011-07-19</td><td>0.7</td><td>update to reflect current code changes.</td></tr>
* </table>
*
*
diff --git a/mobicore/common/MobiCore/inc/Mci/mcifc.h b/mobicore/common/MobiCore/inc/Mci/mcifc.h
index 12c34d6..07590e5 100644
--- a/mobicore/common/MobiCore/inc/Mci/mcifc.h
+++ b/mobicore/common/MobiCore/inc/Mci/mcifc.h
@@ -1,40 +1,35 @@
/*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved
+ * 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.
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce 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.
*
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
- * @addtogroup FCI
- * @{
- * @file
- * FastCall declarations.
- *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/**
* Holds the functions for SIQ, YIELD and FastCall for switching to the secure world.
- *
-
*/
#ifndef MCIFC_H_
#define MCIFC_H_
@@ -46,9 +41,40 @@
// --- global ----
#define MC_FC_INVALID ((uint32_t) 0 ) /**< Invalid FastCall ID */
+
+#if defined(__AARCH32__)
+
+// These should be handled as 64-bit FCs; now they are more like 32bits...
+#define MC_FC_STD64_BASE ((uint32_t)0xFF000000)
+#define MC_FC_STD64(x) ((uint32_t)(MC_FC_STD64_BASE + (x)))
+
+#define MC_FC_INIT MC_FC_STD64(1) /**< Initializing FastCall. */
+#define MC_FC_INFO MC_FC_STD64(2) /**< Info FastCall. */
+
+// --- MEM traces ---
+#define MC_FC_MEM_TRACE MC_FC_STD64(10) /**< Enable SWd tracing via memory */
+
+// --- store value in sDDRRAM ---
+#define MC_FC_STORE_BINFO MC_FC_STD64(20) /**< write a 32bit value in secure DDRRAM in incremented art (max 2kB) */
+#define MC_FC_LOAD_BINFO MC_FC_STD64(21) /**< load a 32bit value from secure DDRRAM using an offset */
+
+// --- system settings ---
+#define MC_FC_STAT_COUNTER MC_FC_STD64(30) /**< Require status counter */
+
+// --- sleep modes ---
+#define MC_FC_SLEEP MC_FC_STD64(40) /**< enter power-sleep */
+#define MC_FC_AFTR MC_FC_STD64(41) /**< enter AFTR-sleep (called from core-0) */
+// --- wake-up access ---
+#define MC_FC_CORE_X_WAKEUP MC_FC_STD64(50) /**< wakeup/boot core-x (optional core-number in r1, not "0" ) */
+#define MC_FC_C15_RESUME MC_FC_STD64(51) /**< Write power control & diag registers */
+#define MC_FC_CMD_SAVE MC_FC_STD64(52) /**< Save core context to CP15 table(r1 is core number) */
+#define MC_FC_CMD_SHUTDOWN MC_FC_STD64(53) /**< Shutdown core(r1 is core number, cache flush is expected) */
+#define MC_FC_SWAP_CPU MC_FC_STD64(54) /**< Change new active Core */
+
+#else
+
#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 */
@@ -58,6 +84,8 @@
#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) */
+// --- fiq debugger ---
+#define MC_FC_ENABLE_INTERRUPT_FIQ_DUMP ((uint32_t)(-8)) /**< enable a certain interrupt, r1 is the interrupt id */
// --- 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 */
@@ -75,13 +103,11 @@
#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
+#endif
+
/** @} */
/** @name MobiCore SMC Defines
diff --git a/mobicore/common/MobiCore/inc/Mci/mcifcfunc.h b/mobicore/common/MobiCore/inc/Mci/mcifcfunc.h
deleted file mode 100644
index 895507e..0000000
--- a/mobicore/common/MobiCore/inc/Mci/mcifcfunc.h
+++ /dev/null
@@ -1,193 +0,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. 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_ */
-/**
- * @}*/
diff --git a/mobicore/common/MobiCore/inc/Mci/mcimcp.h b/mobicore/common/MobiCore/inc/Mci/mcimcp.h
index 1dc30e2..f03510d 100644
--- a/mobicore/common/MobiCore/inc/Mci/mcimcp.h
+++ b/mobicore/common/MobiCore/inc/Mci/mcimcp.h
@@ -1,33 +1,34 @@
/*
* Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce 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.
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
- *
- * @addtogroup MCP
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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
diff --git a/mobicore/common/MobiCore/inc/Mci/mcinq.h b/mobicore/common/MobiCore/inc/Mci/mcinq.h
index 4036cab..3a87545 100644
--- a/mobicore/common/MobiCore/inc/Mci/mcinq.h
+++ b/mobicore/common/MobiCore/inc/Mci/mcinq.h
@@ -1,32 +1,34 @@
/*
* Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce 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.
*
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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.
diff --git a/mobicore/common/MobiCore/inc/Mci/version.h b/mobicore/common/MobiCore/inc/Mci/version.h
index 0130941..7b577bd 100644
--- a/mobicore/common/MobiCore/inc/Mci/version.h
+++ b/mobicore/common/MobiCore/inc/Mci/version.h
@@ -1,33 +1,33 @@
/*
* Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce 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.
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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_
diff --git a/mobicore/common/MobiCore/inc/TlCm/2.0/cmp.h b/mobicore/common/MobiCore/inc/TlCm/2.0/cmp.h
index 94fa4e2..33182ad 100644
--- a/mobicore/common/MobiCore/inc/TlCm/2.0/cmp.h
+++ b/mobicore/common/MobiCore/inc/TlCm/2.0/cmp.h
@@ -15,7 +15,7 @@
* 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,
@@ -69,7 +69,7 @@ typedef struct {
mcSoAuthTokenCont_t soAuthTokenCont;
} cmpCmdBeginSocAuthentication_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_BEGIN_SOC_AUTHENTICATION_RSP Response_2_0
* @{ */
@@ -98,9 +98,9 @@ typedef struct {
cmpBeginSocAuthenticationRsp_t rsp;
} cmpRspBeginSocAuthentication_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_BEGIN_ROOT_AUTHENTICATION \
MC_CMP_2_0_CMD_BEGIN_ROOT_AUTHENTICATION
@@ -123,7 +123,7 @@ typedef struct {
mcSoRootCont_t soRootCont;
} cmpCmdBeginRootAuthentication_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_BEGIN_ROOT_AUTHENTICATION_RSP Response_2_0
* @{ */
@@ -152,9 +152,9 @@ typedef struct {
cmpBeginRootAuthenticationRsp_t rsp;
} cmpRspBeginRootAuthentication_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_BEGIN_SP_AUTHENTICATION \
MC_CMP_2_0_CMD_BEGIN_SP_AUTHENTICATION
@@ -220,7 +220,7 @@ typedef struct {
/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE MC_CMP_2_0_CMD_AUTHENTICATE
* @{ */
@@ -256,7 +256,7 @@ typedef struct {
cmpCommandHeader_t cmdHeader;
/** Encrypted and padded data. */
cmpAuthCmdEd_t ed;
-} cmpAuthCmdSdata_t;
+} cmpAuthCmdSdata_t;
/** Authenticate signed command and signature. */
typedef struct {
@@ -272,7 +272,7 @@ typedef struct {
cmpAuthenticateCmd_t cmd;
} cmpCmdAuthenticate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_RSP Response_2_0
* @{ */
@@ -321,9 +321,9 @@ typedef struct {
cmpAuthenticateRsp_t rsp;
} cmpRspAuthenticate_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_TERMINATE \
MC_CMP_2_0_CMD_AUTHENTICATE_TERMINATE
@@ -352,7 +352,7 @@ typedef struct {
cmpAuthenticateTerminateCmd_t cmd;
} cmpCmdAuthenticateTerminate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_AUTHENTICATE_TERMINATE_RSP Response_2_0
* @{ */
@@ -426,7 +426,7 @@ typedef struct {
cmpRootContRegisterActivateCmd_t cmd;
} cmpCmdRootContRegisterActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_REGISTER_ACTIVATE_RSP Response_2_0
* @{ */
@@ -518,7 +518,7 @@ typedef struct {
cmpRootContUnregisterCmd_t cmd;
} cmpCmdRootContUnregister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNREGISTER_RSP Response_2_0
* @{ */
@@ -561,9 +561,9 @@ typedef struct {
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
@@ -592,7 +592,7 @@ typedef struct {
cmpRootContLockByRootCmd_t cmd;
} cmpCmdRootContLockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_LOCK_BY_ROOT_RSP Response_2_0
* @{ */
@@ -635,9 +635,9 @@ typedef struct {
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
@@ -666,7 +666,7 @@ typedef struct {
cmpRootContUnlockByRootCmd_t cmd;
} cmpCmdRootContUnlockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_ROOT_CONT_UNLOCK_BY_ROOT_RSP Response_2_0
* @{ */
@@ -709,9 +709,9 @@ typedef struct {
mcSoRootCont_t soRootCont;
} cmpRspRootContUnlockByRoot_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_ACTIVATE \
MC_CMP_2_0_CMD_SP_CONT_REGISTER_ACTIVATE
@@ -757,7 +757,7 @@ typedef struct {
cmpSpContRegisterActivateCmd_t cmd;
} cmpCmdSpContRegisterActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_ACTIVATE_RSP Response_2_0
* @{ */
@@ -837,7 +837,7 @@ typedef struct {
cmpSpContUnregisterCmd_t cmd;
} cmpCmdSpContUnregister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNREGISTER_RSP Response_2_0
* @{ */
@@ -880,9 +880,9 @@ typedef struct {
mcSoRootCont_t soRootCont;
} cmpRspSpContUnregister_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER \
MC_CMP_2_0_CMD_SP_CONT_REGISTER
@@ -929,7 +929,7 @@ typedef struct {
cmpSpContRegisterCmd_t cmd;
} cmpCmdSpContRegister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_SP_CONT_REGISTER_RSP Response_2_0
* @{ */
@@ -975,9 +975,9 @@ typedef struct {
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
@@ -989,7 +989,7 @@ typedef struct {
/** SpContLockByRoot signed command. */
typedef struct {
/** Command header. */
- cmpCommandHeader_t cmdHeader;
+ cmpCommandHeader_t cmdHeader;
/** Spid. */
mcSpid_t spid;
} cmpSpLockByRootCmdSdata_t;
@@ -1010,7 +1010,7 @@ typedef struct {
mcSoSpCont_t soSpCont;
} cmpCmdSpContLockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_ROOT_RSP Response_2_0
* @{ */
@@ -1053,9 +1053,9 @@ typedef struct {
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
@@ -1067,7 +1067,7 @@ typedef struct {
/** SpContUnlockByRoot signed command. */
typedef struct {
/** Command header. */
- cmpCommandHeader_t cmdHeader;
+ cmpCommandHeader_t cmdHeader;
/** Spid. */
mcSpid_t spid;
} cmpSpUnlockByRootCmdSdata_t;
@@ -1088,7 +1088,7 @@ typedef struct {
mcSoSpCont_t soSpCont;
} cmpCmdSpContUnlockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_ROOT_RSP Response_2_0
* @{ */
@@ -1131,9 +1131,9 @@ typedef struct {
mcSoSpCont_t soSpCont;
} cmpRspSpContUnlockByRoot_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_SP_CONT_ACTIVATE \
MC_CMP_2_0_CMD_SP_CONT_ACTIVATE
@@ -1180,7 +1180,7 @@ typedef struct {
cmpSpContActivateCmd_t cmd;
} cmpCmdSpContActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_SP_CONT_ACTIVATE_RSP Response_2_0
* @{ */
@@ -1223,9 +1223,9 @@ typedef struct {
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
@@ -1237,7 +1237,7 @@ typedef struct {
/** SpContLockBySp signed command. */
typedef struct {
/** Command header. */
- cmpCommandHeader_t cmdHeader;
+ cmpCommandHeader_t cmdHeader;
/** Spid. */
mcSpid_t spid;
} cmpSpLockBySpCmdSdata_t;
@@ -1256,7 +1256,7 @@ typedef struct {
cmpSpContLockBySpCmd_t cmd;
} cmpCmdSpContLockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_SP_CONT_LOCK_BY_SP_RSP Response_2_0
* @{ */
@@ -1299,9 +1299,9 @@ typedef struct {
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
@@ -1313,7 +1313,7 @@ typedef struct {
/** SpContUnlockBySp signed command. */
typedef struct {
/** Command header. */
- cmpCommandHeader_t cmdHeader;
+ cmpCommandHeader_t cmdHeader;
/** Spid. */
mcSpid_t spid;
} cmpSpUnlockBySpCmdSdata_t;
@@ -1332,7 +1332,7 @@ typedef struct {
cmpSpContUnlockBySpCmd_t cmd;
} cmpCmdSpContUnlockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_SP_CONT_UNLOCK_BY_SP_RSP Response_2_0
* @{ */
@@ -1426,7 +1426,7 @@ typedef struct {
cmpTltContRegisterActivateCmd_t cmd;
} cmpCmdTltContRegisterActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_ACTIVATE_RSP Response_2_0
* @{ */
@@ -1508,7 +1508,7 @@ typedef struct {
cmpTltContUnregisterCmd_t cmd;
} cmpCmdTltContUnregister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNREGISTER_RSP Response_2_0
* @{ */
@@ -1551,9 +1551,9 @@ typedef struct {
mcSoSpCont_t soSpCont;
} cmpRspTltContUnregister_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER \
MC_CMP_2_0_CMD_TLT_CONT_REGISTER
@@ -1602,7 +1602,7 @@ typedef struct {
cmpTltContRegisterCmd_t cmd;
} cmpCmdTltContRegister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_REGISTER_RSP Response_2_0
* @{ */
@@ -1649,9 +1649,9 @@ typedef struct {
mcSoTltCont_2_0_t soTltCont;
} cmpRspTltContRegister_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_ACTIVATE \
MC_CMP_2_0_CMD_TLT_CONT_ACTIVATE
@@ -1686,7 +1686,7 @@ typedef struct {
mcSoTltCont_2_0_t soTltCont;
} cmpCmdTltContActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_ACTIVATE_RSP Response_2_0
* @{ */
@@ -1729,9 +1729,9 @@ typedef struct {
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
@@ -1766,7 +1766,7 @@ typedef struct {
mcSoTltCont_2_0_t soTltCont;
} cmpCmdTltContLockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_LOCK_BY_SP_RSP Response_2_0
* @{ */
@@ -1809,9 +1809,9 @@ typedef struct {
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
@@ -1846,7 +1846,7 @@ typedef struct {
mcSoTltCont_2_0_t soTltCont;
} cmpCmdTltContUnlockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_UNLOCK_BY_SP_RSP Response_2_0
* @{ */
@@ -1891,7 +1891,7 @@ typedef struct {
/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_PERSONALIZE \
MC_CMP_2_0_CMD_TLT_CONT_PERSONALIZE
@@ -1946,7 +1946,7 @@ typedef struct {
mcSoTltCont_2_0_t soTltCont;
} cmpCmdTltContPersonalize_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_2_0_CMD_TLT_CONT_PERSONLIZE_RSP Response_2_0
* @{ */
diff --git a/mobicore/common/MobiCore/inc/TlCm/2.0/tlCmApi.h b/mobicore/common/MobiCore/inc/TlCm/2.0/tlCmApi.h
index 19483b6..d653145 100644
--- a/mobicore/common/MobiCore/inc/TlCm/2.0/tlCmApi.h
+++ b/mobicore/common/MobiCore/inc/TlCm/2.0/tlCmApi.h
@@ -10,7 +10,7 @@
* 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,
diff --git a/mobicore/common/MobiCore/inc/TlCm/3.0/cmp.h b/mobicore/common/MobiCore/inc/TlCm/3.0/cmp.h
index ef2ba56..8454131 100644
--- a/mobicore/common/MobiCore/inc/TlCm/3.0/cmp.h
+++ b/mobicore/common/MobiCore/inc/TlCm/3.0/cmp.h
@@ -15,7 +15,7 @@
* 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,
@@ -50,7 +50,7 @@ typedef struct {
/** Address of the mapped memory. */
void* addr;
/** Size of the mapped memory. */
- uint32_t len;
+ uint32_t len;
} cmpMapInfo_t;
/** Info of the mapped element from a CMP message with NWd. */
@@ -58,7 +58,7 @@ typedef struct {
/** Offset of the mapped element in the mapped memory. */
uint32_t offset;
/** Size of the mapped element. */
- uint32_t len;
+ uint32_t len;
} cmpMapOffsetInfo_t;
/** TCI CMP command header. */
@@ -81,7 +81,7 @@ typedef struct {
cmpResponseId_t responseId;
/** Required lenght (return 0 if lenght is enough) of the mapped memory
* with NWd. */
- uint32_t len;
+ uint32_t len;
} cmpResponseHeaderTci_t;
/** @defgroup MC_CMP_CMD_GET_VERSION_TCI \
@@ -145,7 +145,7 @@ typedef struct {
/** @} */
/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI \
- MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI
+ MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI
* @{ */
/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_TCI_CMD Command
@@ -191,7 +191,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpAuthTokenContMapOffsetInfo;
} cmpCmdBeginSocAuthenticationTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION_TCI_RSP Response
* @{ */
@@ -204,9 +204,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
} cmpRspBeginSocAuthenticationTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_TCI \
MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_TCI
@@ -223,7 +223,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
} cmpCmdBeginRootAuthenticationTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_TCI_RSP Response
* @{ */
@@ -236,7 +236,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
} cmpRspBeginRootAuthenticationTci_t;
-/** @} */
+/** @} */
/** @} */
@@ -257,7 +257,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
} cmpCmdBeginSpAuthenticationTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION_TCI_RSP Response
* @{ */
@@ -270,9 +270,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
} cmpRspBeginSpAuthenticationTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_AUTHENTICATE_TCI \
MC_CMP_CMD_AUTHENTICATE_TCI
@@ -287,7 +287,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdAuthenticateTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_AUTHENTICATE_TCI_RSP Response
* @{ */
@@ -300,9 +300,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
} cmpRspAuthenticateTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_TCI \
MC_CMP_CMD_AUTHENTICATE_TERMINATE_TCI
@@ -317,7 +317,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdAuthenticateTerminateTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_TCI_RSP Response
* @{ */
@@ -330,9 +330,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
} cmpRspAuthenticateTerminateTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_TCI \
MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_TCI
@@ -347,7 +347,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdRootContRegisterActivateTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_TCI_RSP Response
* @{ */
@@ -379,7 +379,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdRootContUnregisterTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_TCI_RSP Response
* @{ */
@@ -392,9 +392,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpRspMapOffsetInfo;
} cmpRspRootContUnregisterTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_TCI \
MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_TCI
@@ -409,7 +409,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdRootContLockByRootTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_TCI_RSP Response
* @{ */
@@ -424,9 +424,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
} cmpRspRootContLockByRootTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_TCI \
MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_TCI
@@ -441,7 +441,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdRootContUnlockByRootTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_TCI_RSP Response
* @{ */
@@ -456,9 +456,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
} cmpRspRootContUnlockByRootTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_TCI \
MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_TCI
@@ -473,7 +473,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdSpContRegisterActivateTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_TCI_RSP Response
* @{ */
@@ -490,9 +490,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
} cmpRspSpContRegisterActivateTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_TCI \
MC_CMP_CMD_SP_CONT_UNREGISTER_TCI
@@ -507,7 +507,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdSpContUnregisterTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_TCI_RSP Response
* @{ */
@@ -522,7 +522,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpRootContMapOffsetInfo;
} cmpRspSpContUnregisterTci_t;
-/** @} */
+/** @} */
/** @} */
@@ -539,7 +539,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdSpContRegisterTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_TCI_RSP Response
* @{ */
@@ -556,9 +556,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
} cmpRspSpContRegisterTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_TCI \
MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_TCI
@@ -575,7 +575,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
} cmpCmdSpContLockByRootTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_TCI_RSP Response
* @{ */
@@ -590,9 +590,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
} cmpRspSpContLockByRootTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_TCI \
MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_TCI
@@ -609,7 +609,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
} cmpCmdSpContUnlockByRootTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_TCI_RSP Response
* @{ */
@@ -624,9 +624,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
} cmpRspSpContUnlockByRootTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_TCI \
MC_CMP_CMD_SP_CONT_ACTIVATE_TCI
@@ -641,7 +641,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdSpContActivateTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_TCI_RSP Response
* @{ */
@@ -656,9 +656,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
} cmpRspSpContActivateTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_TCI \
MC_CMP_CMD_SP_CONT_LOCK_BY_SP_TCI
@@ -673,7 +673,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdSpContLockBySpTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_TCI_RSP Response
* @{ */
@@ -688,9 +688,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
} cmpRspSpContLockBySpTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_TCI \
MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_TCI
@@ -705,7 +705,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdSpContUnlockBySpTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_TCI_RSP Response
* @{ */
@@ -720,9 +720,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpSpContMapOffsetInfo;
} cmpRspSpContUnlockBySpTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_TCI \
MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_TCI
@@ -737,7 +737,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdTltContRegisterActivateTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_TCI_RSP Response
* @{ */
@@ -756,7 +756,7 @@ typedef struct {
/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_TCI \
MC_CMP_CMD_TLT_CONT_UNREGISTER_TCI
@@ -771,7 +771,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdTltContUnregisterTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_TCI_RSP Response
* @{ */
@@ -803,7 +803,7 @@ typedef struct {
cmpCommandHeaderTci_t cmdHeader;
} cmpCmdTltContRegisterTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_TCI_RSP Response
* @{ */
@@ -820,7 +820,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
} cmpRspTltContRegisterTci_t;
-/** @} */
+/** @} */
/** @} */
@@ -839,7 +839,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
} cmpCmdTltContActivateTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_TCI_RSP Response
* @{ */
@@ -854,9 +854,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
} cmpRspTltContActivateTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_TCI \
MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_TCI
@@ -873,7 +873,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
} cmpCmdTltContLockBySpTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_TCI_RSP Response
* @{ */
@@ -888,9 +888,9 @@ typedef struct {
cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
} cmpRspTltContLockBySpTci_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_TCI \
MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_TCI
@@ -907,7 +907,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
} cmpCmdTltContUnlockBySpTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_TCI_RSP Response
* @{ */
@@ -941,7 +941,7 @@ typedef struct {
cmpMapOffsetInfo_t cmpTltContMapOffsetInfo;
} cmpCmdTltContPersonalizeTci_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_TCI_RSP Response
* @{ */
diff --git a/mobicore/common/MobiCore/inc/TlCm/3.0/cmpMap.h b/mobicore/common/MobiCore/inc/TlCm/3.0/cmpMap.h
index 0727407..05c3e7c 100644
--- a/mobicore/common/MobiCore/inc/TlCm/3.0/cmpMap.h
+++ b/mobicore/common/MobiCore/inc/TlCm/3.0/cmpMap.h
@@ -15,7 +15,7 @@
* 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,
@@ -192,7 +192,7 @@ typedef struct {
cmpBeginRootAuthenticationCmd_t cmd;
} cmpCmdBeginRootAuthentication_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION_RSP Response
* @{ */
@@ -221,7 +221,7 @@ typedef struct {
cmpBeginRootAuthenticationRsp_t rsp;
} cmpRspBeginRootAuthentication_t;
-/** @} */
+/** @} */
/** Map CMP BeginRootAuthentication message. */
typedef union {
@@ -231,7 +231,7 @@ typedef union {
cmpRspBeginRootAuthentication_t cmpRspBeginRootAuthentication;
} cmpMapBeginRootAuthentication_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_BEGIN_SP_AUTHENTICATION \
MC_CMP_CMD_BEGIN_SP_AUTHENTICATION
@@ -285,7 +285,7 @@ typedef struct {
cmpBeginSpAuthenticationRsp_t rsp;
} cmpRspBeginSpAuthentication_t;
-/** @} */
+/** @} */
/** Map CMP BeginSpAuthentication message. */
typedef union {
@@ -295,7 +295,7 @@ typedef union {
cmpRspBeginSpAuthentication_t cmpRspBeginSpAuthentication;
} cmpMapBeginSpAuthentication_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_AUTHENTICATE MC_CMP_CMD_AUTHENTICATE
* @{ */
@@ -333,7 +333,7 @@ typedef struct {
uint32_t edLen;
/** Encrypted and padded data. */
cmpAuthCmdEd_t ed;
-} cmpAuthCmdSdata_t;
+} cmpAuthCmdSdata_t;
/** Authenticate signed command and signature. */
typedef struct {
@@ -349,7 +349,7 @@ typedef struct {
cmpAuthenticateCmd_t cmd;
} cmpCmdAuthenticate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_AUTHENTICATE_RSP Response
* @{ */
@@ -410,7 +410,7 @@ typedef union {
cmpRspAuthenticate_t cmpRspAuthenticate;
} cmpMapAuthenticate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE \
MC_CMP_CMD_AUTHENTICATE_TERMINATE
@@ -439,7 +439,7 @@ typedef struct {
cmpAuthenticateTerminateCmd_t cmd;
} cmpCmdAuthenticateTerminate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_AUTHENTICATE_TERMINATE_RSP Response
* @{ */
@@ -474,7 +474,7 @@ typedef union {
cmpRspAuthenticateTerminate_t cmpRspAuthenticateTerminate;
} cmpMapAuthenticateTerminate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE \
MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE
@@ -523,7 +523,7 @@ typedef struct {
cmpRootContRegisterActivateCmd_t cmd;
} cmpCmdRootContRegisterActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE_RSP Response
* @{ */
@@ -609,7 +609,7 @@ typedef struct {
cmpRootContUnregisterCmd_t cmd;
} cmpCmdRootContUnregister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_UNREGISTER_RSP Response
* @{ */
@@ -652,7 +652,7 @@ typedef struct {
cmpRootContUnregisterRsp_t rsp;
} cmpRspRootContUnregister_t;
-/** @} */
+/** @} */
/** Map CMP RootContUnregister message. */
typedef union {
@@ -662,7 +662,7 @@ typedef union {
cmpRspRootContUnregister_t cmpRspRootContUnregister;
} cmpMapRootContUnregister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT \
MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT
@@ -691,7 +691,7 @@ typedef struct {
cmpRootContLockByRootCmd_t cmd;
} cmpCmdRootContLockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT_RSP Response
* @{ */
@@ -719,7 +719,7 @@ typedef struct {
cmpRootContLockByRootRsp_t rsp;
} cmpRspRootContLockByRoot_t;
-/** @} */
+/** @} */
/** Map CMP RootContLockByRoot message. */
typedef union {
@@ -729,7 +729,7 @@ typedef union {
cmpRspRootContLockByRoot_t cmpRspRootContLockByRoot;
} cmpMapRootContLockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT \
MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT
@@ -758,7 +758,7 @@ typedef struct {
cmpRootContUnlockByRootCmd_t cmd;
} cmpCmdRootContUnlockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT_RSP Response
* @{ */
@@ -787,7 +787,7 @@ typedef struct {
cmpRootContUnlockByRootRsp_t rsp;
} cmpRspRootContUnlockByRoot_t;
-/** @} */
+/** @} */
/** Map CMP RootContUnlockByRoot message. */
typedef union {
@@ -797,7 +797,7 @@ typedef union {
cmpRspRootContUnlockByRoot_t cmpRspRootContUnlockByRoot;
} cmpMapRootContUnlockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE \
MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE
@@ -846,7 +846,7 @@ typedef struct {
cmpSpContRegisterActivateCmd_t cmd;
} cmpCmdSpContRegisterActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE_RSP Response
* @{ */
@@ -879,7 +879,7 @@ typedef struct {
cmpSpContRegisterActivateRsp_t rsp;
} cmpRspSpContRegisterActivate_t;
-/** @} */
+/** @} */
/** Map CMP SpContRegisterActivate message. */
typedef union {
@@ -889,7 +889,7 @@ typedef union {
cmpRspSpContRegisterActivate_t cmpRspSpContRegisterActivate;
} cmpMapSpContRegisterActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER \
MC_CMP_CMD_SP_CONT_UNREGISTER
@@ -920,7 +920,7 @@ typedef struct {
cmpSpContUnregisterCmd_t cmd;
} cmpCmdSpContUnregister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNREGISTER_RSP Response
* @{ */
@@ -949,7 +949,7 @@ typedef struct {
cmpSpContUnregisterRsp_t rsp;
} cmpRspSpContUnregister_t;
-/** @} */
+/** @} */
/** Map CMP SpContUnregister message. */
typedef union {
@@ -959,7 +959,7 @@ typedef union {
cmpRspSpContUnregister_t cmpRspSpContUnregister;
} cmpMapSpContUnregister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER \
MC_CMP_CMD_SP_CONT_REGISTER
@@ -1008,7 +1008,7 @@ typedef struct {
cmpSpContRegisterCmd_t cmd;
} cmpCmdSpContRegister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_REGISTER_RSP Response
* @{ */
@@ -1041,7 +1041,7 @@ typedef struct {
cmpSpContRegisterRsp_t rsp;
} cmpRspSpContRegister_t;
-/** @} */
+/** @} */
/** Map CMP SpContRegister message. */
typedef union {
@@ -1051,7 +1051,7 @@ typedef union {
cmpRspSpContRegister_t cmpRspSpContRegister;
} cmpMapSpContRegister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT \
MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT
@@ -1063,7 +1063,7 @@ typedef union {
/** SpContLockByRoot signed command. */
typedef struct {
/** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
+ cmpCommandHeaderMap_t cmdHeader;
/** Spid. */
mcSpid_t spid;
} cmpSpLockByRootCmdSdata_t;
@@ -1082,7 +1082,7 @@ typedef struct {
cmpSpContLockByRootCmd_t cmd;
} cmpCmdSpContLockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT_RSP Response
* @{ */
@@ -1111,7 +1111,7 @@ typedef struct {
cmpSpContLockByRootRsp_t rsp;
} cmpRspSpContLockByRoot_t;
-/** @} */
+/** @} */
/** Map CMP SpContLockByRoot message. */
typedef union {
@@ -1121,7 +1121,7 @@ typedef union {
cmpRspSpContLockByRoot_t cmpRspSpContLockByRoot;
} cmpMapSpContLockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT \
MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT
@@ -1133,7 +1133,7 @@ typedef union {
/** SpContUnlockByRoot signed command. */
typedef struct {
/** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
+ cmpCommandHeaderMap_t cmdHeader;
/** Spid. */
mcSpid_t spid;
} cmpSpUnlockByRootCmdSdata_t;
@@ -1152,7 +1152,7 @@ typedef struct {
cmpSpContUnlockByRootCmd_t cmd;
} cmpCmdSpContUnlockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT_RSP Response
* @{ */
@@ -1181,7 +1181,7 @@ typedef struct {
cmpSpContUnlockByRootRsp_t rsp;
} cmpRspSpContUnlockByRoot_t;
-/** @} */
+/** @} */
/** Map CMP SpContUnlockByRoot message. */
typedef union {
@@ -1191,7 +1191,7 @@ typedef union {
cmpRspSpContUnlockByRoot_t cmpRspSpContUnlockByRoot;
} cmpMapSpContUnlockByRoot_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE \
MC_CMP_CMD_SP_CONT_ACTIVATE
@@ -1240,7 +1240,7 @@ typedef struct {
cmpSpContActivateCmd_t cmd;
} cmpCmdSpContActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_ACTIVATE_RSP Response
* @{ */
@@ -1269,7 +1269,7 @@ typedef struct {
cmpSpContActivateRsp_t rsp;
} cmpRspSpContActivate_t;
-/** @} */
+/** @} */
/** Map CMP SpContActivate message. */
typedef union {
@@ -1279,7 +1279,7 @@ typedef union {
cmpRspSpContActivate_t cmpRspSpContActivate;
} cmpMapSpContActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP \
MC_CMP_CMD_SP_CONT_LOCK_BY_SP
@@ -1291,7 +1291,7 @@ typedef union {
/** SpContLockBySp signed command. */
typedef struct {
/** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
+ cmpCommandHeaderMap_t cmdHeader;
/** Spid. */
mcSpid_t spid;
} cmpSpLockBySpCmdSdata_t;
@@ -1310,7 +1310,7 @@ typedef struct {
cmpSpContLockBySpCmd_t cmd;
} cmpCmdSpContLockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_LOCK_BY_SP_RSP Response
* @{ */
@@ -1339,7 +1339,7 @@ typedef struct {
cmpSpContLockBySpRsp_t rsp;
} cmpRspSpContLockBySp_t;
-/** @} */
+/** @} */
/** Map CMP SpContLockBySp message. */
typedef union {
@@ -1349,7 +1349,7 @@ typedef union {
cmpRspSpContLockBySp_t cmpRspSpContLockBySp;
} cmpMapSpContLockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP \
MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP
@@ -1361,7 +1361,7 @@ typedef union {
/** SpContUnlockBySp signed command. */
typedef struct {
/** Command header. */
- cmpCommandHeaderMap_t cmdHeader;
+ cmpCommandHeaderMap_t cmdHeader;
/** Spid. */
mcSpid_t spid;
} cmpSpUnlockBySpCmdSdata_t;
@@ -1380,7 +1380,7 @@ typedef struct {
cmpSpContUnlockBySpCmd_t cmd;
} cmpCmdSpContUnlockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP_RSP Response
* @{ */
@@ -1409,7 +1409,7 @@ typedef struct {
cmpSpContUnlockBySpRsp_t rsp;
} cmpRspSpContUnlockBySp_t;
-/** @} */
+/** @} */
/** Map CMP SpContUnlockBySp message. */
typedef union {
@@ -1419,7 +1419,7 @@ typedef union {
cmpRspSpContUnlockBySp_t cmpRspSpContUnlockBySp;
} cmpMapSpContUnlockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE \
MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE
@@ -1451,7 +1451,7 @@ typedef struct {
/** Uuid. */
mcUuid_t uuid;
/** Trustlet public key hash. */
- mcSha256_t skSpTltEnc;
+ mcSha256_t skSpTltEnc;
/** Minimum trustlet version supported. */
mcContVersion_t tltVersion;
/** Encrypted and padded data size. */
@@ -1474,7 +1474,7 @@ typedef struct {
cmpTltContRegisterActivateCmd_t cmd;
} cmpCmdTltContRegisterActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE_RSP Response
* @{ */
@@ -1505,7 +1505,7 @@ typedef struct {
cmpTltContRegisterActivateRsp_t rsp;
} cmpRspTltContRegisterActivate_t;
-/** @} */
+/** @} */
/** Map CMP TltContRegisterActivate message. */
typedef union {
@@ -1548,7 +1548,7 @@ typedef struct {
cmpTltContUnregisterCmd_t cmd;
} cmpCmdTltContUnregister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_UNREGISTER_RSP Response
* @{ */
@@ -1577,7 +1577,7 @@ typedef struct {
cmpTltContUnregisterRsp_t rsp;
} cmpRspTltContUnregister_t;
-/** @} */
+/** @} */
/** Map CMP TltContUnregister message. */
typedef union {
@@ -1619,7 +1619,7 @@ typedef struct {
/** Uuid. */
mcUuid_t uuid;
/** Trustlet public key hash. */
- mcSha256_t skSpTltEnc;
+ mcSha256_t skSpTltEnc;
/** Minimum trustlet version supported. */
mcContVersion_t tltVersion;
/** Encrypted and padded data size. */
@@ -1642,7 +1642,7 @@ typedef struct {
cmpTltContRegisterCmd_t cmd;
} cmpCmdTltContRegister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_REGISTER_RSP Response
* @{ */
@@ -1675,7 +1675,7 @@ typedef struct {
cmpTltContRegisterRsp_t rsp;
} cmpRspTltContRegister_t;
-/** @} */
+/** @} */
/** Map CMP TltContRegister message. */
typedef union {
@@ -1685,7 +1685,7 @@ typedef union {
cmpRspTltContRegister_t cmpRspTltContRegister;
} cmpMapTltContRegister_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE \
MC_CMP_CMD_TLT_CONT_ACTIVATE
@@ -1718,7 +1718,7 @@ typedef struct {
cmpTltContActivateCmd_t cmd;
} cmpCmdTltContActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_ACTIVATE_RSP Response
* @{ */
@@ -1747,7 +1747,7 @@ typedef struct {
cmpTltContActivateRsp_t rsp;
} cmpRspTltContActivate_t;
-/** @} */
+/** @} */
/** Map CMP TltContActivate message. */
typedef union {
@@ -1757,7 +1757,7 @@ typedef union {
cmpRspTltContActivate_t cmpRspTltContActivate;
} cmpMapTltContActivate_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP \
MC_CMP_CMD_TLT_CONT_LOCK_BY_SP
@@ -1790,7 +1790,7 @@ typedef struct {
cmpTltContLockBySpCmd_t cmd;
} cmpCmdTltContLockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_LOCK_BY_SP_RSP Response
* @{ */
@@ -1819,7 +1819,7 @@ typedef struct {
cmpTltContLockBySpRsp_t rsp;
} cmpRspTltContLockBySp_t;
-/** @} */
+/** @} */
/** Map CMP TltContLockBySp message. */
typedef union {
@@ -1829,7 +1829,7 @@ typedef union {
cmpRspTltContLockBySp_t cmpRspTltContLockBySp;
} cmpMapTltContLockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP \
MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP
@@ -1862,7 +1862,7 @@ typedef struct {
cmpTltContUnlockBySpCmd_t cmd;
} cmpCmdTltContUnlockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP_RSP Response
* @{ */
@@ -1901,7 +1901,7 @@ typedef union {
cmpRspTltContUnlockBySp_t cmpRspTltContUnlockBySp;
} cmpMapTltContUnlockBySp_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE \
MC_CMP_CMD_TLT_CONT_PERSONALIZE
@@ -1953,7 +1953,7 @@ typedef struct {
cmpTltContPersonalizeCmd_t cmd;
} cmpCmdTltContPersonalize_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_TLT_CONT_PERSONALIZE_RSP Response
* @{ */
diff --git a/mobicore/common/MobiCore/inc/TlCm/3.0/tlCmApi.h b/mobicore/common/MobiCore/inc/TlCm/3.0/tlCmApi.h
index 9325e1c..c66ab5a 100644
--- a/mobicore/common/MobiCore/inc/TlCm/3.0/tlCmApi.h
+++ b/mobicore/common/MobiCore/inc/TlCm/3.0/tlCmApi.h
@@ -10,7 +10,7 @@
* 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,
@@ -150,7 +150,7 @@ typedef union {
/** Sp administrative command TltContActivate. */
cmpRspTltContActivateTci_t cmpRspTltContActivateTci;
/** Sp administrative command TltContLockBySp. */
- cmpCmdTltContLockBySpTci_t cmpCmdTltContLockBySpTci;
+ cmpCmdTltContLockBySpTci_t cmpCmdTltContLockBySpTci;
/** Sp administrative response TltContLockBySp. */
cmpRspTltContLockBySpTci_t cmpRspTltContLockBySpTci;
/** Sp administrative command TltContUnlockBySp. */
diff --git a/mobicore/common/MobiCore/inc/TlCm/cmpCommon.h b/mobicore/common/MobiCore/inc/TlCm/cmpCommon.h
index 006a1c2..7c460ea 100644
--- a/mobicore/common/MobiCore/inc/TlCm/cmpCommon.h
+++ b/mobicore/common/MobiCore/inc/TlCm/cmpCommon.h
@@ -12,7 +12,7 @@
* 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,
@@ -69,7 +69,7 @@ typedef uint32_t cmpReturnCode_t;
/** CMP command header. */
typedef struct {
/** Command id. */
- cmpCommandId_t commandId;
+ cmpCommandId_t commandId;
} cmpCommandHeader_t;
/** CMP response header. */
@@ -141,7 +141,7 @@ typedef struct {
cmpCommandHeader_t cmdHeader;
} cmpCmdGetVersion_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_GET_VERSION_RSP Response
* @{ */
@@ -158,7 +158,7 @@ typedef struct {
/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_GET_SUID MC_CMP_CMD_GET_SUID
* @{ */
@@ -172,7 +172,7 @@ typedef struct {
cmpCommandHeader_t cmdHeader;
} cmpCmdGetSuid_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_GET_SUID_RSP Response
* @{ */
@@ -187,7 +187,7 @@ typedef struct {
/** @} */
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN MC_CMP_CMD_GENERATE_AUTH_TOKEN
* @{ */
@@ -229,7 +229,7 @@ typedef struct {
cmpGenAuthTokenCmd_t cmd;
} cmpCmdGenAuthToken_t;
-/** @} */
+/** @} */
/** @defgroup MC_CMP_CMD_GENERATE_AUTH_TOKEN_RSP Response
* @{ */
@@ -247,9 +247,9 @@ typedef struct {
mcSoAuthTokenCont_t soAuthCont;
} cmpRspGenAuthToken_t;
-/** @} */
+/** @} */
-/** @} */
+/** @} */
#endif // CMP_COMMON_H_
diff --git a/mobicore/common/MobiCore/inc/TlCm/tlCmApiCommon.h b/mobicore/common/MobiCore/inc/TlCm/tlCmApiCommon.h
index 1158c57..b526edd 100644
--- a/mobicore/common/MobiCore/inc/TlCm/tlCmApiCommon.h
+++ b/mobicore/common/MobiCore/inc/TlCm/tlCmApiCommon.h
@@ -9,7 +9,7 @@
* 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,
@@ -47,7 +47,7 @@ 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_BEGIN_SP_AUTHENTICATION = 3,
MC_CMP_CMD_GENERATE_AUTH_TOKEN = 4,
MC_CMP_CMD_GET_VERSION = 5,
//MC_CMP_CMD_ROOT_CONT_ACTIVATE = 6,
diff --git a/mobicore/common/MobiCore/inc/TlCm/tlCmError.h b/mobicore/common/MobiCore/inc/TlCm/tlCmError.h
index 6d08dcb..90d9ba9 100644
--- a/mobicore/common/MobiCore/inc/TlCm/tlCmError.h
+++ b/mobicore/common/MobiCore/inc/TlCm/tlCmError.h
@@ -8,7 +8,7 @@
* 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,
diff --git a/mobicore/common/MobiCore/inc/TlCm/tlCmUuid.h b/mobicore/common/MobiCore/inc/TlCm/tlCmUuid.h
index dabb9c7..5ce25c1 100644
--- a/mobicore/common/MobiCore/inc/TlCm/tlCmUuid.h
+++ b/mobicore/common/MobiCore/inc/TlCm/tlCmUuid.h
@@ -6,7 +6,7 @@
* 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,
diff --git a/mobicore/common/MobiCore/inc/TlCm/version.h b/mobicore/common/MobiCore/inc/TlCm/version.h
index a51c19e..00f3841 100644
--- a/mobicore/common/MobiCore/inc/TlCm/version.h
+++ b/mobicore/common/MobiCore/inc/TlCm/version.h
@@ -6,7 +6,7 @@
* 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,
diff --git a/mobicore/common/MobiCore/inc/mcContainer.h b/mobicore/common/MobiCore/inc/mcContainer.h
index c94e807..da741b0 100644
--- a/mobicore/common/MobiCore/inc/mcContainer.h
+++ b/mobicore/common/MobiCore/inc/mcContainer.h
@@ -1,15 +1,32 @@
-/** @addtogroup MC_CONTAINER mcContainer - Containers for MobiCore Content Management.
- * @ingroup MC_DATA_TYPES
- * @{
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
+ * All rights reserved.
*
- * 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:
*
- * 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.
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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_
@@ -90,15 +107,15 @@ typedef enum {
/** SOC container. */
CONT_TYPE_SOC = 0,
/** Root container. */
- CONT_TYPE_ROOT,
+ CONT_TYPE_ROOT = 1,
/** Service provider container. */
- CONT_TYPE_SP,
+ CONT_TYPE_SP = 2,
/** Trustlet container. */
- CONT_TYPE_TLCON,
+ CONT_TYPE_TLCON = 3,
/** Service provider data. */
- CONT_TYPE_SPDATA,
+ CONT_TYPE_SPDATA = 4,
/** Trustlet data. */
- CONT_TYPE_TLDATA
+ CONT_TYPE_TLDATA = 5
} contType_t;
/** SHA256 checksum. */
@@ -108,7 +125,7 @@ typedef struct {
/** @defgroup MC_CONTAINER_CRYPTO_OBJECTS Container secrets.
* Data that is stored encrypted within the container.
- * @{ */
+ */
/** SoC secret */
typedef struct {
@@ -141,11 +158,9 @@ typedef union {
mcUuid_t uuid;
} mcCid_t;
-/** @} */
-
/** @defgroup MC_CONTAINER_CONTAINER_OBJECTS Container definitions.
* Container type definitions.
- * @{ */
+ */
/** SoC Container */
typedef struct {
@@ -213,8 +228,6 @@ typedef struct {
mcCoDataCont_t co;
} mcDataCont_t;
-/** @} */
-
/** Helper for finding maximum value */
#define MC_MAX(x, y) (((x)<(y))?(y):(x))
@@ -234,7 +247,7 @@ typedef struct {
/** @defgroup MC_CONTAINER_SECURE_OBJECTS Containers in secure objects.
* Secure objects wrapping different containers.
- * @{ */
+ */
/** Authentication token */
typedef struct {
@@ -300,8 +313,5 @@ typedef struct {
#define MC_TLBLOBLEN_MAGIC 0x7672746C
-/** @} */
-
#endif // MC_CONTAINER_H_
-/** @} */
diff --git a/mobicore/common/MobiCore/inc/mcDriverId.h b/mobicore/common/MobiCore/inc/mcDriverId.h
index df9aa88..de4535c 100644
--- a/mobicore/common/MobiCore/inc/mcDriverId.h
+++ b/mobicore/common/MobiCore/inc/mcDriverId.h
@@ -1,15 +1,32 @@
-/**
- * @file
- * Driver ID definition.
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
+ * All rights reserved.
*
- * 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:
*
- * 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.
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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_
diff --git a/mobicore/common/MobiCore/inc/mcLoadFormat.h b/mobicore/common/MobiCore/inc/mcLoadFormat.h
index 028dbb5..85ac4f2 100644
--- a/mobicore/common/MobiCore/inc/mcLoadFormat.h
+++ b/mobicore/common/MobiCore/inc/mcLoadFormat.h
@@ -1,24 +1,32 @@
-/**
- * @defgroup MCLF MobiCore Load Format
- *
- * @defgroup MCLF_VER MCLF Versions
- * @ingroup MCLF
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
+ * All rights reserved.
*
- * @addtogroup MCLF
- * @{
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
*
- * MobiCore Load Format declarations.
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
*
- * Holds the definitions for the layout of MobiCore Trustlet Blob.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
- * 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.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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_
@@ -36,16 +44,9 @@
#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.
@@ -55,7 +56,6 @@ typedef enum {
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;
/**
@@ -71,7 +71,7 @@ typedef enum {
* Descriptor for a memory segment.
*/
typedef struct {
- addr_t start; /**< Virtual start address. */
+ uint32_t start; /**< Virtual start address. */
uint32_t len; /**< Length of the segment in bytes. */
} segmentDescriptor_t, *segmentDescriptor_ptr;
@@ -84,8 +84,6 @@ typedef struct {
uint32_t version; /**< Version of the MCLF header structure. */
} mclfIntro_t, *mclfIntro_ptr;
-/** @} */
-
// Version 2 /////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
@@ -93,7 +91,6 @@ typedef struct {
* @ingroup MCLF_VER
*
* @addtogroup MCLF_VER_V2
- * @{
*/
/**
@@ -120,7 +117,7 @@ typedef struct {
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 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:
@@ -128,7 +125,6 @@ typedef struct {
// uint32_t permittedHwCf; /**< Starting 2.3: If nonzero, hw configuration which is allowed to execute binary */
} mclfHeaderV2_t, *mclfHeaderV2_ptr;
-/** @} */
/**
@@ -139,7 +135,6 @@ typedef struct {
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;
-/** @} */
/**
@@ -151,7 +146,6 @@ typedef struct {
uint32_t attestationOffset; /**<Starting 2.4: Offset of attestation data area. */
} mclfHeaderV24_t, *mclfHeaderV24_ptr;
-/** @} */
@@ -164,16 +158,16 @@ typedef struct {
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.
+ uint32_t requiredFeat; /**< Flags to indicate features that Mobicore must understand/interpret when loading.
Initial value set at compile time.
Required always. */
- addr_t mcLibEntry; /**< Address for McLib entry.
+ uint32_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.
+ uint32_t mcLibBase; /**< McLib base address.
Mobicore sets at load time for trustlets / drivers.
Required always. */
uint32_t tlApiVers; /**< TlApi version used when building trustlet.
@@ -182,13 +176,12 @@ typedef struct {
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. */
+ uint32_t ta_properties; /**< address of _TA_Properties in the TA. */
} mclfTextHeader_t, *mclfTextHeader_ptr;
// Version 2 ///////////////////////////////////////////////////////////////////////////////////////////////////
/**
* @addtogroup MCLF
- * @{
*/
/** MCLF header */
@@ -210,4 +203,3 @@ typedef union {
#endif /* MCLOADFORMAT_H_ */
-/** @} */
diff --git a/mobicore/common/MobiCore/inc/mcRootid.h b/mobicore/common/MobiCore/inc/mcRootid.h
index b60bb56..57e12bc 100644
--- a/mobicore/common/MobiCore/inc/mcRootid.h
+++ b/mobicore/common/MobiCore/inc/mcRootid.h
@@ -1,19 +1,32 @@
-/**
- * @addtogroup MC_ROOTID mcRootid - Root container id.
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
+ * All rights reserved.
*
- * Global definition of root ID.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
*
- * Copyright (c) 2013 TRUSTONIC LIMITED
- * All rights reserved
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
*
- * 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.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * @ingroup MC_DATA_TYPES
- * @{
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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_
@@ -33,4 +46,3 @@ static const mcRootid_t MC_ROOTID_SYSTEM = 0xFFFFFFFE;
#endif // MC_ROOTID_H_
-/** @} */
diff --git a/mobicore/common/MobiCore/inc/mcSo.h b/mobicore/common/MobiCore/inc/mcSo.h
index 848d6d4..897f756 100644
--- a/mobicore/common/MobiCore/inc/mcSo.h
+++ b/mobicore/common/MobiCore/inc/mcSo.h
@@ -1,20 +1,32 @@
-/**
- * @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
- * @{
- *
+/*
+ * 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 MC_SO_H_
@@ -231,4 +243,3 @@ typedef struct {
#endif // MC_SO_H_
-/** @} */
diff --git a/mobicore/common/MobiCore/inc/mcSpid.h b/mobicore/common/MobiCore/inc/mcSpid.h
index 2714d1e..b630d87 100644
--- a/mobicore/common/MobiCore/inc/mcSpid.h
+++ b/mobicore/common/MobiCore/inc/mcSpid.h
@@ -1,17 +1,32 @@
-/**
- * @addtogroup MC_SPID mcSpid - service provider ID.
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
+ * All rights reserved.
*
- * 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:
*
- * 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.
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
*
- * @ingroup MC_DATA_TYPES
- * @{
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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_
@@ -33,6 +48,8 @@ static const mcSpid_t MC_SPID_SYSTEM = 0xFFFFFFFE;
static const mcSpid_t MC_SPID_RESERVED_TEST = 0xFFFFFFFD;
static const mcSpid_t MC_SPID_TRUSTONIC_TEST = 0x4;
+/** SPID reserved for OTA development */
+static const mcSpid_t MC_SPID_TRUSTONIC_OTA = 0x2A;
+
#endif // MC_SPID_H_
-/** @} */
diff --git a/mobicore/common/MobiCore/inc/mcSuid.h b/mobicore/common/MobiCore/inc/mcSuid.h
index a80cfc5..8a6a55e 100644
--- a/mobicore/common/MobiCore/inc/mcSuid.h
+++ b/mobicore/common/MobiCore/inc/mcSuid.h
@@ -1,17 +1,32 @@
-/**
- * @addtogroup MC_SUID mcSuid - SoC unique ID.
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
+ * All rights reserved.
*
- * 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:
*
- * 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.
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
*
- * @ingroup MC_DATA_TYPES
- * @{
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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_
@@ -33,4 +48,3 @@ typedef struct {
#endif // MC_SUID_H_
-/** @} */
diff --git a/mobicore/common/MobiCore/inc/mcUuid.h b/mobicore/common/MobiCore/inc/mcUuid.h
index 16ebb85..918d7f8 100644
--- a/mobicore/common/MobiCore/inc/mcUuid.h
+++ b/mobicore/common/MobiCore/inc/mcUuid.h
@@ -1,17 +1,32 @@
-/**
- * @addtogroup MC_UUID mcUuid - Universally Unique Identifier.
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
+ * All rights reserved.
*
- * 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:
*
- * 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.
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
*
- * @ingroup MC_DATA_TYPES
- * @{
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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_
@@ -30,7 +45,7 @@ typedef struct {
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
-static const mcUuid_t MC_UUID_FREE = {
+static __attribute__((unused)) const mcUuid_t MC_UUID_FREE = {
MC_UUID_FREE_DEFINE
};
@@ -39,7 +54,7 @@ static const mcUuid_t MC_UUID_FREE = {
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
-static const mcUuid_t MC_UUID_RESERVED = {
+static __attribute__((unused)) const mcUuid_t MC_UUID_RESERVED = {
MC_UUID_RESERVED_DEFINE
};
@@ -48,10 +63,9 @@ static const mcUuid_t MC_UUID_RESERVED = {
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE }
-static const mcUuid_t MC_UUID_SYSTEM = {
+static __attribute__((unused)) const mcUuid_t MC_UUID_SYSTEM = {
MC_UUID_SYSTEM_DEFINE
};
#endif // MC_UUID_H_
-/** @} */
diff --git a/mobicore/common/MobiCore/inc/mcVersionHelper.h b/mobicore/common/MobiCore/inc/mcVersionHelper.h
index a5af69f..b4f9b5f 100644
--- a/mobicore/common/MobiCore/inc/mcVersionHelper.h
+++ b/mobicore/common/MobiCore/inc/mcVersionHelper.h
@@ -1,28 +1,42 @@
-/** @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.
+/*
+ * 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.
*/
-#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) \
+#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))
@@ -211,3 +225,6 @@
return 0; \
}
#endif
+
+#endif // MCVERSIONHELPER_H_
+
diff --git a/mobicore/common/MobiCore/inc/mcVersionInfo.h b/mobicore/common/MobiCore/inc/mcVersionInfo.h
index f93115a..26542ff 100644
--- a/mobicore/common/MobiCore/inc/mcVersionInfo.h
+++ b/mobicore/common/MobiCore/inc/mcVersionInfo.h
@@ -1,17 +1,33 @@
-/** @addtogroup MC_RTM
- * @{
- * MobiCore Version Information
+/*
+ * Copyright (c) 2013-2014 TRUSTONIC LIMITED
+ * All rights reserved.
*
- * 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:
*
- * 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.
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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_
diff --git a/mobicore/common/MobiCore/inc/version.md5 b/mobicore/common/MobiCore/inc/version.md5
new file mode 100644
index 0000000..3750066
--- /dev/null
+++ b/mobicore/common/MobiCore/inc/version.md5
@@ -0,0 +1 @@
+a548519579b1a7cddb06c56989fd01f8 *-
diff --git a/mobicore/daemon/CleanSpec.mk b/mobicore/daemon/CleanSpec.mk
deleted file mode 100644
index 7dd6f6c..0000000
--- a/mobicore/daemon/CleanSpec.mk
+++ /dev/null
@@ -1,61 +0,0 @@
-# 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
-# ************************************************
diff --git a/mobicore/daemon/ClientLib/public/GP/tee_error.h b/mobicore/daemon/ClientLib/public/GP/tee_error.h
deleted file mode 100644
index fbae687..0000000
--- a/mobicore/daemon/ClientLib/public/GP/tee_error.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/**
- * 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__ */
-
diff --git a/mobicore/daemon/ClientLib/public/GP/tee_internal_api_impl.h b/mobicore/daemon/ClientLib/public/GP/tee_internal_api_impl.h
deleted file mode 100644
index 9acd363..0000000
--- a/mobicore/daemon/ClientLib/public/GP/tee_internal_api_impl.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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__ */
diff --git a/mobicore/daemon/ClientLib/public/Windows/t-base_client_api.def b/mobicore/daemon/ClientLib/public/Windows/t-base_client_api.def
deleted file mode 100644
index 382a5b7..0000000
--- a/mobicore/daemon/ClientLib/public/Windows/t-base_client_api.def
+++ /dev/null
@@ -1,25 +0,0 @@
-; ------------------------------------------------------------------------
-; 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
-
diff --git a/mobicore/daemon/ClientLib/public/Windows/t-base_client_api.sln b/mobicore/daemon/ClientLib/public/Windows/t-base_client_api.sln
deleted file mode 100644
index df39313..0000000
--- a/mobicore/daemon/ClientLib/public/Windows/t-base_client_api.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-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
diff --git a/mobicore/daemon/ClientLib/public/Windows/t-base_client_api.vcxproj b/mobicore/daemon/ClientLib/public/Windows/t-base_client_api.vcxproj
deleted file mode 100644
index 41bfa15..0000000
--- a/mobicore/daemon/ClientLib/public/Windows/t-base_client_api.vcxproj
+++ /dev/null
@@ -1,109 +0,0 @@
-<?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
diff --git a/mobicore/daemon/Daemon/Device/public/ExcDevice.h b/mobicore/daemon/Daemon/Device/public/ExcDevice.h
deleted file mode 100644
index 733fbcd..0000000
--- a/mobicore/daemon/Daemon/Device/public/ExcDevice.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/** @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_ */
-
-/** @} */
diff --git a/mobicore/daemon/Daemon/FSD/public/dci.h b/mobicore/daemon/Daemon/FSD/public/dci.h
deleted file mode 100644
index c805f5c..0000000
--- a/mobicore/daemon/Daemon/FSD/public/dci.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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__
diff --git a/mobicore/daemon/Daemon/FSD/public/drSecureStorage_Api.h b/mobicore/daemon/Daemon/FSD/public/drSecureStorage_Api.h
deleted file mode 100644
index 6c881e3..0000000
--- a/mobicore/daemon/Daemon/FSD/public/drSecureStorage_Api.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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__
diff --git a/mobicore/daemon/MODULE_LICENSE_BSD b/mobicore/daemon/MODULE_LICENSE_BSD
deleted file mode 100644
index e69de29..0000000
--- a/mobicore/daemon/MODULE_LICENSE_BSD
+++ /dev/null
diff --git a/mobicore/daemon/NOTICE b/mobicore/daemon/NOTICE
deleted file mode 100644
index d742e22..0000000
--- a/mobicore/daemon/NOTICE
+++ /dev/null
@@ -1,25 +0,0 @@
- 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
diff --git a/mobicore/daemon/README.android b/mobicore/daemon/README.android
deleted file mode 100644
index 29edee1..0000000
--- a/mobicore/daemon/README.android
+++ /dev/null
@@ -1,64 +0,0 @@
-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
diff --git a/mobicore/daemon/buildTag.h b/mobicore/daemon/buildTag.h
deleted file mode 100644
index 928fb31..0000000
--- a/mobicore/daemon/buildTag.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * <-- 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 ###"
diff --git a/mobicore/include/Public/mc_linux.h b/mobicore/include/Public/mc_linux.h
index e794662..3da4ae3 100644
--- a/mobicore/include/Public/mc_linux.h
+++ b/mobicore/include/Public/mc_linux.h
@@ -1,4 +1,34 @@
/*
+ * 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.
+ */
+/*
* 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
@@ -7,33 +37,6 @@
* 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.
- *
- * <-- Copyright Giesecke & Devrient GmbH 2010-2012 -->
- * <-- Copyright Trustonic Limited 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 _MC_LINUX_H_
@@ -81,10 +84,10 @@ struct mc_ioctl_info {
* already. I.e. Daemon was restarted.
*/
struct mc_ioctl_map {
- size_t len; /* Buffer length */
+ uint32_t len; /* Buffer length */
uint32_t handle; /* WSM handle */
uint64_t phys_addr; /* physical address of WSM (or 0) */
- unsigned long addr; /* Virtual address */
+ uint32_t rfu;
bool reused; /* if WSM memory was reused, or new allocated */
};
@@ -95,8 +98,11 @@ struct mc_ioctl_map {
* 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_ioctl_reg_wsm {
+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 */
@@ -104,6 +110,14 @@ struct mc_ioctl_reg_wsm {
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.
*/
@@ -166,8 +180,14 @@ struct mc_ioctl_resolv_wsm {
* 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)
diff --git a/mobicore/include/Public/version.h b/mobicore/include/Public/version.h
index 591ca3d..9262a78 100644
--- a/mobicore/include/Public/version.h
+++ b/mobicore/include/Public/version.h
@@ -1,30 +1,32 @@
/*
- * <-- Copyright Giesecke & Devrient GmbH 2010-2012 -->
- * <-- Copyright Trustonic Limited 2013 -->
+ * 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.
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce 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.
+ * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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_
diff --git a/mobicore/provlib/Android.mk b/mobicore/provlib/Android.mk
deleted file mode 100644
index db3da67..0000000
--- a/mobicore/provlib/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# =============================================================================
-#
-# 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
diff --git a/mobicore/provlib/Application.mk b/mobicore/provlib/Application.mk
deleted file mode 100644
index fde1054..0000000
--- a/mobicore/provlib/Application.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-# =============================================================================
-#
-# 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
diff --git a/mobicore/provlib/buildTag.h b/mobicore/provlib/buildTag.h
deleted file mode 100644
index 928fb31..0000000
--- a/mobicore/provlib/buildTag.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * <-- 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 ###"
diff --git a/mobicore/provlib/inc_private/gdmcdevicebinding.h b/mobicore/provlib/inc_private/gdmcdevicebinding.h
deleted file mode 100644
index 3b979b8..0000000
--- a/mobicore/provlib/inc_private/gdmcdevicebinding.h
+++ /dev/null
@@ -1,101 +0,0 @@
-#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
diff --git a/mobicore/provlib/inc_private/gdmcinstance.h b/mobicore/provlib/inc_private/gdmcinstance.h
deleted file mode 100644
index 0369f62..0000000
--- a/mobicore/provlib/inc_private/gdmcinstance.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#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
diff --git a/mobicore/provlib/inc_private/gdmcprovprotocol.h b/mobicore/provlib/inc_private/gdmcprovprotocol.h
deleted file mode 100644
index bd2686d..0000000
--- a/mobicore/provlib/inc_private/gdmcprovprotocol.h
+++ /dev/null
@@ -1,127 +0,0 @@
-#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_
diff --git a/mobicore/provlib/inc_private/mobicore.h b/mobicore/provlib/inc_private/mobicore.h
deleted file mode 100644
index 1806f2b..0000000
--- a/mobicore/provlib/inc_private/mobicore.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/// @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_
-
diff --git a/mobicore/provlib/inc_public/gdmcprovlib.h b/mobicore/provlib/inc_public/gdmcprovlib.h
deleted file mode 100644
index 71196ca..0000000
--- a/mobicore/provlib/inc_public/gdmcprovlib.h
+++ /dev/null
@@ -1,424 +0,0 @@
-///
-/// @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_
-
diff --git a/mobicore/provlib/jni/Android.mk b/mobicore/provlib/jni/Android.mk
deleted file mode 100644
index d7ab59c..0000000
--- a/mobicore/provlib/jni/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libgdmcprov
-LOCAL_MODULE_TAGS := debug eng optional
-
-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)
diff --git a/mobicore/provlib/src/crc32.c b/mobicore/provlib/src/crc32.c
deleted file mode 100644
index 37ac0c6..0000000
--- a/mobicore/provlib/src/crc32.c
+++ /dev/null
@@ -1,49 +0,0 @@
-#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);
- }
-}
-
diff --git a/mobicore/provlib/src/gdmcdevicebinding.cpp b/mobicore/provlib/src/gdmcdevicebinding.cpp
deleted file mode 100644
index 353be75..0000000
--- a/mobicore/provlib/src/gdmcdevicebinding.cpp
+++ /dev/null
@@ -1,533 +0,0 @@
-///
-/// @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",(unsigned int)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, 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;
-}
diff --git a/mobicore/provlib/src/gdmcprovlib.cpp b/mobicore/provlib/src/gdmcprovlib.cpp
deleted file mode 100644
index 7deed36..0000000
--- a/mobicore/provlib/src/gdmcprovlib.cpp
+++ /dev/null
@@ -1,408 +0,0 @@
-///
-/// @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,
- gderror errorcode,
- char *msgbuf,
- _u32 *size )
-{
- 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)inst;
-
- return GDERROR_OK;
-}
-
-static gderror GDPROVAPI _GDMCProvEndProvisioning ( gdhandle provhandle )
-{
- gdmcinst *inst = (gdmcinst*)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*)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,
- _u32 receipt_size,
- _u8 *fmt_receipt,
- _u32 *fmt_receipt_size )
-{
- return GDERROR_NOT_IMPLEMENTED;
-}
-
-extern "C" gderror GDPROVAPI GDMCProvGetSUID (
- gdhandle provhandle,
- _u8 *suid )
-{
- 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 )
-{
-#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
diff --git a/mobicore/provlib/src/mobicore.c b/mobicore/provlib/src/mobicore.c
deleted file mode 100644
index 85ab5c4..0000000
--- a/mobicore/provlib/src/mobicore.c
+++ /dev/null
@@ -1,294 +0,0 @@
-#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;
-}
diff --git a/mobicore/rootpa/Code/Android/app/Android.mk b/mobicore/rootpa/Code/Android/app/Android.mk
index 90b9067..cac6938 100644
--- a/mobicore/rootpa/Code/Android/app/Android.mk
+++ b/mobicore/rootpa/Code/Android/app/Android.mk
@@ -15,6 +15,8 @@ LOCAL_CERTIFICATE := platform
LOCAL_PROGUARD_FLAGS := -include $(LOCAL_PATH)/proguard-project.txt
+LOCAL_32_BIT_ONLY := true
+
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
diff --git a/mobicore/rootpa/Code/Android/app/NOTICE b/mobicore/rootpa/Code/Android/app/NOTICE
new file mode 100644
index 0000000..627167a
--- /dev/null
+++ b/mobicore/rootpa/Code/Android/app/NOTICE
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
diff --git a/mobicore/rootpa/Code/Android/app/ant.properties b/mobicore/rootpa/Code/Android/app/ant.properties
index 452d2d4..3f42c1c 100644
--- a/mobicore/rootpa/Code/Android/app/ant.properties
+++ b/mobicore/rootpa/Code/Android/app/ant.properties
@@ -1,7 +1,2 @@
out.dir=out
-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
+java.compilerargs="-Xlint:unchecked" \ No newline at end of file
diff --git a/mobicore/rootpa/Code/Android/app/build.xml b/mobicore/rootpa/Code/Android/app/build.xml
index d58ed9d..c251281 100644
--- a/mobicore/rootpa/Code/Android/app/build.xml
+++ b/mobicore/rootpa/Code/Android/app/build.xml
@@ -28,11 +28,25 @@
-->
<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>
@@ -48,12 +62,50 @@
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:
diff --git a/mobicore/rootpa/Code/Android/app/jni/Android.mk b/mobicore/rootpa/Code/Android/app/jni/Android.mk
index c5b1b1b..dc9de57 100644
--- a/mobicore/rootpa/Code/Android/app/jni/Android.mk
+++ b/mobicore/rootpa/Code/Android/app/jni/Android.mk
@@ -39,6 +39,6 @@
# (including RootPA/Common) checked out in order to sucessfully
# complete te build
#
-
+LOCAL_32_BIT_ONLY := true
include $(call all-subdir-makefiles)
diff --git a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/Android.mk b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/Android.mk
index 1142b37..137e9e2 100644
--- a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/Android.mk
+++ b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/Android.mk
@@ -3,29 +3,29 @@
#
# 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.
#
@@ -45,7 +45,7 @@ LOCAL_CFLAGS += -DANDROID_ARM=1
LOCAL_CFLAGS +=-fstack-protector
ifeq ($(DEBUG), 1)
LOCAL_CFLAGS += -D__DEBUG=1
-endif
+endif
LOCAL_SRC_FILES += commonwrapper.cpp
LOCAL_SRC_FILES += JniHelpers.cpp
@@ -62,7 +62,7 @@ LOCAL_MODULE_TAGS := debug 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
@@ -80,4 +80,6 @@ LOCAL_SHARED_LIBRARIES += libcurl
LOCAL_STATIC_LIBRARIES += libxml2
LOCAL_SHARED_LIBRARIES += libicuuc
+LOCAL_32_BIT_ONLY := true
include $(BUILD_SHARED_LIBRARY)
+
diff --git a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/CmpBase.cpp b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/CmpBase.cpp
index 464f02e..4a0b3e3 100644
--- a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/CmpBase.cpp
+++ b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/CmpBase.cpp
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -39,9 +39,9 @@ Public methods
*/
CmpBase::CmpBase(JNIEnv* env, jobject msgs): env_(env),
- msgs_(msgs),
- cls_(NULL),
- broken_(false),
+ msgs_(msgs),
+ cls_(NULL),
+ broken_(false),
objectCls_(NULL),
numberOfElements_(0)
{
@@ -52,7 +52,7 @@ CmpBase::CmpBase(JNIEnv* env, jobject msgs): env_(env),
{
LOGE("can not get object class");
broken_=true;
- }
+ }
}
else
{
@@ -85,7 +85,7 @@ int CmpBase::numberOfElements()
jmethodID mid = env_->GetMethodID(cls_, "size", "()I");
if(mid !=0)
{
- numberOfElements_ = (int) env_->CallIntMethod(msgs_, mid);
+ numberOfElements_ = (int) env_->CallIntMethod(msgs_, mid);
}
else
{
@@ -94,3 +94,8 @@ int CmpBase::numberOfElements()
}
return numberOfElements_;
}
+
+
+
+
+
diff --git a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/CmpResponses.cpp b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/CmpResponses.cpp
index 285833d..4ab2557 100644
--- a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/CmpResponses.cpp
+++ b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/CmpResponses.cpp
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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 <stdlib.h>
@@ -43,7 +43,7 @@ CmpResponses::CmpResponses(JNIEnv* env, jobject responses): CmpBase(env, respons
}
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!");
}
}
}
@@ -56,16 +56,16 @@ CmpResponses::~CmpResponses()
int CmpResponses::update(CmpMessage* responses, int numberOfResponses)
{
- int ret=ROOTPA_OK;
+ int ret=ROOTPA_OK;
if(broken_) return ROOTPA_ERROR_INTERNAL;
- jmethodID mid=env_->GetMethodID(cls_, "add", "(Ljava/lang/Object;)Z");
+ jmethodID mid=env_->GetMethodID(cls_, "add", "(Ljava/lang/Object;)Z");
if(NULL==mid)
{
LOGE("do not find add(Ljava/lang/Object)Z from List");
return ROOTPA_ERROR_INTERNAL;
}
-
+
jobject responseObject=NULL;
bool result;
for(int i=0; i<numberOfResponses; i++)
@@ -76,15 +76,15 @@ int CmpResponses::update(CmpMessage* responses, int numberOfResponses)
if((result=(bool) env_->CallBooleanMethod(msgs_, mid, responseObject))==false)
{
ret=ROOTPA_ERROR_INTERNAL;
- LOGE("adding cmp response object %d failed", i);
+ LOGE("adding cmp response object %d failed", i);
}
env_->DeleteLocalRef(responseObject);
}
else
{
ret=ROOTPA_ERROR_INTERNAL;
- LOGE("creating cmp response object failed");
- }
+ LOGE("creating cmp response object failed");
+ }
}
return ret;
}
@@ -101,17 +101,17 @@ jobject CmpResponses::createCmpResponseObject(CmpMessage msg)
{
jmethodID constructor=NULL;
JniHelpers helper(env_);
- jbyteArray rsp = helper.byteArrayToJByteArray(msg.contentP, msg.length);
+ jbyteArray rsp = helper.byteArrayToJByteArray(msg.contentP, msg.length);
if(rsp != NULL)
{
- constructor = env_->GetMethodID(objectCls_, "<init>", "([B)V");
+ constructor = env_->GetMethodID(objectCls_, "<init>", "([B)V");
}
else
{
constructor = env_->GetMethodID(objectCls_, "<init>", "()V");
LOGE("CmpResponses::createCmpResponseObject no response received, using empty response object");
}
-
+
if(constructor != NULL)
{
@@ -132,21 +132,21 @@ jobject CmpResponses::createCmpResponseObject(CmpMessage msg)
}
else
{
- LOGE("CmpResponses::createCmpResponseObject creating constructor failed");
+ LOGE("CmpResponses::createCmpResponseObject creating constructor failed");
}
-
+
if(rsp != NULL)
{
env_->DeleteLocalRef(rsp);
}
-
+
}
else
{
LOGE("CmpResponses::createCmpResponseObject did not find java side class /com/gd/mobicore/pa/ifc/CmpResponse");
}
}
-
+
if(objectCls_!=NULL)
{
env_->DeleteLocalRef(objectCls_);
@@ -155,3 +155,5 @@ jobject CmpResponses::createCmpResponseObject(CmpMessage msg)
return newObject;
}
+
+
diff --git a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/JniHelpers.cpp b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/JniHelpers.cpp
index e47653d..4180907 100644
--- a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/JniHelpers.cpp
+++ b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/JniHelpers.cpp
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -34,7 +34,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
#include "JniHelpers.h"
#include "rootpaErrors.h"
-JniHelpers::JniHelpers(JNIEnv* envP):broken_(false),
+JniHelpers::JniHelpers(JNIEnv* envP):broken_(false),
envP_(envP),
keysP_(NULL),
valuesP_(NULL),
@@ -45,7 +45,7 @@ JniHelpers::JniHelpers(JNIEnv* envP):broken_(false),
stringConstructur_(NULL),
intConstructor_(NULL),
listAdd_(NULL)
-{}
+{}
JniHelpers::~JniHelpers()
{
@@ -53,20 +53,20 @@ JniHelpers::~JniHelpers()
{
envP_->DeleteLocalRef(listCls_);
}
-
+
if(intCls_!=NULL)
{
envP_->DeleteLocalRef(intCls_);
- }
-
+ }
+
if(stringCls_!=NULL)
{
envP_->DeleteLocalRef(stringCls_);
- }
+ }
}
-JniHelpers::JniHelpers(JNIEnv* envP,jobject* keysP, jobject* valuesP, jbyteArray* productIdP):broken_(false),
+JniHelpers::JniHelpers(JNIEnv* envP,jobject* keysP, jobject* valuesP, jbyteArray* productIdP):broken_(false),
envP_(envP),
keysP_(keysP),
valuesP_(valuesP),
@@ -81,15 +81,15 @@ JniHelpers::JniHelpers(JNIEnv* envP,jobject* keysP, jobject* valuesP, jbyteArray
listCls_=envP_->FindClass("java/util/List");
if(NULL == listCls_)
{
- LOGE("JniHelpers::JniHelpers no listCls_");
+ LOGE("JniHelpers::JniHelpers no listCls_");
broken_=true;
return;
}
- listAdd_=envP_->GetMethodID(listCls_, "add", "(Ljava/lang/Object;)Z");
+ listAdd_=envP_->GetMethodID(listCls_, "add", "(Ljava/lang/Object;)Z");
if(NULL == listAdd_)
{
- LOGE("JniHelpers::JniHelpers no listAdd_");
+ LOGE("JniHelpers::JniHelpers no listAdd_");
broken_=true;
return;
}
@@ -102,18 +102,18 @@ JniHelpers::JniHelpers(JNIEnv* envP,jobject* keysP, jobject* valuesP, jbyteArray
return;
}
- intConstructor_=envP_->GetMethodID(intCls_, "<init>", "(I)V");
+ intConstructor_=envP_->GetMethodID(intCls_, "<init>", "(I)V");
if(NULL == intConstructor_)
{
- LOGE("JniHelpers::JniHelpers no intConstructor_");
+ LOGE("JniHelpers::JniHelpers no intConstructor_");
broken_=true;
return;
}
-
+
stringCls_=envP_->FindClass("java/lang/String");
if(NULL == stringCls_)
{
- LOGE("JniHelpers::JniHelpers no stringCls_");
+ LOGE("JniHelpers::JniHelpers no stringCls_");
broken_=true;
return;
}
@@ -121,7 +121,7 @@ JniHelpers::JniHelpers(JNIEnv* envP,jobject* keysP, jobject* valuesP, jbyteArray
stringConstructur_=envP_->GetMethodID(stringCls_, "<init>", "([B)V");
if(NULL == stringConstructur_)
{
- LOGE("JniHelpers::JniHelpers no stringConstructur_");
+ LOGE("JniHelpers::JniHelpers no stringConstructur_");
broken_=true;
return;
}
@@ -138,11 +138,11 @@ int JniHelpers::setVersion(char* fieldName, int version)
broken_=true;
return ROOTPA_ERROR_INTERNAL;
}
-
+
jobject newStringObject = envP_->NewObject(stringCls_, stringConstructur_, fName);
if(NULL == newStringObject)
{
- LOGE("JniHelpers::setVersion no newStringObject");
+ LOGE("JniHelpers::setVersion no newStringObject");
broken_=true;
envP_->DeleteLocalRef(fName);
return ROOTPA_ERROR_INTERNAL;
@@ -151,31 +151,31 @@ int JniHelpers::setVersion(char* fieldName, int version)
if(envP_->CallBooleanMethod(*keysP_, listAdd_, newStringObject)==JNI_FALSE)
{
- LOGE("JniHelpers::setVersion can not add key");
+ LOGE("JniHelpers::setVersion can not add key");
broken_=true;
envP_->DeleteLocalRef(newStringObject);
- return ROOTPA_ERROR_INTERNAL;
+ return ROOTPA_ERROR_INTERNAL;
}
envP_->DeleteLocalRef(newStringObject);
jobject newIntObject = envP_->NewObject(intCls_, intConstructor_, version);
if(NULL == newIntObject)
{
- LOGE("JniHelpers::setVersion no newIntObject");
+ LOGE("JniHelpers::setVersion no newIntObject");
broken_=true;
return ROOTPA_ERROR_INTERNAL;
- }
-
+ }
+
if(envP_->CallBooleanMethod(*valuesP_, listAdd_, newIntObject)==JNI_FALSE)
{
- LOGE("JniHelpers::setVersion can not add value");
+ LOGE("JniHelpers::setVersion can not add value");
broken_=true;
envP_->DeleteLocalRef(newIntObject);
- return ROOTPA_ERROR_INTERNAL;
+ return ROOTPA_ERROR_INTERNAL;
}
envP_->DeleteLocalRef(newIntObject);
-
- return ROOTPA_OK;
+
+ return ROOTPA_OK;
}
int JniHelpers::setProductId(char* productId)
@@ -210,20 +210,20 @@ int JniHelpers::setIntToArray(jintArray* targetArrayP, int index, int source)
return ROOTPA_OK;
}
-jbyteArray JniHelpers::byteArrayToJByteArray(uint8_t* dataP, uint32_t length)
+jbyteArray JniHelpers::byteArrayToJByteArray(uint8_t* dataP, uint32_t length)
{
jbyteArray jbArray = NULL;
- if (envP_->EnsureLocalCapacity(1) == JNI_OK)
+ if (envP_->EnsureLocalCapacity(1) == JNI_OK)
{
-
- if ((length > 0) && (dataP != NULL))
+
+ if ((length > 0) && (dataP != NULL))
{
jbArray = envP_->NewByteArray(length);
- if (jbArray != NULL)
+ if (jbArray != NULL)
{
envP_->SetByteArrayRegion(jbArray, 0, length, (jbyte*) dataP);
}
- }
+ }
}
return jbArray;
@@ -235,7 +235,7 @@ jbyteArray JniHelpers::byteArrayToJByteArray(uint8_t* dataP, uint32_t length)
* @param outLength* (OUT PARAMETER) length of the returned uint8_t* byte array
* @return uint8_t* byte array. Needs to be freed with delete[] afterwards.
*/
-uint8_t* JniHelpers::jByteArrayToCByteArray(jbyteArray jBytes, uint32_t* outLength)
+uint8_t* JniHelpers::jByteArrayToCByteArray(jbyteArray jBytes, uint32_t* outLength)
{
*outLength=0;
uint8_t* cBytes = NULL;
@@ -244,16 +244,18 @@ uint8_t* JniHelpers::jByteArrayToCByteArray(jbyteArray jBytes, uint32_t* outLeng
*outLength = envP_->GetArrayLength(jBytes);
cBytes = new uint8_t[*outLength];
jbyte* p_jcResult = envP_->GetByteArrayElements(jBytes, JNI_FALSE);
- for (unsigned int i = 0; i < *outLength; i++)
+ for (unsigned int i = 0; i < *outLength; i++)
{
cBytes[i] = (uint8_t) p_jcResult[i] & (0x00ff);
}
envP_->ReleaseByteArrayElements(jBytes, p_jcResult, JNI_FALSE);
}
- else
+ else
{
LOGE("jByteArrayToCByteArray: Input is NULL or something else is broken. Cannot return byte array");
}
return cBytes;
}
+
+
diff --git a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/JniHelpers.h b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/JniHelpers.h
index 195019c..2a93d80 100644
--- a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/JniHelpers.h
+++ b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/JniHelpers.h
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -63,10 +63,10 @@ class JniHelpers
jclass listCls_;
jclass intCls_;
- jclass stringCls_;
+ jclass stringCls_;
jmethodID stringConstructur_;
jmethodID intConstructor_;
- jmethodID listAdd_;
+ jmethodID listAdd_;
};
diff --git a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/NOTICE b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/NOTICE
new file mode 100644
index 0000000..627167a
--- /dev/null
+++ b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/NOTICE
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
diff --git a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/com_gd_mobicore_pa_jni_CommonPAWrapper.h b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/com_gd_mobicore_pa_jni_CommonPAWrapper.h
index 5d0b140..c3aa05d 100644
--- a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/com_gd_mobicore_pa_jni_CommonPAWrapper.h
+++ b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/com_gd_mobicore_pa_jni_CommonPAWrapper.h
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -157,6 +157,11 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_unregisterRoo
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
diff --git a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/commonwrapper.cpp b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/commonwrapper.cpp
index 29b3f22..3fe592a 100644
--- a/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/commonwrapper.cpp
+++ b/mobicore/rootpa/Code/Android/app/jni/CommonPAWrapper/commonwrapper.cpp
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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 <string.h>
@@ -46,7 +46,7 @@ JavaVM* jvmP_ = NULL;
const jint VERSION=JNI_VERSION_1_2;
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* jvm, void* reserved)
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* jvm, void* reserved)
{
// remember JVM pointer:
jvmP_ = jvm;
@@ -56,7 +56,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* jvm, void* reserved)
JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_openSession(JNIEnv *, jobject)
{
- return (jint) openSessionToCmtl();
+ return (jint) openSessionToCmtl();
}
JNIEXPORT void JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_closeSession(JNIEnv *, jobject)
@@ -75,22 +75,22 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_executeCmpCom
int numberOfCommands=inCmd.numberOfElements();
if(0==numberOfCommands){
- LOGD("No commands received, returning ROOTPA_COMMAND_NOT_SUPPORTED\n");
+ LOGD("No commands received, returning ROOTPA_COMMAND_NOT_SUPPORTED\n");
return ROOTPA_COMMAND_NOT_SUPPORTED;
}
CmpMessage* commands = new CmpMessage[numberOfCommands];
if(NULL==commands) return ROOTPA_ERROR_OUT_OF_MEMORY;
- memset(commands, 0, numberOfCommands*sizeof(CmpMessage));
+ memset(commands, 0, numberOfCommands*sizeof(CmpMessage));
CmpMessage* responses = new CmpMessage[numberOfCommands];
if(NULL==responses)
- {
+ {
delete [] commands;
return ROOTPA_ERROR_OUT_OF_MEMORY;
}
memset(responses, 0, numberOfCommands*sizeof(CmpMessage));
-
+
if(inCmd.getCommands(commands)==false)
{
LOGE("getting commands on C side of the wrapper failed\n");
@@ -99,7 +99,7 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_executeCmpCom
else
{
ret=executeCmpCommands(numberOfCommands, commands, responses, &internalError);
- CmpResponses outRsp(env, outResults);
+ CmpResponses outRsp(env, outResults);
if(ret!=ROOTPA_OK)
{
LOGE("call to executeCmpCommands failed %d %d\n", ret, internalError);
@@ -144,7 +144,7 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getVersion
int ret=ROOTPA_OK;
int tag=0;
mcVersionInfo_t version;
-
+
ret=getVersion(&tag, &version);
if(ROOTPA_OK == ret)
{
@@ -177,7 +177,7 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getVersion
}
}
}
- LOGD("<<Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getVersion %x %x %x\n", productId, keys, values);
+ LOGD("<<Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getVersion %x %x %x\n", productId, keys, values);
return ret;
}
@@ -186,14 +186,14 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getSuid
{
int ret=ROOTPA_OK;
mcSuid_t mySuid;
-
+
ret=getSuid(&mySuid);
if(ROOTPA_OK == ret)
{
JniHelpers jniHelp(env);
ret=jniHelp.setByteArray(&suid, (uint8_t*)&mySuid, sizeof(mySuid));
}
- return ret;
+ return ret;
}
JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_isRootContainerRegistered
@@ -201,14 +201,14 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_isRootContain
{
int ret=ROOTPA_OK;
bool isRegistered;
-
+
ret=isRootContainerRegistered(&isRegistered);
if(ROOTPA_OK == ret)
{
JniHelpers jniHelp(envP);
ret=jniHelp.setBooleanToArray(&result, isRegistered);
}
- return ret;
+ return ret;
}
JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_isSpContainerRegistered
@@ -223,7 +223,7 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_isSpContainer
JniHelpers jniHelp(envP);
ret=jniHelp.setBooleanToArray(&result, isRegistered);
}
- return ret;
+ return ret;
}
JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getSPContainerState
@@ -240,11 +240,11 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getSPContaine
ret=jniHelp.setIntToArray(&stateArray, 0, state);
}
LOGD("<<Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getSpContainerState\n");
- return ret;
+ return ret;
}
const int CONTAINER_STATE_IDX=0;
-const int NUMBER_OF_TLTS_IDX=1;
+const int NUMBER_OF_TLTS_IDX=1;
const int NUMBER_OF_ELEMENTS=2;
JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getSPContainerStructure
@@ -255,7 +255,7 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getSPContaine
int state;
SpContainerStructure spContainerStructure;
-
+
ret=getSpContainerStructure((mcSpid_t) spid, &spContainerStructure);
if(ROOTPA_OK == ret)
{
@@ -285,7 +285,7 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getSPContaine
spContainerStructure.tltContainers[i].uuid.value[13],
spContainerStructure.tltContainers[i].uuid.value[14],
spContainerStructure.tltContainers[i].uuid.value[15]);
-
+
ret=jniHelp.setIntToArray(&trustletStates, i, spContainerStructure.tltContainers[i].state);
jbyteArray uuid = jniHelp.byteArrayToJByteArray(spContainerStructure.tltContainers[i].uuid.value, UUID_LENGTH);
envP->SetObjectArrayElement(uuidArray, i, (jobject) uuid);
@@ -304,12 +304,12 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getSPContaine
}
else
{
- LOGE("..._jni_CommonPAWrapper_getSPContainerStructure getSpContainerStructure failed\n");
+ LOGE("..._jni_CommonPAWrapper_getSPContainerStructure getSpContainerStructure failed\n");
}
-
-
+
+
LOGD("<<Java_com_gd_mobicore_pa_jni_CommonPAWrapper_getSPContainerStructure %d\n", ret);
- return ret;
+ return ret;
}
jmethodID provisioningStateCallback_=NULL;
@@ -323,7 +323,7 @@ void stateUpdateCallback(ProvisioningState state, rootpaerror_t error, tltInfo_t
JNIEnv* envP=NULL;
- // it is enough to call this only once for each thread but since this is
+ // it is enough to call this only once for each thread but since this is
// the best place to call it we call it every time
jint res = jvmP_->AttachCurrentThread(&envP, NULL);
@@ -331,7 +331,7 @@ void stateUpdateCallback(ProvisioningState state, rootpaerror_t error, tltInfo_t
if(NULL==obj_ ||NULL==provisioningStateCallback_ || NULL== envP || res != JNI_OK)
{
LOGE("obj=%ld, provisioningStateCallback==%ld, envP==%ld res==%d", (long int) obj_, (long int) provisioningStateCallback_, (long int) envP, res);
- }
+ }
else if(PROVISIONING_STATE_INSTALL_TRUSTLET == state)
{
if(tltInfoP)
@@ -343,12 +343,12 @@ void stateUpdateCallback(ProvisioningState state, rootpaerror_t error, tltInfo_t
}
else
{
- envP->CallVoidMethod(obj_, provisioningStateCallback_, ERROR, ROOTPA_ERROR_INTERNAL);
+ envP->CallVoidMethod(obj_, provisioningStateCallback_, ERROR_STATE, ROOTPA_ERROR_INTERNAL);
}
}
else
{
- envP->CallVoidMethod(obj_, provisioningStateCallback_, state, error);
+ envP->CallVoidMethod(obj_, provisioningStateCallback_, state, error);
}
if( obj_!=NULL && (PROVISIONING_STATE_THREAD_EXITING == state) )
@@ -358,20 +358,20 @@ void stateUpdateCallback(ProvisioningState state, rootpaerror_t error, tltInfo_t
obj_=NULL;
}
- // doing this in every round in order to make sure what is attached will be detached and that
- // envP is correctly updated at every round (it seems to work also inside the above if statement,
- // but calling AttachCurrentThread to already attached thread is is supposed to be no-op. It seems
+ // doing this in every round in order to make sure what is attached will be detached and that
+ // envP is correctly updated at every round (it seems to work also inside the above if statement,
+ // but calling AttachCurrentThread to already attached thread is is supposed to be no-op. It seems
// to update the envP though.)
// If the thread is not detached there will be a crash when the thread exists
jvmP_->DetachCurrentThread();
-
+
LOGD("<<stateUpdateCallback\n");
}
void storeCallbackMethodIds(JNIEnv* envP)
{
- LOGD(">>storeCallbackMethodIds\n");
-
+ LOGD(">>storeCallbackMethodIds\n");
+
jclass cls = envP->GetObjectClass(obj_);
if(NULL==cls)
{
@@ -382,37 +382,37 @@ void storeCallbackMethodIds(JNIEnv* envP)
if(NULL==provisioningStateCallback_)
{
LOGE("storeCallbackMethodIds provisioningStateCallback_==NULL");
- }
+ }
getSystemInfoCallback_ = envP->GetMethodID(cls, "getSystemInfo","()[Ljava/lang/String;");
if(NULL==getSystemInfoCallback_)
{
LOGE("storeCallbackMethodIds getSystemInfoCallback_==NULL");
- }
+ }
trustletInstallCallback_ = envP->GetMethodID(cls, "trustletInstallCallback","([B)V");
if(NULL==trustletInstallCallback_)
{
LOGE("storeCallbackMethodIds trustletInstallCallback_==NULL");
- }
+ }
if(cls!=NULL)
{
envP->DeleteLocalRef(cls);
}
-
+
LOGD("<<storeCallbackMethodIds\n");
}
/*
-This function has to be called before any communication with SE is done (or actually,
+This function has to be called before any communication with SE is done (or actually,
before any xml parsing is done.
*/
void setFilesPath(JNIEnv* envP, jobject obj)
{
LOGD(">>setFilesPath\n");
-
+
jclass cls = envP->GetObjectClass(obj);
if(NULL==cls)
{
@@ -422,14 +422,14 @@ void setFilesPath(JNIEnv* envP, jobject obj)
jmethodID getFilesDirPath = envP->GetMethodID(cls, "getFilesDirPath","()Ljava/lang/String;");
if(NULL==getFilesDirPath)
{
- setPaths(HARDCODED_STORAGEPATH, CERT_PATH);
+ setPaths(HARDCODED_STORAGEPATH, CERT_PATH);
LOGE("<<setFilesPath getFilesDirPath==NULL, used hardcoded paths");
return;
}
-
- jobject jpath = envP->CallObjectMethod(obj, getFilesDirPath);
+
+ jobject jpath = envP->CallObjectMethod(obj, getFilesDirPath);
if(jpath!=NULL)
- {
+ {
const char* pathP = envP->GetStringUTFChars((jstring)jpath, NULL);
setPaths(pathP, CERT_PATH);
if(NULL == pathP)
@@ -443,19 +443,19 @@ void setFilesPath(JNIEnv* envP, jobject obj)
else
{
LOGE("setFilesPath jpath==NULL, using hardcoded paths");
- setPaths(HARDCODED_STORAGEPATH, CERT_PATH);
- }
+ setPaths(HARDCODED_STORAGEPATH, CERT_PATH);
+ }
if(cls!=NULL)
{
envP->DeleteLocalRef(cls);
- }
-
+ }
+
LOGD("<<setFilesPath\n");
}
const int IMEI_ESN_INDEX=com_gd_mobicore_pa_jni_CommonPAWrapper_IMEI_ESN_INDEX;
-const int MNO_INDEX=com_gd_mobicore_pa_jni_CommonPAWrapper_MNO_INDEX;
+const int MNO_INDEX=com_gd_mobicore_pa_jni_CommonPAWrapper_MNO_INDEX;
const int BRAND_INDEX=com_gd_mobicore_pa_jni_CommonPAWrapper_BRAND_INDEX;
const int MANUFACTURER_INDEX=com_gd_mobicore_pa_jni_CommonPAWrapper_MANUFACTURER_INDEX;
const int HARDWARE_INDEX=com_gd_mobicore_pa_jni_CommonPAWrapper_HARDWARE_INDEX;
@@ -468,12 +468,15 @@ void copyElement(JNIEnv* envP, char** target, jstring source)
{
const char* tmp=envP->GetStringUTFChars(source, NULL);
*target=(char*)malloc(strlen(tmp)+1);
- strcpy(*target, tmp);
+ if(*target!=NULL)
+ {
+ strcpy(*target, tmp);
+ }
envP->ReleaseStringUTFChars(source, tmp);
}
else
{
- *target=NULL;
+ *target=NULL;
}
}
@@ -483,9 +486,9 @@ rootpaerror_t getSystemInfoCallback(osInfo_t* osSpecificInfoP)
rootpaerror_t ret=ROOTPA_OK;
if(NULL==osSpecificInfoP) return ROOTPA_ERROR_INTERNAL;
-
+
memset(osSpecificInfoP, 0, sizeof(osInfo_t));
-
+
JNIEnv* envP=NULL;
jint res = jvmP_->AttachCurrentThread(&envP, NULL);
@@ -494,12 +497,12 @@ rootpaerror_t getSystemInfoCallback(osInfo_t* osSpecificInfoP)
{
ret=ROOTPA_ERROR_INTERNAL;
LOGE("obj=%ld, getSystemInfoCallback_==%ld, envP==%ld res==%d", (long int) obj_, (long int) getSystemInfoCallback_, (long int) envP, res);
- }
+ }
else
{
- jobjectArray systemInfo = (jobjectArray) envP->CallObjectMethod(obj_, getSystemInfoCallback_);
+ jobjectArray systemInfo = (jobjectArray) envP->CallObjectMethod(obj_, getSystemInfoCallback_);
if(systemInfo!=NULL)
- {
+ {
jstring imeiEsn=(jstring) envP->GetObjectArrayElement(systemInfo, IMEI_ESN_INDEX);
jstring mno=(jstring) envP->GetObjectArrayElement(systemInfo, MNO_INDEX);
jstring brand=(jstring) envP->GetObjectArrayElement(systemInfo, BRAND_INDEX);
@@ -507,7 +510,7 @@ rootpaerror_t getSystemInfoCallback(osInfo_t* osSpecificInfoP)
jstring hw=(jstring) envP->GetObjectArrayElement(systemInfo, HARDWARE_INDEX);
jstring model=(jstring) envP->GetObjectArrayElement(systemInfo, MODEL_INDEX);
jstring version=(jstring) envP->GetObjectArrayElement(systemInfo, VERSION_INDEX);
-
+
copyElement(envP, &osSpecificInfoP->imeiEsnP, imeiEsn);
copyElement(envP, &osSpecificInfoP->mnoP, mno);
copyElement(envP, &osSpecificInfoP->brandP, brand);
@@ -523,12 +526,12 @@ rootpaerror_t getSystemInfoCallback(osInfo_t* osSpecificInfoP)
if(manufacturer!=NULL) envP->DeleteLocalRef(manufacturer);
if(hw!=NULL) envP->DeleteLocalRef(hw);
if(model!=NULL) envP->DeleteLocalRef(model);
- if(version!=NULL) envP->DeleteLocalRef(version);
- }
+ if(version!=NULL) envP->DeleteLocalRef(version);
+ }
}
- // doing this in every round in order to make sure what is attached will be detached and that
- // envP is correctly updated at every round (it seems to work also inside the above if, but
+ // doing this in every round in order to make sure what is attached will be detached and that
+ // envP is correctly updated at every round (it seems to work also inside the above if, but
// calling AttachCurrentThread to already attched thread is is supposed to be no-op. It seems to
// update the envP though.)
// If the thread is not detached there will be a crash when the thread exists
@@ -544,14 +547,14 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_doProvisionin
LOGD(">>Java_com_gd_mobicore_pa_jni_CommonPAWrapper_doProvisioning %ld %ld\n", (long int) stateUpdateCallback, (long int) getSystemInfoCallback);
setFilesPath(envP, obj);
int ret=ROOTPA_OK;
-
+
if(seAddress)
{
uint32_t length=0;
JniHelpers jniHelp(envP);
char* addrP=(char*)jniHelp.jByteArrayToCByteArray(seAddress, &length);
ret=setSeAddress(addrP, length);
- delete[] addrP;
+ delete[] addrP;
}
if(ROOTPA_OK==ret)
@@ -566,36 +569,36 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_doProvisionin
JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_installTrustlet
-(JNIEnv* envP, jobject obj,
-jint spid,
-jbyteArray uuid,
-jint requestDataType,
-jbyteArray tltOrKeyData,
+(JNIEnv* envP, jobject obj,
+jint spid,
+jbyteArray uuid,
+jint requestDataType,
+jbyteArray tltOrKeyData,
jint minTltVersion,
jbyteArray tltPukHash,
-jint memoryType,
-jint numberOfInstances,
-jint flags,
+jint memoryType,
+jint numberOfInstances,
+jint flags,
jbyteArray seAddress)
{
LOGD(">>Java_com_gd_mobicore_pa_jni_CommonPAWrapper_installTrustlet %ld %ld\n", (long int) stateUpdateCallback, (long int) getSystemInfoCallback);
setFilesPath(envP, obj);
int ret=ROOTPA_OK;
- JniHelpers jniHelp(envP);
-
+ JniHelpers jniHelp(envP);
+
if(seAddress)
{
uint32_t length=0;
char* addrP=(char*)jniHelp.jByteArrayToCByteArray(seAddress, &length);
ret=setSeAddress(addrP, length);
- delete[] addrP;
+ delete[] addrP;
}
if(ROOTPA_OK==ret)
{
obj_= envP->NewGlobalRef(obj);
storeCallbackMethodIds(envP);
- trustletInstallationData_t tltData;
+ trustletInstallationData_t tltData;
tltData.dataP=(uint8_t*) jniHelp.jByteArrayToCByteArray(tltOrKeyData, &tltData.dataLength);
tltData.dataType=(TltInstallationRequestDataType) requestDataType;
tltData.minTltVersion=minTltVersion;
@@ -603,7 +606,7 @@ jbyteArray seAddress)
tltData.memoryType=memoryType;
tltData.numberOfInstances=numberOfInstances;
tltData.flags=flags;
-
+
uint32_t uuidLength=0;
uint8_t* uuidP=(uint8_t*) jniHelp.jByteArrayToCByteArray(uuid, &uuidLength);
if(UUID_LENGTH != uuidLength){
@@ -633,11 +636,11 @@ JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_unregisterRoo
uint32_t length=0;
char* addrP=(char*)jniHelp.jByteArrayToCByteArray(seAddress, &length);
ret=setSeAddress(addrP, length);
- delete[] addrP;
+ delete[] addrP;
}
if(ROOTPA_OK==ret)
- {
+ {
obj_= envP->NewGlobalRef(obj);
storeCallbackMethodIds(envP);
ret=unregisterRootContainer(stateUpdateCallback, getSystemInfoCallback);
@@ -656,7 +659,7 @@ char* addTrailingZero(uint8_t* vP, uint32_t length)
memcpy(newVP, vP, length);
newVP[length]=0;
}
- delete [] vP;
+ delete [] vP;
return newVP;
}
@@ -664,11 +667,11 @@ JNIEXPORT void JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmen
{
LOGD(">>Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmentVariable");
JniHelpers jniHelp(envP);
- uint32_t length=0;
+ uint32_t length=0;
char* envVarP=NULL;
char* envValP=NULL;
uint8_t* vP=jniHelp.jByteArrayToCByteArray(variable_name, &length);
-
+
if(NULL==vP)
{
LOGE("Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmentVariable, FAILURE: can not get variable\n");
@@ -678,7 +681,7 @@ JNIEXPORT void JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmen
envVarP = addTrailingZero(vP, length);
if(value!=NULL)
{
- vP=jniHelp.jByteArrayToCByteArray(value, &length);
+ vP=jniHelp.jByteArrayToCByteArray(value, &length);
if(NULL!=vP)
{
envValP = addTrailingZero(vP, length);
@@ -698,7 +701,7 @@ JNIEXPORT void JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmen
}
else
{
- LOGD("unsetting environment variable, %s", envVarP);
+ LOGD("unsetting environment variable, %s", envVarP);
if(unsetenv(envVarP)!=0)
{
LOGE("Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmentVariable, unsetenv %s FAILURE\n", envVarP);
@@ -709,3 +712,37 @@ JNIEXPORT void JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmen
delete[] envValP;
LOGD("<<Java_com_gd_mobicore_pa_jni_CommonPAWrapper_setEnvironmentVariable");
}
+
+JNIEXPORT jint JNICALL Java_com_gd_mobicore_pa_jni_CommonPAWrapper_storeTA(JNIEnv* envP, jobject obj, 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;
+}
+
diff --git a/mobicore/rootpa/Code/Android/app/jni/McStub/Android.mk b/mobicore/rootpa/Code/Android/app/jni/McStub/Android.mk
index 2bc574c..307dc07 100644
--- a/mobicore/rootpa/Code/Android/app/jni/McStub/Android.mk
+++ b/mobicore/rootpa/Code/Android/app/jni/McStub/Android.mk
@@ -50,5 +50,7 @@ ifeq ($(ROOTPA_MODULE_TEST), 1)
LOCAL_C_INCLUDES += $(MOBICOREDRIVER_DIR_INC)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../Common/include
+ LOCAL_32_BIT_ONLY := true
+
include $(BUILD_STATIC_LIBRARY)
endif
diff --git a/mobicore/rootpa/Code/Android/app/jni/McStub/NOTICE b/mobicore/rootpa/Code/Android/app/jni/McStub/NOTICE
new file mode 100644
index 0000000..627167a
--- /dev/null
+++ b/mobicore/rootpa/Code/Android/app/jni/McStub/NOTICE
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
diff --git a/mobicore/rootpa/Code/Android/app/res/values/version.xml b/mobicore/rootpa/Code/Android/app/res/values/version.xml
index 5ef4dfb..2ec00e2 100644
--- a/mobicore/rootpa/Code/Android/app/res/values/version.xml
+++ b/mobicore/rootpa/Code/Android/app/res/values/version.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="name">2.0068 (46860)</string>
- <integer name="code">0x20044</integer>
+ <string name="name">3.0079 (51551)</string>
+ <integer name="code">0x3004F</integer>
</resources>
diff --git a/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/jni/CommonPAWrapper.java b/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/jni/CommonPAWrapper.java
index 0d56599..febaac9 100644
--- a/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/jni/CommonPAWrapper.java
+++ b/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/jni/CommonPAWrapper.java
@@ -3,35 +3,35 @@ Copyright © Trustonic Limited 2013
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.
*/
//
-// Wrapper class for common C part of the Root Provisioning Agent, the C
-// files under Android/jni
+// Wrapper class for common C part of the Root Provisioning Agent, the C
+// files under Android/jni
//
package com.gd.mobicore.pa.jni;
@@ -50,7 +50,7 @@ import com.gd.mobicore.pa.ifc.CmpResponse;
public class CommonPAWrapper {
private static final String TAG = "RootPA-J";
private BaseService service_;
-
+
public CommonPAWrapper(BaseService service){
service_=service;
Log.d(TAG,"CommonPAWrapper.java: constructor");
@@ -66,24 +66,25 @@ public class CommonPAWrapper {
public native int getSPContainerState(int spid, int[] state);
public native int getSPContainerStructure(int spid, int[] ints, byte[][] uuidArray, int[] trustletStates);
public native int doProvisioning(int uid, int spid, byte[] seAddress);
- public native int installTrustlet(int spid,
- byte[] uuid,
- int dataType,
+ public native int installTrustlet(int spid,
+ byte[] uuid,
+ int dataType,
byte[] tltOrKeyData,
int minTltVersion,
byte[] tltPukHash,
- int memoryType,
- int numberOfInstances,
- int flags,
+ int memoryType,
+ int numberOfInstances,
+ int flags,
byte[] seAddress);
public native int unregisterRootContainer(byte[] seAddress);
- public native void setEnvironmentVariable(byte[] variable, byte[] value);
+ 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");
}
@@ -102,14 +103,14 @@ public class CommonPAWrapper {
}
private static final int IMEI_ESN_INDEX=0;
- private static final int MNO_INDEX=1;
+ private static final int MNO_INDEX=1;
private static final int BRAND_INDEX=2;
private static final int MANUFACTURER_INDEX=3;
private static final int HARDWARE_INDEX=4;
- private static final int MODEL_INDEX=5;
+ private static final int MODEL_INDEX=5;
private static final int VERSION_INDEX=6;
private static final int RESPONSE_ARRAY_SIZE=7;
-
+
public String[] getSystemInfo(){
Log.d(TAG,">>CommonPAWrapper.getSystemInfo");
String[] response= new String[RESPONSE_ARRAY_SIZE];
@@ -127,11 +128,11 @@ public class CommonPAWrapper {
Log.d(TAG,"<<CommonPAWrapper.getSystemInfo "+response[IMEI_ESN_INDEX]+" "+response[MANUFACTURER_INDEX]+" "+response[VERSION_INDEX]);
return response;
}
-
-
+
+
public void trustletInstallCallback(byte[] trustlet){
Log.d(TAG,">>CommonPAWrapper.trustletInstallCallback "+trustlet.length);
service_.trustletInstallCallback(trustlet);
- Log.d(TAG,"<<CommonPAWrapper.trustletInstallCallback");
+ Log.d(TAG,"<<CommonPAWrapper.trustletInstallCallback");
}
}
diff --git a/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/BaseService.java b/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/BaseService.java
index 030eb73..536a6b8 100644
--- a/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/BaseService.java
+++ b/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/BaseService.java
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -54,10 +54,10 @@ import com.gd.mobicore.pa.ifc.RootPAProvisioningIntents;
import com.gd.mobicore.pa.ifc.CommandResult;
public abstract class BaseService extends Service {
- protected static final String TAG = "RootPA-J";
+ protected static final String TAG = "RootPA-J";
/*
- being statically linked library, the Common C implementation does not handle locks,
+ being statically linked library, the Common C implementation does not handle locks,
they must be handled in the using implementation, in this case here.
*/
private static final int LOCK_FREE=0;
@@ -67,8 +67,8 @@ public abstract class BaseService extends Service {
private Timer timer_=null;
protected int doProvisioningLockSuid_=0;
- protected byte[] se_ = null;
-
+ protected byte[] se_ = null;
+
private static final int C_CONNECTING_SERVICE_ENABLER=1;
private static final int C_AUTHENTICATING_SOC=2;
private static final int C_CREATING_ROOT_CONTAINER=3;
@@ -81,15 +81,15 @@ public abstract class BaseService extends Service {
protected final CommonPAWrapper commonPaWrapper_=new CommonPAWrapper(this);
private boolean sessionOpened_=false;
-
+
protected CommonPAWrapper commonPAWrapper(){
return commonPaWrapper_;
}
-
+
protected synchronized CommandResult acquireLock(int uid, boolean openSession){
Log.d(TAG,">>BaseService.acquireLock "+uid+" "+lock_.get()+" "+timer_);
if(uid==LOCK_FREE){
- return new CommandResult(CommandResult.ROOTPA_ERROR_ILLEGAL_ARGUMENT);
+ return new CommandResult(CommandResult.ROOTPA_ERROR_ILLEGAL_ARGUMENT);
}
boolean result=lock_.compareAndSet(LOCK_FREE, uid);
if(result==true || lock_.get() == uid){
@@ -111,7 +111,7 @@ public abstract class BaseService extends Service {
Log.i(TAG,"Timer expired, releasing lock");
lock_.set(LOCK_FREE);
if(sessionOpened_==true){
- Log.d(TAG,"BaseService.Timer.run, closingSession");
+ Log.d(TAG,"BaseService.Timer.run, closingSession");
commonPAWrapper().closeSession();
sessionOpened_=false;
}
@@ -123,13 +123,13 @@ public abstract class BaseService extends Service {
}
return new CommandResult(CommandResult.ROOTPA_ERROR_LOCK);
}
-
+
// this is public for the ProvisioningService to call it
protected synchronized CommandResult releaseLock(int uid, boolean closeSession){
Log.d(TAG,"BaseService.releaseLock "+uid+" "+lock_.get()+" "+timer_);
-
+
if(uid==LOCK_FREE){
- return new CommandResult(CommandResult.ROOTPA_ERROR_ILLEGAL_ARGUMENT);
+ return new CommandResult(CommandResult.ROOTPA_ERROR_ILLEGAL_ARGUMENT);
}
if((lock_.get()==LOCK_FREE) || (lock_.compareAndSet(uid, LOCK_FREE)==true)){
@@ -158,7 +158,7 @@ public abstract class BaseService extends Service {
BroadcastReceiver networkChangeReceiver_=null;
protected void setupProxy()
- {
+ {
byte[] proxyAddress=null;
ProxySelector defaultProxySelector = ProxySelector.getDefault();
@@ -169,15 +169,15 @@ public abstract class BaseService extends Service {
if(se_==null){
uri=new URI("https://se.cgbe.trustonic.com"); // the URI here does not matter a lot, as long as one exists. We try to use as real one as is easily possible
}else{
- uri=new URI(new String(se_));
+ uri=new URI(new String(se_));
}
proxyList = defaultProxySelector.select(uri);
if (proxyList.size() > 0)
{
Proxy proxy = proxyList.get(0);
- Log.d(TAG,"BaseService.setupProxy proxy "+proxy); // there should be only one element in the list in the current Android versions, it is for the current connection
+ Log.d(TAG,"BaseService.setupProxy proxy "+proxy); // there should be only one element in the list in the current Android versions, it is for the current connection
if(proxy != Proxy.NO_PROXY){
- Log.d(TAG,"BaseService.setupProxy proxy.type "+proxy.type());
+ Log.d(TAG,"BaseService.setupProxy proxy.type "+proxy.type());
if(proxy.type()==Proxy.Type.HTTP){
// TODO-future there is currently no way for the user to store proxy user name and password in Android,
// so they need to be asked at connection time. There is not any kind of user/password support for proxies in RootPA.
@@ -187,14 +187,14 @@ public abstract class BaseService extends Service {
}
}
}
-
+
}catch(Exception e){
Log.e(TAG,"BaseService.setupProxy FAILURE in getting the proxy: "+e.toString());
}
}
commonPAWrapper().setEnvironmentVariable("http_proxy".getBytes(), proxyAddress);
- commonPAWrapper().setEnvironmentVariable("https_proxy".getBytes(), proxyAddress);
+ commonPAWrapper().setEnvironmentVariable("https_proxy".getBytes(), proxyAddress);
Log.d(TAG,"BaseService.setupProxy just set the proxy to: "+(proxyAddress==null?proxyAddress:new String(proxyAddress)));
// start listening to intents on network changes if not doing it already
@@ -209,7 +209,7 @@ public abstract class BaseService extends Service {
Log.d(TAG,"BaseService: Network "+ni.getTypeName()+" connected");
setupProxy();
}else{
- if(ni!=null){
+ if(ni!=null){
Log.d(TAG, "BaseService: network state "+ni.getState());
}else{
Log.d(TAG, "BaseService: no network info");
@@ -223,14 +223,14 @@ public abstract class BaseService extends Service {
IntentFilter filter=new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
registerReceiver(networkChangeReceiver_, filter);
}
- }
-
+ }
+
protected synchronized boolean locked(int uid){
return(lock_.get() != uid && uid != LOCK_FREE);
}
-
+
/**
- This method is called from the C code to send the trustlet binary to the client
+ This method is called from the C code to send the trustlet binary to the client
(trustlet connector/"sp.pa" for develope trustlet) that then can store it where desired.
*/
public void trustletInstallCallback(byte[] trustlet){
@@ -238,9 +238,9 @@ public abstract class BaseService extends Service {
Intent intent=new Intent(RootPAProvisioningIntents.INSTALL_TRUSTLET);
intent.putExtra(RootPAProvisioningIntents.TRUSTLET, trustlet);
sendBroadcast(intent);
- Log.d(TAG,"<<BaseService.trustletInstallCallback");
+ Log.d(TAG,"<<BaseService.trustletInstallCallback");
}
-
+
/**
This method is called from the C code to get the path for files directory
*/
@@ -252,15 +252,15 @@ public abstract class BaseService extends Service {
This method is called from the C code to send the intents while executing doProvisioning
*/
public void provisioningStateCallback(int state, int ret){
- Log.d(TAG,">>provisioningStateCallback "+state+" "+ret);
+ Log.d(TAG,">>provisioningStateCallback "+state+" "+ret);
// since sommunication with SE may take consirderable amount of time, we refresh the Lock timer
- // by calling acquireLock every time a state notification callback is called. This way the lock
+ // by calling acquireLock every time a state notification callback is called. This way the lock
// will not timeout before the communication with SE is complete.
try{
CommandResult res=acquireLock(doProvisioningLockSuid_, false);
if(!res.isOk()){
- Log.e(TAG,"provisioningStateCallback re-acquiring lock failed, res: "+res.result());
+ Log.e(TAG,"provisioningStateCallback re-acquiring lock failed, res: "+res.result());
}
}catch(Exception e){
Log.e(TAG,"provisioningStateCallback re-acquiring lock failed: "+e);
@@ -291,7 +291,7 @@ public abstract class BaseService extends Service {
break;
case C_ERROR:
intent=new Intent(RootPAProvisioningIntents.PROVISIONING_ERROR);
-
+
intent.putExtra(RootPAProvisioningIntents.ERROR, ret);
break;
@@ -299,9 +299,9 @@ public abstract class BaseService extends Service {
try{
CommandResult res=releaseLock(doProvisioningLockSuid_, false);
if(!res.isOk()){
- Log.e(TAG,"provisioningStateCallback releasing lock failed, res: "+res.result());
+ Log.e(TAG,"provisioningStateCallback releasing lock failed, res: "+res.result());
}
- doProvisioningLockSuid_=0;
+ doProvisioningLockSuid_=0;
intent=null; // no intent sent in this case
}catch(Exception e){
Log.e(TAG,"provisioningStateCallback releasing lock failed: "+e);
@@ -310,7 +310,7 @@ public abstract class BaseService extends Service {
unregisterReceiver(networkChangeReceiver_);
networkChangeReceiver_=null;
}
- sendBroadcast(new Intent(RootPAProvisioningIntents.FINISHED_ROOT_PROVISIONING));
+ sendBroadcast(new Intent(RootPAProvisioningIntents.FINISHED_ROOT_PROVISIONING));
break;
default:
Log.e(TAG,"unknown state: "+state);
@@ -327,8 +327,8 @@ public abstract class BaseService extends Service {
public void onConfigurationChanged(android.content.res.Configuration newConfig){
super.onConfigurationChanged(newConfig);
Log.d(TAG,"BaseService.onConfigurationChanged");
- }
-
+ }
+
public void onCreate(){
super.onCreate();
Log.d(TAG,"BaseService.onCreate");
@@ -339,45 +339,45 @@ public abstract class BaseService extends Service {
unregisterReceiver(networkChangeReceiver_);
networkChangeReceiver_=null;
}
- Log.d(TAG,"BaseService.onDestroy");
+ Log.d(TAG,"BaseService.onDestroy");
}
-
+
public void onLowMemory(){
super.onLowMemory();
Log.d(TAG,"BaseService.onLowMemory");
}
-
+
public void onRebind(Intent intent){
super.onRebind(intent);
Log.d(TAG,"BaseService.onRebind");
- }
-
+ }
+
public void onStart(Intent intent, int startId){
super.onStart(intent, startId);
Log.d(TAG,"BaseService.onStart");
- }
+ }
public int onStartCommand(Intent intent, int flags, int startId){
int res=super.onStartCommand(intent, flags, startId);
Log.d(TAG,"BaseService.onStartCommand");
- return res;
- }
-
+ return res;
+ }
+
public void onTaskRemoved(Intent intent){
super.onTaskRemoved(intent);
Log.d(TAG,"BaseService.onTaskRemoved");
- }
-
-
+ }
+
+
public void onTrimMemory(int level){
super.onTrimMemory(level);
Log.d(TAG,"BaseService.onTrimMemory");
}
-
+
public boolean onUnbind(Intent intent){
boolean res=super.onUnbind(intent);
Log.d(TAG,"BaseService.onUnbind");
return res;
- }
-
+ }
+
} \ No newline at end of file
diff --git a/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/DeveloperService.java b/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/DeveloperService.java
index 6d1bdf9..718734f 100644
--- a/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/DeveloperService.java
+++ b/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/DeveloperService.java
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -54,7 +54,7 @@ public class DeveloperService extends BaseService {
private static final int EXTERNAL_MEMORY=2;
private static final int DEFAULT_MEMORY_TYPE=EXTERNAL_MEMORY;
private static final int DEFAULT_NUMBER_OF_INSTANCES=1;
- private static final int DEFAULT_FLAGS=0;
+ private static final int DEFAULT_FLAGS=0;
private static final byte[] DEFAULT_PUKHASH={0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0};
@@ -65,7 +65,7 @@ public class DeveloperService extends BaseService {
// note that these values have to be in line with TltInstallationRequestDataType in rootpa.h
public static final int REQUEST_DATA_TLT=1;
- public static final int REQUEST_DATA_KEY=2;
+ public static final int REQUEST_DATA_KEY=2;
private CommonPAWrapper commonPAWrapper(){
@@ -80,18 +80,18 @@ public class DeveloperService extends BaseService {
Log.d(TAG,"DeveloperService.Stub.uuidOk OK");
return true;
}
-
+
public CommandResult installTrustletOrKey(int spid, byte[] uuid, byte[] trustletBinary, byte[] key, int minTltVersion, byte[] tltPukHash){
- Log.d(TAG,">>DeveloperService.Stub.installTrustletOrKey");
+ Log.d(TAG,">>DeveloperService.Stub.installTrustletOrKey");
if(tltPukHash==null){
tltPukHash=DEFAULT_PUKHASH;
}
-
+
if((trustletBinary == null && key == null) || (trustletBinary != null && key != null) || 0==spid || !uuidOk(uuid) ){
return new CommandResult(CommandResult.ROOTPA_ERROR_ILLEGAL_ARGUMENT);
}
- int tmpSuid=DEVELOPER_UID_FOR_LOCK+new Random().nextInt();
+ int tmpSuid=DEVELOPER_UID_FOR_LOCK+new Random().nextInt();
if(!DeveloperService.this.acquireLock(tmpSuid, false).isOk()){
return new CommandResult(CommandResult.ROOTPA_ERROR_LOCK);
@@ -99,7 +99,7 @@ public class DeveloperService extends BaseService {
doProvisioningLockSuid_=tmpSuid;
int err=0;
byte[] data=null;
- int dataType;
+ int dataType;
try{
if(trustletBinary != null){
data=trustletBinary;
@@ -108,16 +108,16 @@ public class DeveloperService extends BaseService {
data=key;
dataType=REQUEST_DATA_KEY;
}
- setupProxy();
- err=commonPAWrapper().installTrustlet(spid,
- uuid,
- dataType,
- data,
- minTltVersion,
- tltPukHash,
- DEFAULT_MEMORY_TYPE,
- DEFAULT_NUMBER_OF_INSTANCES,
- DEFAULT_FLAGS,
+ setupProxy();
+ err=commonPAWrapper().installTrustlet(spid,
+ uuid,
+ dataType,
+ data,
+ minTltVersion,
+ tltPukHash,
+ DEFAULT_MEMORY_TYPE,
+ DEFAULT_NUMBER_OF_INSTANCES,
+ DEFAULT_FLAGS,
se_);
}catch(Exception e){
Log.e(TAG,"CommonPAWrapper().installTrustletOrKey exception: ", e);
@@ -127,26 +127,26 @@ public class DeveloperService extends BaseService {
Log.d(TAG,"<<DeveloperService.Stub.installTrustletOrKey");
return new CommandResult(err);
}
-
- public CommandResult installTrustlet(int spid,
- byte[] uuid,
- byte[] trustletBinary,
- int minTltVersion,
- byte[] tltPukHash,
- int memoryType,
- int numberOfInstances,
+
+ public CommandResult installTrustlet(int spid,
+ byte[] uuid,
+ byte[] trustletBinary,
+ int minTltVersion,
+ byte[] tltPukHash,
+ int memoryType,
+ int numberOfInstances,
int flags){
- Log.d(TAG,">>DeveloperService.Stub.installTrustlet");
+ Log.d(TAG,">>DeveloperService.Stub.installTrustlet");
if(tltPukHash==null){
tltPukHash=DEFAULT_PUKHASH;
}
-
+
if(trustletBinary == null || 0==spid || !uuidOk(uuid) || memoryType > EXTERNAL_MEMORY){
return new CommandResult(CommandResult.ROOTPA_ERROR_ILLEGAL_ARGUMENT);
}
- int tmpSuid=DEVELOPER_UID_FOR_LOCK+new Random().nextInt();
+ int tmpSuid=DEVELOPER_UID_FOR_LOCK+new Random().nextInt();
if(!DeveloperService.this.acquireLock(tmpSuid, false).isOk()){
return new CommandResult(CommandResult.ROOTPA_ERROR_LOCK);
@@ -154,16 +154,16 @@ public class DeveloperService extends BaseService {
doProvisioningLockSuid_=tmpSuid;
int err=0;
try{
- setupProxy();
- err=commonPAWrapper().installTrustlet(spid,
- uuid,
- REQUEST_DATA_TLT,
- trustletBinary,
- minTltVersion,
+ setupProxy();
+ err=commonPAWrapper().installTrustlet(spid,
+ uuid,
+ REQUEST_DATA_TLT,
+ trustletBinary,
+ minTltVersion,
tltPukHash,
- memoryType,
- numberOfInstances,
- flags,
+ memoryType,
+ numberOfInstances,
+ flags,
se_);
}catch(Exception e){
Log.e(TAG,"CommonPAWrapper().installTrustlet exception: ", e);
@@ -172,9 +172,9 @@ public class DeveloperService extends BaseService {
Log.d(TAG,"<<DeveloperService.Stub.installTrustlet");
return new CommandResult(err);
- }
+ }
}
-
+
@Override
public void onCreate() {
Log.d(TAG,"Hello, DeveloperService onCreate");
@@ -184,14 +184,14 @@ public class DeveloperService extends BaseService {
@Override
public void onLowMemory() {
Log.d(TAG,"DeveloperService onLowMemory");
- super.onLowMemory();
+ super.onLowMemory();
}
public void onDestroy(){
super.onDestroy();
Log.d(TAG,"DeveloperService being destroyed");
}
-
+
@Override
public IBinder onBind(Intent intent){
try{
@@ -200,7 +200,7 @@ public class DeveloperService extends BaseService {
Log.i(TAG,"DeveloperService something wrong in the given ip "+e );
}
- try{
+ try{
Log.setLoggingLevel(intent.getIntExtra("LOG",0));
}catch(Exception e){
Log.i(TAG,"DeveloperService something wrong in the given logging level "+e );
@@ -214,6 +214,8 @@ public class DeveloperService extends BaseService {
@Override
public int onStartCommand(Intent i, int flags, int startid){
Log.d(TAG,"DeveloperService starting");
- return START_STICKY;
- }
+ return START_STICKY;
+ }
}
+
+
diff --git a/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/OemService.java b/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/OemService.java
index f6382e2..70ec091 100644
--- a/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/OemService.java
+++ b/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/OemService.java
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -52,7 +52,7 @@ public class OemService extends BaseService {
private final RootPAOemIfc.Stub mBinder = new ServiceIfc();
private static final int OEM_UID_FOR_LOCK=0x33330000;
-
+
private class ServiceIfc extends RootPAOemIfc.Stub {
public ServiceIfc(){
super();
@@ -61,43 +61,43 @@ public class OemService extends BaseService {
private CommonPAWrapper commonPAWrapper(){
return OemService.this.commonPAWrapper();
}
-
+
public CommandResult unregisterRootContainer(){
- Log.d(TAG,">>RootPAServiceIfc.Stub.unregisterRootContainer");
+ Log.d(TAG,">>RootPAServiceIfc.Stub.unregisterRootContainer");
int tmpSuid=OEM_UID_FOR_LOCK+new Random().nextInt(); // this may override the uid used in lock, which means it will not be
-
+
if(!OemService.this.acquireLock(tmpSuid, false).isOk()){
return new CommandResult(CommandResult.ROOTPA_ERROR_LOCK);
}
doProvisioningLockSuid_=tmpSuid;
Log.d(TAG,"RootPAServiceIfc.Stub.unregisterRootContainer calling JNI");
-
+
int ret=CommandResult.ROOTPA_OK;
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;
}
-
+
CommandResult res=OemService.this.releaseLock(doProvisioningLockSuid_, false);
if(!res.isOk()){
Log.e(TAG,"releasing lock failed, res: "+res.result());
// this return code is not returned to the client since
// the command may have succeeded and there is just something wrong with the lock
// we leave it the the next command if the problem remains
- }
-
- Log.d(TAG,"<<RootPAServiceIfc.Stub.unregisterRootContainer");
+ }
+
+ Log.d(TAG,"<<RootPAServiceIfc.Stub.unregisterRootContainer");
return new CommandResult(ret);
}
-
+
}
-
+
@Override
public void onCreate() {
Log.d(TAG,"Hello, OemService onCreate");
@@ -107,14 +107,14 @@ public class OemService extends BaseService {
@Override
public void onLowMemory() {
Log.d(TAG,"OemService onLowMemory");
- super.onLowMemory();
+ super.onLowMemory();
}
public void onDestroy(){
- super.onDestroy();
+ super.onDestroy();
Log.d(TAG,"OemService being destroyed");
}
-
+
@Override
public IBinder onBind(Intent intent){
try{
@@ -123,7 +123,7 @@ public class OemService extends BaseService {
Log.i(TAG,"OemService something wrong in the given ip "+e );
}
- try{
+ try{
Log.setLoggingLevel(intent.getIntExtra("LOG",0));
}catch(Exception e){
Log.i(TAG,"OemService something wrong in the given logging level "+e );
@@ -136,6 +136,8 @@ public class OemService extends BaseService {
@Override
public int onStartCommand(Intent i, int flags, int startid){
Log.d(TAG,"OemService starting");
- return START_STICKY;
- }
+ return START_STICKY;
+ }
}
+
+
diff --git a/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/ProvisioningService.java b/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/ProvisioningService.java
index 9aea5fb..0fa9cca 100644
--- a/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/ProvisioningService.java
+++ b/mobicore/rootpa/Code/Android/app/src/com/gd/mobicore/pa/service/ProvisioningService.java
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -65,32 +65,32 @@ public class ProvisioningService extends BaseService {
private static final int PROVISIONING_UID_FOR_LOCK=0x11110000;
private static final int LONG_SIZE=8;
- private final RootPAServiceIfc.Stub mBinder = new ServiceIfc();
-
- // using this instead of anonymous inner class in order to allow call to some of the private methods we define here
+ private final RootPAServiceIfc.Stub mBinder = new ServiceIfc();
+
+ // using this instead of anonymous inner class in order to allow call to some of the private methods we define here
private class ServiceIfc extends RootPAServiceIfc.Stub {
public ServiceIfc(){
super();
}
-
+
private CommonPAWrapper commonPAWrapper(){
return ProvisioningService.this.commonPAWrapper();
}
-
+
public CommandResult executeCmpCommands(int uid, List<CmpCommand> commands, List<CmpResponse> responses){
- Log.d(TAG,">>RootPAServiceIfc.Stub.executeCmpCommands "+commands+" "+responses);
+ Log.d(TAG,">>RootPAServiceIfc.Stub.executeCmpCommands "+commands+" "+responses);
if(commands==null||responses==null){ // 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
- Log.d(TAG,"RootPAServiceIfc.Stub.executeCmpCommands, illegal argument");
+ Log.d(TAG,"RootPAServiceIfc.Stub.executeCmpCommands, illegal argument");
return new CommandResult(CommandResult.ROOTPA_ERROR_ILLEGAL_ARGUMENT);
- }
-
+ }
+
if(locked(uid)){
return new CommandResult(CommandResult.ROOTPA_ERROR_LOCK);
}
-
+
int ret=CommandResult.ROOTPA_OK;
try{
ret=commonPAWrapper().executeCmpCommands(uid, commands, responses);
@@ -102,17 +102,17 @@ public class ProvisioningService extends BaseService {
Log.d(TAG,"<<RootPAServiceIfc.Stub.executeCmpCommands");
return new CommandResult(ret);
}
-
+
public CommandResult isRootContainerRegistered(BooleanResult result){
- Log.d(TAG,">>RootPAServiceIfc.Stub.isRootContainerRegistered");
+ Log.d(TAG,">>RootPAServiceIfc.Stub.isRootContainerRegistered");
if(result==null){ // having null out variable leads to null pointer exception in the client, however we stll want to do checking so that there is not unncessary execution of the following code
Log.d(TAG,"RootPAServiceIfc.Stub.isRootContainerRegistered result null");
return new CommandResult(CommandResult.ROOTPA_ERROR_ILLEGAL_ARGUMENT);
- }
-
+ }
+
int internalUidForLock=new Random().nextInt();
-
+
if(!ProvisioningService.this.acquireLock(internalUidForLock, false).isOk())
{
return new CommandResult(CommandResult.ROOTPA_ERROR_LOCK);
@@ -126,7 +126,7 @@ public class ProvisioningService extends BaseService {
Log.e(TAG,"CommonPAWrapper().isRootContainerRegistered exception: ", e);
ret=CommandResult.ROOTPA_ERROR_INTERNAL;
}
- result.setResult(isRegistered[0]);
+ result.setResult(isRegistered[0]);
CommandResult res=ProvisioningService.this.releaseLock(internalUidForLock, false);
if(!res.isOk()){
@@ -134,14 +134,14 @@ public class ProvisioningService extends BaseService {
// this return code is not returned to the client since
// the command may have succeeded and there is just something wrong with the lock
// we leave it the the next command if the problem remains
- }
+ }
- Log.d(TAG,"<<RootPAServiceIfc.Stub.isRootContainerRegistered");
+ Log.d(TAG,"<<RootPAServiceIfc.Stub.isRootContainerRegistered");
return new CommandResult(ret);
}
public CommandResult isSPContainerRegistered(SPID spid, BooleanResult result){
- Log.d(TAG,">>RootPAServiceIfc.Stub.isSPContainerRegistered");
+ Log.d(TAG,">>RootPAServiceIfc.Stub.isSPContainerRegistered");
if(spid==null || result==null){ // 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
Log.d(TAG,"RootPAServiceIfc.Stub.isSPContainerRegistered spid "+spid+" result "+result);
@@ -171,15 +171,15 @@ public class ProvisioningService extends BaseService {
// this return code is not returned to the client since
// the command may have succeeded and there is just something wrong with the lock
// we leave it the the next command if the problem remains
- }
+ }
- Log.d(TAG,"<<RootPAServiceIfc.Stub.isSPContainerRegistered ");
+ Log.d(TAG,"<<RootPAServiceIfc.Stub.isSPContainerRegistered ");
return new CommandResult(ret);
}
public CommandResult getVersion(Version version){
- Log.d(TAG,">>RootPAServiceIfc.Stub.getVersion");
+ Log.d(TAG,">>RootPAServiceIfc.Stub.getVersion");
int internalUidForLock=new Random().nextInt();
if(!ProvisioningService.this.acquireLock(internalUidForLock, false).isOk())
@@ -196,7 +196,7 @@ public class ProvisioningService extends BaseService {
try{
ret=commonPAWrapper().getVersion(productId, keys, values);
if(ret == CommandResult.ROOTPA_OK && (keys.size() != values.size())){
- ret=CommandResult.ROOTPA_ERROR_INTERNAL;
+ ret=CommandResult.ROOTPA_ERROR_INTERNAL;
}
}catch(Exception e){
Log.e(TAG,"CommonPAWrapper().getVersion exception: ", e);
@@ -219,15 +219,15 @@ public class ProvisioningService extends BaseService {
// this return code is not returned to the client since
// the command may have succeeded and there is just something wrong with the lock
// we leave it the the next command if the problem remains
- }
+ }
- Log.d(TAG,"<<RootPAServiceIfc.Stub.getVersion "+ret);
+ Log.d(TAG,"<<RootPAServiceIfc.Stub.getVersion "+ret);
return new CommandResult(ret);
}
public CommandResult getDeviceId(SUID suid){
- Log.d(TAG,">>RootPAServiceIfc.Stub.getDeviceId");
+ Log.d(TAG,">>RootPAServiceIfc.Stub.getDeviceId");
int internalUidForLock=new Random().nextInt();
if(!ProvisioningService.this.acquireLock(internalUidForLock, false).isOk())
@@ -251,40 +251,40 @@ public class ProvisioningService extends BaseService {
// this return code is not returned to the client since
// the command may have succeeded and there is just something wrong with the lock
// we leave it the the next command if the problem remains
- }
+ }
- Log.d(TAG,"<<RootPAServiceIfc.Stub.getDeviceId");
+ Log.d(TAG,"<<RootPAServiceIfc.Stub.getDeviceId");
return new CommandResult(ret);
}
public CommandResult acquireLock(int uid){
return ProvisioningService.this.acquireLock(uid, true);
}
-
+
public CommandResult releaseLock(int uid){
return ProvisioningService.this.releaseLock(uid, true);
}
-
+
public CommandResult doProvisioning(int uid, SPID spid){
- Log.d(TAG,">>RootPAServiceIfc.Stub.doProvisioning");
+ Log.d(TAG,">>RootPAServiceIfc.Stub.doProvisioning");
int ret=CommandResult.ROOTPA_OK;
if(spid==null){ // 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
Log.d(TAG,"RootPAServiceIfc.Stub.doProvisioning spid==null");
return new CommandResult(CommandResult.ROOTPA_ERROR_ILLEGAL_ARGUMENT);
- }
-
- // we do not use uid here since we do not want to let the client to released the lock, it is done
- // internally at CommonPAWrapper.java when sending Intents.
-
+ }
+
+ // we do not use uid here since we do not want to let the client to released the lock, it is done
+ // internally at CommonPAWrapper.java when sending Intents.
+
int tmpSuid=uid+PROVISIONING_UID_FOR_LOCK+new Random().nextInt();
if(!ProvisioningService.this.acquireLock(tmpSuid, false).isOk()){
return new CommandResult(CommandResult.ROOTPA_ERROR_LOCK);
}
doProvisioningLockSuid_=tmpSuid;
-
+
try{
setupProxy();
ret=commonPAWrapper().doProvisioning(uid, spid.spid(), se_);
@@ -292,12 +292,12 @@ public class ProvisioningService extends BaseService {
Log.d(TAG,"CommonPAWrapper()).doProvisioning failed "+e);
ret=CommandResult.ROOTPA_ERROR_INTERNAL;
}
-
- Log.d(TAG,"CommonPAWrapper()).doProvisioning returned "+ret);
+
+ Log.d(TAG,"CommonPAWrapper()).doProvisioning returned "+ret);
if(ret!=CommandResult.ROOTPA_OK){
if(!ProvisioningService.this.releaseLock(doProvisioningLockSuid_, false).isOk()){
Log.e(TAG,"releasing lock failed after doProvisioning returned an error");
- }
+ }
doProvisioningLockSuid_=0;
}
@@ -306,26 +306,26 @@ public class ProvisioningService extends BaseService {
}
public CommandResult getSPContainerStructure(SPID spid, SPContainerStructure cs){
- Log.d(TAG,">>RootPAServiceIfc.Stub.getSPContainerStructure");
+ Log.d(TAG,">>RootPAServiceIfc.Stub.getSPContainerStructure");
if(spid==null||cs==null){ // 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 internalUidForLock=new Random().nextInt();
if(!ProvisioningService.this.acquireLock(internalUidForLock, false).isOk())
{
return new CommandResult(CommandResult.ROOTPA_ERROR_LOCK);
}
-
+
int ret=CommandResult.ROOTPA_OK;
final int CONTAINER_STATE_IDX=0;
- final int NUMBER_OF_TLTS_IDX=1;
+ final int NUMBER_OF_TLTS_IDX=1;
final int NUMBER_OF_ELEMENTS=2;
final int MAX_NUMBER_OF_TRUSTLETS=16;
final int UUID_LENGTH=16;
-
+
int[] ints = new int[NUMBER_OF_ELEMENTS];
int[] trustletStates = new int[MAX_NUMBER_OF_TRUSTLETS];
byte[][] uuidArray = new byte[MAX_NUMBER_OF_TRUSTLETS][];
@@ -338,15 +338,15 @@ public class ProvisioningService extends BaseService {
}
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;
+ ret=CommandResult.ROOTPA_ERROR_INTERNAL;
}
-
+
for(int i=0; i<ints[NUMBER_OF_TLTS_IDX]; i++){
- byte[] msBytes=new byte[LONG_SIZE];
+ byte[] msBytes=new byte[LONG_SIZE];
System.arraycopy(uuidArray[i], 0, msBytes, 0, LONG_SIZE);
BigInteger mostSignificant=new BigInteger(msBytes);
@@ -355,16 +355,16 @@ public class ProvisioningService extends BaseService {
BigInteger leastSignificant=new BigInteger(lsBytes);
Log.d(TAG,"UUID: ls ms"+leastSignificant+" "+mostSignificant);
-
+
TrustletContainerState ts=mapTltContainerState(trustletStates[i]);
if (ts == TrustletContainerState.UNDEFINED){
- ret=CommandResult.ROOTPA_ERROR_INTERNAL;
+ ret=CommandResult.ROOTPA_ERROR_INTERNAL;
}
cs.add(new TrustletContainer(new UUID(mostSignificant.longValue(), leastSignificant.longValue()), ts));
}
-
+
}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;
}
@@ -374,16 +374,16 @@ public class ProvisioningService extends BaseService {
// this return code is not returned to the client since
// the command may have succeeded and there is just something wrong with the lock
// we leave it the the next command if the problem remains
- }
+ }
- Log.d(TAG,"<<RootPAServiceIfc.Stub.getSPContainerStructure");
- return new CommandResult(ret);
+ Log.d(TAG,"<<RootPAServiceIfc.Stub.getSPContainerStructure");
+ return new CommandResult(ret);
}
-
+
public CommandResult getSPContainerState(SPID spid, SPContainerStateParcel state){
- Log.d(TAG,">>RootPAServiceIfc.Stub.getSPContainerState");
+ Log.d(TAG,">>RootPAServiceIfc.Stub.getSPContainerState");
if(spid==null||state==null){ // 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);
@@ -405,17 +405,17 @@ public class ProvisioningService extends BaseService {
ret=CommandResult.ROOTPA_ERROR_INTERNAL;
}
- Log.d(TAG,"RootPAServiceIfc.Stub.getSPContainerState received " + containerState[0] + " "+ ret);
-
+ Log.d(TAG,"RootPAServiceIfc.Stub.getSPContainerState received " + containerState[0] + " "+ ret);
+
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;
+ 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;
}
@@ -425,13 +425,31 @@ public class ProvisioningService extends BaseService {
// this return code is not returned to the client since
// the command may have succeeded and there is just something wrong with the lock
// we leave it the the next command if the problem remains
- }
+ }
- Log.d(TAG,"<<RootPAServiceIfc.Stub.getSPContainerState");
+ Log.d(TAG,"<<RootPAServiceIfc.Stub.getSPContainerState");
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;
@@ -449,13 +467,13 @@ public class ProvisioningService extends BaseService {
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;
}
@@ -472,17 +490,17 @@ public class ProvisioningService extends BaseService {
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;
@@ -502,10 +520,10 @@ public class ProvisioningService extends BaseService {
}
public void onDestroy(){
- super.onDestroy();
+ super.onDestroy();
Log.d(TAG,"ProvisioningService being destroyed");
}
-
+
@Override
public IBinder onBind(Intent intent){
try{
@@ -514,7 +532,7 @@ public class ProvisioningService extends BaseService {
Log.i(TAG,"ProvisioningService something wrong in the given ip "+e );
}
- try{
+ try{
Log.setLoggingLevel(intent.getIntExtra("LOG",0));
}catch(Exception e){
Log.i(TAG,"ProvisioningService something wrong in the given logging level "+e );
@@ -527,6 +545,6 @@ public class ProvisioningService extends BaseService {
@Override
public int onStartCommand(Intent i, int flags, int startid){
Log.d(TAG,"ProvisioningService starting");
- return START_STICKY;
+ return START_STICKY;
}
}
diff --git a/mobicore/rootpa/Code/Android/lib/Android.mk b/mobicore/rootpa/Code/Android/lib/Android.mk
index fed6a0d..fb893e9 100644
--- a/mobicore/rootpa/Code/Android/lib/Android.mk
+++ b/mobicore/rootpa/Code/Android/lib/Android.mk
@@ -8,10 +8,12 @@ include $(CLEAR_VARS)
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
+LOCAL_32_BIT_ONLY := true
+
include $(BUILD_STATIC_JAVA_LIBRARY) \ No newline at end of file
diff --git a/mobicore/rootpa/Code/Android/lib/NOTICE b/mobicore/rootpa/Code/Android/lib/NOTICE
new file mode 100644
index 0000000..627167a
--- /dev/null
+++ b/mobicore/rootpa/Code/Android/lib/NOTICE
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
diff --git a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/AbstractEnumParcel.java b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/AbstractEnumParcel.java
index d92948d..33cfa5b 100644
--- a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/AbstractEnumParcel.java
+++ b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/AbstractEnumParcel.java
@@ -1,74 +1,74 @@
-/*
-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;
-import android.os.Parcelable;
-
-/**
- * Abstracts some of the logic common to all parcelable facades that wrap a single enumerated value.
- */
-public abstract class AbstractEnumParcel<E extends Enum<E>> implements Parcelable {
- private E enumeratedValue;
-
- public AbstractEnumParcel() {
- }
-
- public AbstractEnumParcel(E enumeratedValue) {
- this.enumeratedValue = enumeratedValue;
- }
-
- public E getEnumeratedValue() {
- return enumeratedValue;
- }
-
- public void setEnumeratedValue(E enumeratedValue) {
- this.enumeratedValue = enumeratedValue;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- if (enumeratedValue != null){
- dest.writeString(enumeratedValue.toString());
- }
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName() + '{' + enumeratedValue + '}';
- }
-}
+/*
+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;
+import android.os.Parcelable;
+
+/**
+ * Abstracts some of the logic common to all parcelable facades that wrap a single enumerated value.
+ */
+public abstract class AbstractEnumParcel<E extends Enum<E>> implements Parcelable {
+ private E enumeratedValue;
+
+ public AbstractEnumParcel() {
+ }
+
+ public AbstractEnumParcel(E enumeratedValue) {
+ this.enumeratedValue = enumeratedValue;
+ }
+
+ public E getEnumeratedValue() {
+ return enumeratedValue;
+ }
+
+ public void setEnumeratedValue(E enumeratedValue) {
+ this.enumeratedValue = enumeratedValue;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ if (enumeratedValue != null){
+ dest.writeString(enumeratedValue.toString());
+ }
+ }
+
+ @Override
+ public String toString() {
+ return this.getClass().getSimpleName() + '{' + enumeratedValue + '}';
+ }
+}
diff --git a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/BooleanResult.aidl b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/BooleanResult.aidl
index 447a5a4..9238689 100644
--- a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/BooleanResult.aidl
+++ b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/BooleanResult.aidl
@@ -1,34 +1,34 @@
-/*
-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 © 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 BooleanResult; \ No newline at end of file
diff --git a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/BooleanResult.java b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/BooleanResult.java
index 8042d05..d1b9c65 100644
--- a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/BooleanResult.java
+++ b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/BooleanResult.java
@@ -1,94 +1,94 @@
-/*
-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.Bundle;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * An 'out' value for an AIDL method that represents a boolean value.
- */
-public class BooleanResult implements Parcelable {
- private Boolean result_;
-
- public BooleanResult() {
- }
-
- public BooleanResult(Boolean result) {
- setResult(result);
- }
-
- public Boolean result() {
- return result_;
- }
-
- public void setResult(final Boolean result) {
- if(result == null) {
- throw new IllegalStateException("Result is null!");
- }
-
- this.result_ = result;
- }
-
- //parcelable interface
-
- public static final Creator<BooleanResult> CREATOR = new Creator<BooleanResult>() {
- public BooleanResult createFromParcel(Parcel in) {
- return new BooleanResult(in);
- }
-
- public BooleanResult[] newArray(int size) {
- return new BooleanResult[size];
- }
- };
-
- private BooleanResult(Parcel in) {
- readFromParcel(in);
- }
-
- public void readFromParcel(Parcel in) {
- result_ = (in.readByte() == 1);
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- if(result_ != null){
- out.writeByte((byte) (result_ ? 1 : 0));
- }
- }
-}
+/*
+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.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * An 'out' value for an AIDL method that represents a boolean value.
+ */
+public class BooleanResult implements Parcelable {
+ private Boolean result_;
+
+ public BooleanResult() {
+ }
+
+ public BooleanResult(Boolean result) {
+ setResult(result);
+ }
+
+ public Boolean result() {
+ return result_;
+ }
+
+ public void setResult(final Boolean result) {
+ if(result == null) {
+ throw new IllegalStateException("Result is null!");
+ }
+
+ this.result_ = result;
+ }
+
+ //parcelable interface
+
+ public static final Creator<BooleanResult> CREATOR = new Creator<BooleanResult>() {
+ public BooleanResult createFromParcel(Parcel in) {
+ return new BooleanResult(in);
+ }
+
+ public BooleanResult[] newArray(int size) {
+ return new BooleanResult[size];
+ }
+ };
+
+ private BooleanResult(Parcel in) {
+ readFromParcel(in);
+ }
+
+ public void readFromParcel(Parcel in) {
+ result_ = (in.readByte() == 1);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ if(result_ != null){
+ out.writeByte((byte) (result_ ? 1 : 0));
+ }
+ }
+}
diff --git a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/CommandResult.java b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/CommandResult.java
index 606646f..34d4e8e 100644
--- a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/CommandResult.java
+++ b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/CommandResult.java
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -44,7 +44,7 @@ public class CommandResult implements Parcelable{
*/
/**
- No errors detected, successful execution
+ No errors detected, successful execution
*/
public static final int ROOTPA_OK=0x00000000;
@@ -54,7 +54,7 @@ public class CommandResult implements Parcelable{
*/
public static final int ROOTPA_COMMAND_NOT_SUPPORTED=0x00000001;
- /**
+ /**
Either rootpa is locked by another client, or the client requests lock or unlock when it is not allowed to do that.
Possible steps to recover: wait until the lock is released
*/
@@ -65,7 +65,7 @@ public class CommandResult implements Parcelable{
*/
public static final int ROOTPA_ERROR_COMMAND_EXECUTION=0x00000003;
- /**
+ /**
Registry returned an error when trying to write a container. mcDaemon could be dead or something seriously wrong in the file system.
Possible steps to recover: rebooting the device may help
*/
@@ -77,53 +77,53 @@ public class CommandResult implements Parcelable{
*/
public static final int ROOTPA_ERROR_MOBICORE_CONNECTION=0x00000005;
- /**
+ /**
Either Nwd or Swd software is out of memory.
Possible steps to recover: release memory
*/
public static final int ROOTPA_ERROR_OUT_OF_MEMORY=0x00000006;
- /**
+ /**
Rootpa internal error. This error is returned in various situations when something unexpected went wrong e.g. message from CMTL can‘t be interpreted, SE returned an error indicating invalid data, bad request or similar or base64 decoding failed
Possible steps to recover: rebooting or updating the device may help
*/
public static final int ROOTPA_ERROR_INTERNAL=0x00000007;
- /**
+ /**
Given argument is not allowed (in many cases it is NULL) or e.g. the format of xml is unsupported.
Possible steps to recover: give correct argument
*/
public static final int ROOTPA_ERROR_ILLEGAL_ARGUMENT=0x00000008;
- /**
+ /**
Error in network connection or use of networking library.
Possible steps to recover: create working network connection (avoid firewalls and proxies that require password)
*/
public static final int ROOTPA_ERROR_NETWORK=0x00000009;
- /**
+ /**
Error returned by XML library. Problems in parsing received XML command or creating new XML response.
*/
public static final int ROOTPA_ERROR_XML=0x0000000A;
- /**
+ /**
Registry returned an error when trying to read a container. Most likely the container does not exist.
*/
public static final int ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE=0x0000000B;
- /**
+ /**
CMP version of the device is not supported by SE.
Possible steps to recover: use CMP version supported by SE (>=3.0)
*/
public static final int ROOTPA_ERROR_SE_CMP_VERSION=0x0000000C;
- /**
- Precoditions for SP container installation are not met in SE.
+ /**
+ Precoditions for SP container installation are not met in SE.
Possible steps to recover: register used SPID to SE
*/
public static final int ROOTPA_ERROR_SE_PRECONDITION_NOT_MET=0x0000000D;
- /**
+ /**
Requested SP container does not exist. This is not always considered an error but is used as an informative return code. As this is internal return code, user of RootPA services should never see this.
Possible steps to recover: add SP container or request container with different SPID
*/
@@ -131,21 +131,21 @@ public class CommandResult implements Parcelable{
private int result_;
-
+
public static final Parcelable.Creator<CommandResult> CREATOR = new Parcelable.Creator<CommandResult>(){
public CommandResult createFromParcel(Parcel in){
return new CommandResult(in);
}
-
+
public CommandResult[] newArray(int size){
return null;
}
};
-
+
/**
- Constructor
+ Constructor
@param result of the command
- */
+ */
public CommandResult(int result){
result_=result;
}
@@ -156,7 +156,7 @@ public class CommandResult implements Parcelable{
/**
Constructor required by parcelable
- */
+ */
public CommandResult(Parcel in){
readFromParcel(in);
}
@@ -167,31 +167,31 @@ public class CommandResult implements Parcelable{
public void setValue(int value){
result_=value;
- }
-
+ }
+
public boolean isOk(){
return (result_==ROOTPA_OK);
}
- @Override
- public String toString() {
+ @Override
+ public String toString() {
String ret=new Integer(result_).toString();
switch(result_){
case ROOTPA_OK:
ret+=": ROOTPA_OK";
- break;
+ break;
case ROOTPA_COMMAND_NOT_SUPPORTED:
ret+=": ROOTPA_COMMAND_NOT_SUPPORTED";
- break;
+ break;
case ROOTPA_ERROR_INTERNAL:
ret+=": ROOTPA_ERROR_INTERNAL";
- break;
+ break;
case ROOTPA_ERROR_LOCK:
ret+=": ROOTPA_ERROR_LOCK";
- break;
+ break;
case ROOTPA_ERROR_ILLEGAL_ARGUMENT:
ret+=": ROOTPA_ERROR_ILLEGAL_ARGUMENT";
- break;
+ break;
case ROOTPA_ERROR_INTERNAL_NO_CONTAINER:
ret+=": ROOTPA_ERROR_INTERNAL_NO_CONTAINER";
break;
@@ -212,7 +212,7 @@ public class CommandResult implements Parcelable{
break;
case ROOTPA_ERROR_XML:
ret+=": ROOTPA_ERROR_XML";
- break;
+ break;
case ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE:
ret+=": ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE";
break;
@@ -225,16 +225,16 @@ public class CommandResult implements Parcelable{
default:
break;
}
-
+
return ret;
- }
+ }
- @Override
- public int describeContents() {
- return 0;
- }
+ @Override
+ public int describeContents() {
+ return 0;
+ }
- @Override
+ @Override
public void writeToParcel(Parcel out, int flags){
out.writeInt(result_);
}
diff --git a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/IfcVersion.java b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/IfcVersion.java
index fbba6f6..0ee6c6e 100644
--- a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/IfcVersion.java
+++ b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/IfcVersion.java
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -36,6 +36,7 @@ package com.gd.mobicore.pa.ifc;
public class IfcVersion{
- public final static int ROOTPA_ANDROID_API_VERSION_MAJOR = 1;
- public final static int ROOTPA_ANDROID_API_VERSION_MINOR=0;
+ public final static int ROOTPA_ANDROID_API_VERSION_MAJOR=1;
+ public final static int ROOTPA_ANDROID_API_VERSION_MINOR=1;
};
+
diff --git a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/README.txt b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/README.txt
deleted file mode 100644
index aae37d6..0000000
--- a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/README.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-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)
-{
diff --git a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPADeveloperIfc.aidl b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPADeveloperIfc.aidl
index 688c1bc..fd6a955 100644
--- a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPADeveloperIfc.aidl
+++ b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPADeveloperIfc.aidl
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -39,94 +39,94 @@ import com.gd.mobicore.pa.ifc.CommandResult;
/**
- * This API contains method(s) that are intended to be used for developer
- * 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
+ * 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
* 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.
- * The service is protected by permission com.gd.mobicore.pa.permission.DEVELOPER_PERMISSION with
+ * The service is started by sending intent com.gd.mobicore.pa.service.DEVELOPER_SERVICE in binding.
+ * The service is protected by permission com.gd.mobicore.pa.permission.DEVELOPER_PERMISSION with
* protectionLevel "normal"
*/
interface RootPADeveloperIfc{
/**
- * 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
+ * This method can be used for installing "developer TA" 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.
+ * 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
- * trustlet binary (in case of dynamic installation where trustletBinary is given
+ * 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
* as a parameter).
*
* There are constants related to the intents in @ref RootPAProvisioningIntents
*
* @param spid service provider id
- * @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 trustletBinary
- * or key can be given. There are sperate instructions on how the binary is to
- * 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 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 trustletBinary are exclusive, only one of
+ * @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.
+ * If the binary is already encrypted, this array must be empty. The binary
+ * has to be encrypted for transfer. Note that only either taBinary
+ * 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
+ * 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
+ * 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
* them can be given.
- * @param minTltVersion minimum version of the trustlet
+ * @param minTltVersion minimum version of the TA
* @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[] trustletBinary,
- in byte[] key,
- in int minTltVersion,
+ CommandResult installTrustletOrKey(in int spid,
+ in byte[] uuid,
+ in byte[] taBinary,
+ in byte[] key,
+ in int minTltVersion,
in byte[] tltPukHash);
-
+
/**
- * 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
+ * This method can be used for installing "developer TA" 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
- * trustlet binary.
+ * 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.
*
* There are constants related to the intents in @ref RootPAProvisioningIntents
*
* @param spid service provider id
- * @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 trustletBinary
- * or key can be given. There are sperate instructions on how the binary is to
+ * @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.
+ * If the binary is already encrypted, this array must be empty. The binary
+ * has to be encrypted for transfer. Note that only either taBinary
+ * 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 trustlet
+ * @param minTltVersion minimum version of the TA
* @param tltPukHash this field is not used at the moment, null is fine here.
- * @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,
+ * @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,
2 - external memory
- * @param numberOfInstances indicates how many instances of a trustlet can be installed (run) in parallel
+ * @param numberOfInstances indicates how many instances of a TA 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[] trustletBinary,
- in int minTltVersion,
- in byte[] tltPukHash,
- in int memoryType,
- in int numberOfInstances,
+ CommandResult installTrustlet(in int spid,
+ in byte[] uuid,
+ in byte[] taBinary,
+ in int minTltVersion,
+ in byte[] tltPukHash,
+ in int memoryType,
+ in int numberOfInstances,
in int flags);
}
diff --git a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPAProvisioningIntents.java b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPAProvisioningIntents.java
index 16fa11a..a3463d5 100644
--- a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPAProvisioningIntents.java
+++ b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPAProvisioningIntents.java
@@ -1,90 +1,90 @@
-/*
-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;
-
-/**
- * A list of intent actions that the root PA can broadcast.
- */
-public class RootPAProvisioningIntents {
-
-//
-/** Intents for starting up and connecting to services */
-//
-
- public static final String PROVISIONING_SERVICE="com.gd.mobicore.pa.service.PROVISIONING_SERVICE";
- public static final String DEVELOPER_SERVICE="com.gd.mobicore.pa.service.DEVELOPER_SERVICE";
- public static final String OEM_SERVICE="com.gd.mobicore.pa.service.OEM_SERVICE";
-
-//
-/** Execution status reporting Intents */
-//
-
-/** Provisioning is ongoing. The intent contained additional data in the integer field pointed by STATUS */
- public static final String PROVISIONING_PROGRESS_UPDATE = "com.gd.mobicore.pa.service.PROVISIONING_PROGRESS_UPDATE";
-/** root provisioning was attempted but failed - the intent will contain an error code */
- public static final String PROVISIONING_ERROR = "com.gd.mobicore.pa.service.PROVISIONING_ERROR";
-/** root provisioning has completed, root and SP containers are available for use */
- public static final String FINISHED_ROOT_PROVISIONING = "com.gd.mobicore.pa.service.PROVISIONING_FINISHED";
-
-
-/** this intent contains developer trustlet in it's extra data. The trustlet has been signed by SE */
- public static final String INSTALL_TRUSTLET = "com.gd.mobicore.pa.service.INSTALL_TRUSTLET";
-
-//
-/** Names of extra data field's for intents */
-//
-
-/** Additional state information in PROVISIONING_PROGRESS_UPDATE intent */
- public static final String STATE ="com.gd.mobicore.pa.ifc.State";
-/** Error code field in PROVISIONING_ERROR intent */
- public static final String ERROR ="com.gd.mobicore.pa.ifc.Error";
-/** Error code field in INSTALL_TRUSTLET intent */
- public static final String TRUSTLET ="com.gd.mobicore.pa.ifc.Trustlet";
-
-//
-/** possible values for STATE field */
-//
-
-/** root provisioning has started and a connection to SE is being established */
- public static final int CONNECTING_SERVICE_ENABLER=100;
- public static final int AUTHENTICATING_SOC=200;
-/** connection to SE has been established during provisioning and the root container is being created */
- public static final int CREATING_ROOT_CONTAINER=300;
- public static final int AUTHENTICATING_ROOT=400;
-/** connection to SE has been established during provisioning and the SP container is being created */
- public static final int CREATING_SP_CONTAINER=500;
- public static final int FINISHED_PROVISIONING=1000;
-/** unregistering root container will be sent by SE after OemService.unregisterRootContainer is used */
- public static final int UNREGISTERING_ROOT_CONTAINER=3000;
-
- private RootPAProvisioningIntents() { }
-}
+/*
+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;
+
+/**
+ * A list of intent actions that the root PA can broadcast.
+ */
+public class RootPAProvisioningIntents {
+
+//
+/** Intents for starting up and connecting to services */
+//
+
+ public static final String PROVISIONING_SERVICE="com.gd.mobicore.pa.service.PROVISIONING_SERVICE";
+ public static final String DEVELOPER_SERVICE="com.gd.mobicore.pa.service.DEVELOPER_SERVICE";
+ public static final String OEM_SERVICE="com.gd.mobicore.pa.service.OEM_SERVICE";
+
+//
+/** Execution status reporting Intents */
+//
+
+/** Provisioning is ongoing. The intent contained additional data in the integer field pointed by STATUS */
+ public static final String PROVISIONING_PROGRESS_UPDATE = "com.gd.mobicore.pa.service.PROVISIONING_PROGRESS_UPDATE";
+/** root provisioning was attempted but failed - the intent will contain an error code */
+ public static final String PROVISIONING_ERROR = "com.gd.mobicore.pa.service.PROVISIONING_ERROR";
+/** root provisioning has completed, root and SP containers are available for use */
+ public static final String FINISHED_ROOT_PROVISIONING = "com.gd.mobicore.pa.service.PROVISIONING_FINISHED";
+
+
+/** this intent contains developer trustlet in it's extra data. The trustlet has been signed by SE */
+ public static final String INSTALL_TRUSTLET = "com.gd.mobicore.pa.service.INSTALL_TRUSTLET";
+
+//
+/** Names of extra data field's for intents */
+//
+
+/** Additional state information in PROVISIONING_PROGRESS_UPDATE intent */
+ public static final String STATE ="com.gd.mobicore.pa.ifc.State";
+/** Error code field in PROVISIONING_ERROR intent */
+ public static final String ERROR ="com.gd.mobicore.pa.ifc.Error";
+/** Error code field in INSTALL_TRUSTLET intent */
+ public static final String TRUSTLET ="com.gd.mobicore.pa.ifc.Trustlet";
+
+//
+/** possible values for STATE field */
+//
+
+/** root provisioning has started and a connection to SE is being established */
+ public static final int CONNECTING_SERVICE_ENABLER=100;
+ public static final int AUTHENTICATING_SOC=200;
+/** connection to SE has been established during provisioning and the root container is being created */
+ public static final int CREATING_ROOT_CONTAINER=300;
+ public static final int AUTHENTICATING_ROOT=400;
+/** connection to SE has been established during provisioning and the SP container is being created */
+ public static final int CREATING_SP_CONTAINER=500;
+ public static final int FINISHED_PROVISIONING=1000;
+/** unregistering root container will be sent by SE after OemService.unregisterRootContainer is used */
+ public static final int UNREGISTERING_ROOT_CONTAINER=3000;
+
+ private RootPAProvisioningIntents() { }
+}
diff --git a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPAServiceIfc.aidl b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPAServiceIfc.aidl
index 3623f70..9db4557 100644
--- a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPAServiceIfc.aidl
+++ b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/RootPAServiceIfc.aidl
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -45,10 +45,10 @@ import com.gd.mobicore.pa.ifc.SUID;
import com.gd.mobicore.pa.ifc.SPContainerStructure;
import com.gd.mobicore.pa.ifc.SPContainerStateParcel;
-/**
-* 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.
+/**
+* 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.
*
* The service is started by sending intent com.gd.mobicore.pa.service.PROVISIONING_SERVICE in binding.
*/
@@ -56,7 +56,7 @@ interface RootPAServiceIfc {
/**
* Checks if a root container is registered.
- * Lock must not be acquired before executing this method and it can not be
+ * Lock must not be acquired before executing this method and it can not be
* acquired while this method runs.
*
* @param result true if root container exists.
@@ -66,7 +66,7 @@ interface RootPAServiceIfc {
/**
* Checks if a specific SP container is registered.
- * Lock must not be acquired before executing this method and it can not be
+ * Lock must not be acquired before executing this method and it can not be
* acquired while this method runs.
*
* @param spid SPID of the Service Provider
@@ -77,7 +77,7 @@ interface RootPAServiceIfc {
/**
* Returns the version of various components of the MobiCore OS and surrounding components.
- * Lock must not be acquired before executing this method and it can not be
+ * Lock must not be acquired before executing this method and it can not be
* acquired while this method runs.
*
* @param version the result code of the call is saved in this parameter.
@@ -87,7 +87,7 @@ interface RootPAServiceIfc {
/**
* Returns the SUID of the device.
- * Lock must not be acquired before executing this method and it can not be
+ * Lock must not be acquired before executing this method and it can not be
* acquired while this method runs.
*
* @param suid the result of the SUID is saved in this parameter.
@@ -120,9 +120,9 @@ interface RootPAServiceIfc {
* If one of the commands result in an error then the following commands are
* not executed anymore, unless the command object has "ignoreError" set true.
* A lock is required to execute this method.
- *
- * Note that this causes only excution of the CMP command(s) and reads/stores the
- * secure objects when needed. It does not initiate any discussion with Servce Enabler
+ *
+ * Note that this causes only excution of the CMP command(s) and reads/stores the
+ * secure objects when needed. It does not initiate any discussion with Servce Enabler
* or any other network component with any of CMP commands.
*
* @param uid the user id of the process which is accessing.
@@ -134,14 +134,14 @@ interface RootPAServiceIfc {
/**
* Starts provisioning. What actually happens after calling this depends on the state of the system and the commands SE sends.
- * In normal situation, SE sends commands to create root container and SP container (indicated by spid) if they do not already
+ * In normal situation, SE sends commands to create root container and SP container (indicated by spid) if they do not already
* exist. If given spid is 0, only root container is created (if it does not already exist).
* Tasks are performed asynchronously. Method returns immediately.
* Intents are broadcast to indicate the progress of the provisioning. The result is also
* sent via broadcast.
*
- * Cannot be executed if the acquireLock is called. Release any lock before calling this
- * method. Also, this command acquires lock internally before executing and releases lock
+ * Cannot be executed if the acquireLock is called. Release any lock before calling this
+ * method. Also, this command acquires lock internally before executing and releases lock
* when error occurs or provisioning is finished (just before sending FINISHED_ROOT_PROVISIONING intent) or after 1 minute timeout.
*
* The following intents are broadcast after calling doProvisioning:
@@ -159,12 +159,12 @@ interface RootPAServiceIfc {
* <li>com.gd.mobicore.pa.service.FINISHED_ROOT_PROVISIONING: Sent when the provisioning is finished.</li>
* <li>com.gd.mobicore.pa.service.PROVISIONING_ERROR: Sent when an error has occured, also contains an error code.</li>
* </ul>
- * Note that depending on the nature of th errors it is possible that more than one PROVISIONING_ERROR intents are sent
+ * Note that depending on the nature of th errors it is possible that more than one PROVISIONING_ERROR intents are sent
* before the excution of provisioning is fully stopped. This depends a lot on whether SE can still continue execution.
*
* There are constants related to the intents in @ref RootPAProvisioningIntents
- *
- * Service Enabler is contacted and asked to perform the tasks, so the device has to be connected to network
+ *
+ * Service Enabler is contacted and asked to perform the tasks, so the device has to be connected to network
* in order for this to succeed.
*
* @param uid the user id of the process which is accessing.
@@ -176,18 +176,18 @@ interface RootPAServiceIfc {
/**
* Interrogates the SP container structure.
- * Lock must not be acquired before executing this method and it can not be
+ * Lock must not be acquired before executing this method and it can not be
* 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 trustlet containers for the given SP
+ * @param cs [out] state of the sp container and a list of installed TA containers for the given SP
* @return indication of successful completion
*/
CommandResult getSPContainerStructure(in SPID spid, out SPContainerStructure cs);
/**
* Interrogates the state of an SP container.
- * Lock must not be acquired before executing this method and it can not be
+ * Lock must not be acquired before executing this method and it can not be
* acquired while this method runs.
*
* @param spid [in] service provider id to query
@@ -196,6 +196,16 @@ interface RootPAServiceIfc {
*/
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);
}
/**@}*/
diff --git a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/Version.java b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/Version.java
index d8c46ce..ac03271 100644
--- a/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/Version.java
+++ b/mobicore/rootpa/Code/Android/lib/src/com/gd/mobicore/pa/ifc/Version.java
@@ -1,119 +1,119 @@
-/*
-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.Bundle;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import java.util.Map;
-
-/**
- * Contains the device's product ID and a collection of version numbers for various software components installed on
- * the device.
- */
-public class Version implements Parcelable {
- public final static String VERSION_FIELD_TAG="TAG";
- public final static String VERSION_FIELD_TAG1ALL="TAG1ALL";
- public final static String VERSION_FIELD_MCI="MCI";
- public final static String VERSION_FIELD_SO="SO";
- public final static String VERSION_FIELD_MCLF="MCLF";
- public final static String VERSION_FIELD_CONT="CONT";
- public final static String VERSION_FIELD_MCCONF="MCCONF";
- public final static String VERSION_FIELD_TLAPI="TLAPI";
- public final static String VERSION_FIELD_DRAPI="DRAPI";
- public final static String VERSION_FIELD_CMP="CMP";
-
- private String productId_;
- private Bundle version_;
-
- public Version() {
- }
-
- public Version(String productId, Bundle version) {
- setVersion(version);
- setProductId(productId);
- }
-
- public String productId() {
- return productId_;
- }
-
- public void setProductId(String productId) {
- this.productId_ = productId;
- }
-
- public Bundle version() {
- return version_;
- }
-
- public void setVersion(Bundle version) {
- this.version_ = version;
- }
-
-//parcelable interface
-
- public static final Creator<Version> CREATOR = new Creator<Version>() {
- public Version createFromParcel(Parcel in) {
- return new Version(in);
- }
-
- public Version[] newArray(int size) {
- return new Version[size];
- }
- };
-
- private Version(Parcel in) {
- readFromParcel(in);
- }
-
- public void readFromParcel(Parcel in) {
- productId_ = in.readString();
- version_ = in.readBundle();
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- if(productId_!=null){
- out.writeString(productId_);
- }
- if(version_!=null){
- out.writeBundle(version_);
- }
- }
-
-}
+/*
+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.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Map;
+
+/**
+ * Contains the device's product ID and a collection of version numbers for various software components installed on
+ * the device.
+ */
+public class Version implements Parcelable {
+ public final static String VERSION_FIELD_TAG="TAG";
+ public final static String VERSION_FIELD_TAG1ALL="TAG1ALL";
+ public final static String VERSION_FIELD_MCI="MCI";
+ public final static String VERSION_FIELD_SO="SO";
+ public final static String VERSION_FIELD_MCLF="MCLF";
+ public final static String VERSION_FIELD_CONT="CONT";
+ public final static String VERSION_FIELD_MCCONF="MCCONF";
+ public final static String VERSION_FIELD_TLAPI="TLAPI";
+ public final static String VERSION_FIELD_DRAPI="DRAPI";
+ public final static String VERSION_FIELD_CMP="CMP";
+
+ private String productId_;
+ private Bundle version_;
+
+ public Version() {
+ }
+
+ public Version(String productId, Bundle version) {
+ setVersion(version);
+ setProductId(productId);
+ }
+
+ public String productId() {
+ return productId_;
+ }
+
+ public void setProductId(String productId) {
+ this.productId_ = productId;
+ }
+
+ public Bundle version() {
+ return version_;
+ }
+
+ public void setVersion(Bundle version) {
+ this.version_ = version;
+ }
+
+//parcelable interface
+
+ public static final Creator<Version> CREATOR = new Creator<Version>() {
+ public Version createFromParcel(Parcel in) {
+ return new Version(in);
+ }
+
+ public Version[] newArray(int size) {
+ return new Version[size];
+ }
+ };
+
+ private Version(Parcel in) {
+ readFromParcel(in);
+ }
+
+ public void readFromParcel(Parcel in) {
+ productId_ = in.readString();
+ version_ = in.readBundle();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ if(productId_!=null){
+ out.writeString(productId_);
+ }
+ if(version_!=null){
+ out.writeBundle(version_);
+ }
+ }
+
+}
diff --git a/mobicore/rootpa/Code/Android/app/jni/Common/Android.mk b/mobicore/rootpa/Code/Common/Android.mk
index 8e3d4b3..ac71006 100644
--- a/mobicore/rootpa/Code/Android/app/jni/Common/Android.mk
+++ b/mobicore/rootpa/Code/Common/Android.mk
@@ -3,35 +3,35 @@
#
# 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.
#
#
-# makefile for building the provisioning agent Common part for android. build the code by executing
+# 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.
@@ -43,22 +43,24 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS += -DANDROID_ARM=1
-LOCAL_CFLAGS += -DANDROID
+LOCAL_CFLAGS += -DANDROID
LOCAL_CFLAGS +=-fstack-protector
ifeq ($(DEBUG), 1)
LOCAL_CFLAGS += -D__DEBUG=1
-endif
+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_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
@@ -67,8 +69,9 @@ 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
+LOCAL_C_INCLUDES += external/icu4c/common
+LOCAL_C_INCLUDES += .
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
ifeq ($(ROOTPA_MODULE_TEST), 1)
LOCAL_STATIC_LIBRARIES += McStub
@@ -79,4 +82,7 @@ endif
LOCAL_MODULE_TAGS := debug eng optional
+LOCAL_32_BIT_ONLY := true
+LOCAL_STATIC_LIBRARIES += libxml2
+
include $(BUILD_STATIC_LIBRARY)
diff --git a/mobicore/rootpa/Code/Common/NOTICE b/mobicore/rootpa/Code/Common/NOTICE
new file mode 100644
index 0000000..627167a
--- /dev/null
+++ b/mobicore/rootpa/Code/Common/NOTICE
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
diff --git a/mobicore/rootpa/Code/Common/base64.c b/mobicore/rootpa/Code/Common/base64.c
index 633a62f..9535e8a 100644
--- a/mobicore/rootpa/Code/Common/base64.c
+++ b/mobicore/rootpa/Code/Common/base64.c
@@ -96,27 +96,31 @@ Decode base64 encoded NULL terminated string. If the string is not NULL terminat
*/
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;
+ int inIndex=0;
+ int outIndex=0;
+
LOGD(">> base64DecodeStringRemoveEndZero");
if(NULL==toBeDecoded) return 0;
- size_t inSize=strlen(toBeDecoded);
- size_t outSize=((inSize*PLAINSIZE)/ENCODEDSIZE)+((inSize*PLAINSIZE)%ENCODEDSIZE);
- *resultP=malloc(outSize);
+ inSize=strlen(toBeDecoded);
+ outSize=((inSize*PLAINSIZE)/ENCODEDSIZE)+((inSize*PLAINSIZE)%ENCODEDSIZE);
+ *resultP=(char *)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;
- int inIndex=0;
- int outIndex=0;
+
while( inIndex < inSize )
{
for( len = 0, i = 0; i < ENCODEDSIZE && inIndex < inSize; i++ )
@@ -180,29 +184,32 @@ base64encode data to a NULL terminated string.
*/
char* base64EncodeAddEndZero(const char* toBeEncoded, size_t length)
{
+ size_t outSize;
+ char* resultP;
+
+ unsigned char in[PLAINSIZE];
+ unsigned char out[ENCODEDSIZE];
+ int i, len;
+ int inIndex=0;
+ int outIndex=0;
+
LOGD(">> base64EncodeAddEndZero %d %s", (int) length, ((toBeEncoded!=NULL)?"ptr ok":"NULL"));
if(NULL==toBeEncoded) return NULL;
- size_t outSize=(length/PLAINSIZE + ((length%PLAINSIZE>0)?1:0))*ENCODEDSIZE+1;
+ outSize=(length/PLAINSIZE + ((length%PLAINSIZE>0)?1:0))*ENCODEDSIZE+1;
// outSize+=(outsize/LINESIZE)*2; // crlf after each full line
- char* resultP=malloc(outSize);
+ resultP=(char *) malloc(outSize);
if(resultP==NULL) return NULL;
resultP[outSize-1]=0;
- 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;
- int inIndex=0;
- int outIndex=0;
while( inIndex < length )
{
len = 0;
diff --git a/mobicore/rootpa/Code/Common/commandhandler.c b/mobicore/rootpa/Code/Common/commandhandler.c
index 6d6158c..44da5bc 100644
--- a/mobicore/rootpa/Code/Common/commandhandler.c
+++ b/mobicore/rootpa/Code/Common/commandhandler.c
@@ -3,41 +3,47 @@ Copyright © Trustonic Limited 2013
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 <string.h>
#include <stdlib.h>
-#include <pthread.h>
+
+#include <wrapper.h>
+#ifdef WIN32
+ #include <windows.h>
+#else
+ #include <pthread.h>
+#endif
#include <TlCm/3.0/tlCmApi.h>
#include <MobiCoreDriverApi.h>
#include "rootpaErrors.h"
#include "logging.h"
-#include "provisioningagent.h"
+#include "provisioningagent.h"
#include "registry.h"
#include "contentmanager.h"
#include "provisioningengine.h"
@@ -51,12 +57,10 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
/*
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()
@@ -71,32 +75,32 @@ void closeSessionToCmtl()
rootpaerror_t getVersion(int* tag, mcVersionInfo_t* versionP)
{
- LOGD(">>getVersion");
rootpaerror_t ret=ROOTPA_OK;
- uint32_t internalError=0;
- CmpMessage command;
+ 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=malloc(GET_VERSION_COMMAND_LENGTH);
+ command.contentP=(uint8_t*)malloc(GET_VERSION_COMMAND_LENGTH);
if(!command.contentP)
{
return ROOTPA_ERROR_OUT_OF_MEMORY;
}
-
+
*((uint32_t*)command.contentP)=MC_CMP_CMD_GET_VERSION;
command.hdr.ignoreError=false;
-
+
ret=executeContentManagementCommands(1, &command, &response, &internalError);
if(ROOTPA_OK==ret && 0 == internalError)
{
if(response.length != sizeof(cmpRspGetVersion_t))
{
- ret=ROOTPA_ERROR_INTERNAL;
+ ret=ROOTPA_ERROR_INTERNAL;
}
else
{
@@ -115,7 +119,7 @@ rootpaerror_t getVersion(int* tag, mcVersionInfo_t* versionP)
}
else
{
- LOGE("getVersion, ERROR %d %d", ret, internalError);
+ LOGE("getVersion, ERROR %d %d", ret, internalError);
}
free(response.contentP);
free(command.contentP);
@@ -125,32 +129,32 @@ rootpaerror_t getVersion(int* tag, mcVersionInfo_t* versionP)
rootpaerror_t getSuid(mcSuid_t* suidP)
{
- LOGD(">>getSuid");
rootpaerror_t ret=ROOTPA_OK;
- uint32_t internalError=0;
- CmpMessage command;
+ 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=malloc(GET_SUID_COMMAND_LENGTH);
+ command.contentP=(uint8_t*)malloc(GET_SUID_COMMAND_LENGTH);
if(!command.contentP)
{
return ROOTPA_ERROR_OUT_OF_MEMORY;
}
-
+
*((uint32_t*)command.contentP)=MC_CMP_CMD_GET_SUID;
command.hdr.ignoreError=false;
-
+
ret=executeContentManagementCommands(1, &command, &response, &internalError);
if(ROOTPA_OK==ret && 0 == internalError)
{
if(response.length != sizeof(cmpRspGetSuid_t))
{
- ret=ROOTPA_ERROR_INTERNAL;
+ ret=ROOTPA_ERROR_INTERNAL;
}
else
{
@@ -165,36 +169,36 @@ rootpaerror_t getSuid(mcSuid_t* suidP)
rootpaerror_t isRootContainerRegistered(bool* isRegisteredP)
{
- LOGD(">>isRootContainerRegistered");
rootpaerror_t ret=ROOTPA_OK;
-
- if(NULL==isRegisteredP) return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
-
ROOTCONTAINERP rootContP=NULL;
uint32_t rootContSize=0;
- mcResult_t result=regReadRoot(&rootContP, &rootContSize);
+ mcResult_t result;
+ LOGD(">>isRootContainerRegistered");
+ if(NULL==isRegisteredP) return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
+
+ result=regReadRoot(&rootContP, &rootContSize);
if(MC_DRV_OK == result)
{
if(rootContP->cont.attribs.state != MC_CONT_STATE_UNREGISTERED)
{
*isRegisteredP=true;
- }
+ }
else
{
- *isRegisteredP=false;
+ *isRegisteredP=false;
}
-
+
}
else if(MC_DRV_ERR_INVALID_DEVICE_FILE == result)
{
- *isRegisteredP=false;
+ *isRegisteredP=false;
}
else
{
ret=ROOTPA_ERROR_REGISTRY;
}
-
+
free(rootContP);
LOGD("<<isRootContainerRegistered %d", *isRegisteredP);
@@ -203,14 +207,14 @@ rootpaerror_t isRootContainerRegistered(bool* isRegisteredP)
rootpaerror_t isSpContainerRegistered(mcSpid_t spid, bool* isRegisteredP)
{
- LOGD(">>isSpContainerRegistered");
rootpaerror_t ret=ROOTPA_OK;
+ int state;
+ LOGD(">>isSpContainerRegistered");
if(NULL==isRegisteredP) return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
- int state;
- ret=getSpContainerState(spid, &state);
-
+ ret=getSpContainerState(spid, (mcContainerState_t*)&state);
+
if(ROOTPA_OK == ret)
{
if(state != MC_CONT_STATE_UNREGISTERED)
@@ -219,7 +223,7 @@ rootpaerror_t isSpContainerRegistered(mcSpid_t spid, bool* isRegisteredP)
}
else
{
- *isRegisteredP=false;
+ *isRegisteredP=false;
}
}
else if(ROOTPA_ERROR_INTERNAL_NO_CONTAINER == ret)
@@ -227,7 +231,7 @@ rootpaerror_t isSpContainerRegistered(mcSpid_t spid, bool* isRegisteredP)
*isRegisteredP=false;
ret=ROOTPA_OK;
}
-
+
LOGD("<<isSpContainerRegistered %d", *isRegisteredP);
return ret;
}
@@ -235,13 +239,14 @@ rootpaerror_t isSpContainerRegistered(mcSpid_t spid, bool* isRegisteredP)
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;
- mcResult_t result=regGetSpState(spid, stateP);
-
+ result=regGetSpState(spid, stateP);
+
if(MC_DRV_ERR_INVALID_DEVICE_FILE == result)
{
ret=ROOTPA_ERROR_INTERNAL_NO_CONTAINER; // using this since it is changed to ROOTPA_OK and state NO_CONTAINER in the wrapper.
@@ -262,29 +267,30 @@ bool containerExists(mcUuid_t uuid)
rootpaerror_t getSpContainerStructure(mcSpid_t spid, SpContainerStructure* spContainerStructure)
{
- LOGD(">>getSpContainerStructure");
rootpaerror_t ret=ROOTPA_OK;
-
+ SPCONTAINERP spP=NULL;
+ uint32_t spContSize=0;
+ mcResult_t result;
+ int i;
+ TLTCONTAINERP tltP=NULL;
+ LOGD(">>getSpContainerStructure");
+
if(NULL==spContainerStructure) return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
memset(spContainerStructure, 0xFF, sizeof(SpContainerStructure));
- spContainerStructure->nbrOfTlts=0;
-
- SPCONTAINERP spP=NULL;
- uint32_t spContSize=0;
- mcResult_t result=regReadSp(spid, &spP, &spContSize);
+ spContainerStructure->nbrOfTlts=0;
+ 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;
@@ -309,16 +315,48 @@ rootpaerror_t getSpContainerStructure(mcSpid_t spid, SpContainerStructure* spCo
{
ret=ROOTPA_ERROR_INTERNAL_NO_CONTAINER; // using this since it is changed to ROOTPA_OK and state NO_CONTAINER in the wrapper.
}
- else
+ else
{
ret=ROOTPA_ERROR_REGISTRY;
}
-
+
free(spP);
LOGD("<<getSpContainerStructure nr: %d st: %d ret: %d",spContainerStructure->nbrOfTlts, spContainerStructure->state, ret );
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)
{
LOGD("dummy callback %d %d %ld", state, error, (long int) tltInfoP);
@@ -327,7 +365,7 @@ void dummyCallback(ProvisioningState state, rootpaerror_t error, tltInfo_t* tltI
rootpaerror_t dummySysInfoCallback(osInfo_t* osSpecificInfoP)
{
LOGD("dummy sysinfo callback %ld", (long int) osSpecificInfoP);
- if(NULL==osSpecificInfoP) return ROOTPA_ERROR_INTERNAL;
+ if(NULL==osSpecificInfoP) return ROOTPA_ERROR_INTERNAL;
memset(osSpecificInfoP, 0, sizeof(osInfo_t));
return ROOTPA_OK;
}
@@ -340,17 +378,19 @@ typedef struct{
initialRel_t initialRel;
trustletInstallationData_t* tltInstallationDataP;
} provisioningparams_t;
-
-void* provisioningThreadFunction(void* paramsP)
+#ifdef WIN32
+ void* WINAPI provisioningThreadFunction(void* paramsP)
+#else
+ void* provisioningThreadFunction(void* paramsP)
+#endif
{
- LOGD(">>provisioningThreadFunction %ld", (long int)((provisioningparams_t*)paramsP)->callbackP);
-
rootpaerror_t ret=ROOTPA_OK;
+ LOGD(">>provisioningThreadFunction %ld", (long int)((provisioningparams_t*)paramsP)->callbackP);
if((ret=openCmtlSession())==ROOTPA_OK)
{
- doProvisioningWithSe(((provisioningparams_t*)paramsP)->spid,
- ((provisioningparams_t*)paramsP)->suid,
- ((provisioningparams_t*)paramsP)->callbackP,
+ doProvisioningWithSe(((provisioningparams_t*)paramsP)->spid,
+ ((provisioningparams_t*)paramsP)->suid,
+ ((provisioningparams_t*)paramsP)->callbackP,
((provisioningparams_t*)paramsP)->sysInfoCallbackP,
getVersion,
((provisioningparams_t*)paramsP)->initialRel,
@@ -359,7 +399,7 @@ void* provisioningThreadFunction(void* paramsP)
}
else
{
- ((provisioningparams_t*)paramsP)->callbackP(ERROR, ret, NULL);
+ ((provisioningparams_t*)paramsP)->callbackP(ERROR_STATE, ret, NULL);
LOGE("provisioningThreadFunction: was not able to open session %d", ret);
}
@@ -373,29 +413,39 @@ void* provisioningThreadFunction(void* paramsP)
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;
- provisioningparams_t* paramsP=malloc(sizeof(provisioningparams_t));
+ paramsP=(provisioningparams_t*)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->callbackP=callbackP;
paramsP->sysInfoCallbackP=systemInfoCallbackP;
paramsP->spid=spid;
if(tltDataP)
{
- // Coverity complains that paramsP allocated here is not freed. It is done in "provisioningThreadFunction"
- paramsP->tltInstallationDataP=malloc(sizeof(trustletInstallationData_t));
+ // Coverity complains that paramsP allocated here is not freed. It is done in "provisioningThreadFunction"
+ paramsP->tltInstallationDataP=(trustletInstallationData_t*)malloc(sizeof(trustletInstallationData_t));
if(!paramsP->tltInstallationDataP)
{
free(paramsP);
@@ -403,13 +453,13 @@ rootpaerror_t provision(mcSpid_t spid, CallbackFunctionP callbackP, SystemInfoCa
}
// copy the whole struct
-
+
memset(paramsP->tltInstallationDataP,0,sizeof(trustletInstallationData_t)); // initialize in order to satisfy valgrind
memcpy(paramsP->tltInstallationDataP, tltDataP, sizeof(trustletInstallationData_t));
// malloc and copy data from/to the pointers
-
- paramsP->tltInstallationDataP->dataP=malloc(tltDataP->dataLength);
+
+ paramsP->tltInstallationDataP->dataP=(const uint8_t *)malloc(tltDataP->dataLength);
if(!paramsP->tltInstallationDataP->dataP)
{
free(paramsP->tltInstallationDataP);
@@ -419,30 +469,39 @@ rootpaerror_t provision(mcSpid_t spid, CallbackFunctionP callbackP, SystemInfoCa
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=malloc(tltDataP->tltPukHashLength);
+ paramsP->tltInstallationDataP->tltPukHashP=(const uint8_t *)malloc(tltDataP->tltPukHashLength);
if(!paramsP->tltInstallationDataP->tltPukHashP)
{
free((void*) paramsP->tltInstallationDataP->dataP);
free((void*) paramsP->tltInstallationDataP);
free(paramsP);
return ROOTPA_ERROR_OUT_OF_MEMORY;
- }
+ }
memset((char*)paramsP->tltInstallationDataP->tltPukHashP,0,tltDataP->tltPukHashLength); // initialize in order to satisfy valgrind
memcpy((char*)paramsP->tltInstallationDataP->tltPukHashP, tltDataP->tltPukHashP, tltDataP->tltPukHashLength);
}
else
{
- paramsP->tltInstallationDataP=NULL;
+ paramsP->tltInstallationDataP=NULL;
}
paramsP->initialRel = initialRel;
-
- rootpaerror_t ret=ROOTPA_OK;
+
+ ret=ROOTPA_OK;
ret=getSuid(&paramsP->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;
@@ -453,13 +512,13 @@ rootpaerror_t provision(mcSpid_t spid, CallbackFunctionP callbackP, SystemInfoCa
ret=ROOTPA_ERROR_INTERNAL;
}
else
- {
+ {
r=pthread_attr_setdetachstate(&attributes, PTHREAD_CREATE_DETACHED);
if(r)
{
LOGE("unable to set detached state, trying with defaults %d",r);
}
-
+
r=pthread_create(&provisioningThread, &attributes, provisioningThreadFunction, (void*) paramsP);
if(r)
{
@@ -469,10 +528,11 @@ rootpaerror_t provision(mcSpid_t spid, CallbackFunctionP callbackP, SystemInfoCa
}
pthread_attr_destroy(&attributes);
}
+#endif
}
else
{
- LOGE("provisioning can not get suid: %d",ret );
+ LOGE("provisioning can not get suid: %d",ret );
}
LOGD("<<provision ret: %d",ret );
return ret;
@@ -486,7 +546,7 @@ rootpaerror_t doProvisioning(mcSpid_t spid, CallbackFunctionP callbackP, SystemI
rootpaerror_t installTrustlet(mcSpid_t spid, CallbackFunctionP callbackP, SystemInfoCallbackFunctionP systemInfoCallbackP, trustletInstallationData_t* tltDataP)
{
- if(NULL == tltDataP || NULL == tltDataP->dataP || 0 == tltDataP->dataLength||
+ if(NULL == tltDataP || NULL == tltDataP->dataP || 0 == tltDataP->dataLength||
(REQUEST_DATA_TLT != tltDataP->dataType && REQUEST_DATA_KEY != tltDataP->dataType)) return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
LOGD("installTrustlet");
return provision(spid, callbackP, systemInfoCallbackP, tltDataP, initialRel_POST);
@@ -505,9 +565,10 @@ void setPaths(const char* storageDirP, const char* certDirP)
rootpaerror_t unregisterRootContainer(CallbackFunctionP callbackP, SystemInfoCallbackFunctionP systemInfoCallbackP)
{
- LOGD("unregisterRootContainer");
-
mcSpid_t spid;
+ LOGD("unregisterRootContainer");
memset(&spid, 0x0, sizeof(mcSpid_t));
return provision(spid, callbackP, systemInfoCallbackP, NULL, initialRel_DELETE);
}
+
+
diff --git a/mobicore/rootpa/Code/Common/contentmanager.c b/mobicore/rootpa/Code/Common/contentmanager.c
index 21ab9f4..2f3c029 100644
--- a/mobicore/rootpa/Code/Common/contentmanager.c
+++ b/mobicore/rootpa/Code/Common/contentmanager.c
@@ -78,10 +78,11 @@ rootpaerror_t executeOneCmpCommand(CMTHANDLE handle, CmpMessage* commandP, CmpMe
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;
@@ -93,7 +94,7 @@ rootpaerror_t executeContentManagementCommands(int numberOfCommands, CmpMessage*
ret=openCmtlSession();
selfOpened=true;
}
- CMTHANDLE handle=handle_;
+ handle=handle_;
if (handle)
{
@@ -158,18 +159,22 @@ rootpaerror_t executeContentManagementCommands(int numberOfCommands, CmpMessage*
*/
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))))
{
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;
}
- mcResult_t mcRet=MC_DRV_OK;
- cmpCommandId_t commandId=getCmpCommandId(commandP->contentP);
+ mcRet=MC_DRV_OK;
+ commandId=getCmpCommandId(commandP->contentP);
handle->mappedSize=getTotalMappedBufferSize(commandP);
if(0==handle->mappedSize)
@@ -178,10 +183,10 @@ rootpaerror_t executeOneCmpCommand(CMTHANDLE handle, CmpMessage* commandP, CmpMe
return ROOTPA_COMMAND_NOT_SUPPORTED;
}
- rootpaerror_t ret=ROOTPA_OK;
+ ret=ROOTPA_OK;
while(true)
{
- handle->mappedP=malloc((size_t) handle->mappedSize);
+ handle->mappedP=(uint8_t*)malloc((size_t) handle->mappedSize);
if(NULL==handle->mappedP)
{
ret=ROOTPA_ERROR_OUT_OF_MEMORY;
@@ -212,7 +217,7 @@ rootpaerror_t executeOneCmpCommand(CMTHANDLE handle, CmpMessage* commandP, CmpMe
break;
}
- uint32_t neededBytes=getNeededBytesFromResponse(handle->wsmP);
+ neededBytes=getNeededBytesFromResponse(handle->wsmP);
if(0==neededBytes)
{
diff --git a/mobicore/rootpa/Code/Common/enrollmentservicexmlschema.h b/mobicore/rootpa/Code/Common/enrollmentservicexmlschema.h
index 648e5c6..943f8ed 100644
--- a/mobicore/rootpa/Code/Common/enrollmentservicexmlschema.h
+++ b/mobicore/rootpa/Code/Common/enrollmentservicexmlschema.h
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -92,7 +92,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<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\" /> \
diff --git a/mobicore/rootpa/Code/Common/include/logging.h b/mobicore/rootpa/Code/Common/include/logging.h
index 0b2f28b..35f51e3 100644
--- a/mobicore/rootpa/Code/Common/include/logging.h
+++ b/mobicore/rootpa/Code/Common/include/logging.h
@@ -45,16 +45,49 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
#define LOGD(scite ...)
#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, ...) printf(fmt "\n", ##__VA_ARGS__)
+ #define LOGD(fmt, ...) MyOutputFunction(fmt "\n", ##__VA_ARGS__)
#else
#define LOGD(fmt, ...)
- #endif
+ #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
+#else
+ #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
+ #define LOGD(fmt, ...)
+ #endif
+#endif // WIN32
+#endif // ANDROID
#endif // LOGGING_H
diff --git a/mobicore/rootpa/Code/Common/include/provisioningagent.h b/mobicore/rootpa/Code/Common/include/provisioningagent.h
index 4750528..97553bd 100644
--- a/mobicore/rootpa/Code/Common/include/provisioningagent.h
+++ b/mobicore/rootpa/Code/Common/include/provisioningagent.h
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -36,7 +36,7 @@ extern "C" {
#endif
-#include <stdbool.h>
+#include <wrapper.h>
#include <TlCm/3.0/cmp.h>
#include <mcVersionInfo.h>
@@ -44,9 +44,9 @@ extern "C" {
#include "rootpa.h"
/**
-since the CMP commands that require authentication need to be executed during
-the same session the actual authentication, the client needs to handle opening
-and closing the session before
+since the CMP commands that require authentication need to be executed during
+the same session the actual authentication, the client needs to handle opening
+and closing the session before
*/
rootpaerror_t openSessionToCmtl();
void closeSessionToCmtl();
@@ -54,21 +54,21 @@ void closeSessionToCmtl();
/**
Executes all given content management protocol commands in the order they are given and returns response to all of them.
-The calling operating system specific part has to take care that no other calls are executed before
+The calling operating system specific part has to take care that no other calls are executed before
executeCmpCommands has exited.
-@param numberOfCommands number of commands given in this request. The array of
- commands and responses must be allocated with the same
+@param numberOfCommands number of commands given in this request. The array of
+ commands and responses must be allocated with the same
number of CmpMessage structs.
@param commandsP an array of commands to be executed. The commands will be executed in the given order.
-@param responsesP an array of responses that have to be empty when the call is made.
- Memory for the responses need to be freed (with free) by the caller,
+@param responsesP an array of responses that have to be empty when the call is made.
+ Memory for the responses need to be freed (with free) by the caller,
after the call.
@param internalError if returning an error, rootPA copies here error code it received from Cmtl or MC.
-@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful.
- Note that when ROOTPA_ERROR_COMMAND_EXECUTION is returned, execution of some of the commands
- may have been successful. The status of individual commands can be checked from the actual
- content of the individual response.
+@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful.
+ Note that when ROOTPA_ERROR_COMMAND_EXECUTION is returned, execution of some of the commands
+ may have been successful. The status of individual commands can be checked from the actual
+ content of the individual response.
*/
rootpaerror_t executeCmpCommands(int numberOfCommands, CmpMessage* commandsP, CmpMessage* responsesP, uint32_t* internalError);
@@ -76,14 +76,14 @@ rootpaerror_t executeCmpCommands(int numberOfCommands, CmpMessage* commandsP, Cm
/**
Obtains and returns version information from CMTL
-The calling operating system specific part has to take care that no other calls are executed before
+The calling operating system specific part has to take care that no other calls are executed before
the command has exited.
@param tag version of the version. See mcVersionInfo_t for more information.
-@param versionP version information. In case version info tag is 1, the version
+@param versionP version information. In case version info tag is 1, the version
is written in the first four bytes of mcVersionInfo_t.productId
-@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful.
+@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful.
*/
rootpaerror_t getVersion(int* tag, mcVersionInfo_t* versionP);
@@ -91,11 +91,11 @@ rootpaerror_t getVersion(int* tag, mcVersionInfo_t* versionP);
/**
Returns SUID
-The calling operating system specific part has to take care that no other calls are executed before
+The calling operating system specific part has to take care that no other calls are executed before
the command has exited.
@param suidP pointer to the emory area where the suid is copied to
-@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful.
+@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful.
*/
rootpaerror_t getSuid(mcSuid_t* suidP);
@@ -103,7 +103,7 @@ rootpaerror_t getSuid(mcSuid_t* suidP);
/**
@param isRegisteredP writes here true if the container is registered, false otherwise
-@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful.
+@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful.
*/
rootpaerror_t isRootContainerRegistered(bool* isRegisteredP);
@@ -113,7 +113,7 @@ rootpaerror_t isRootContainerRegistered(bool* isRegisteredP);
@param spid service provider id
@param isRegisteredP writes here true if the container is registered, false otherwise
-@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful.
+@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful.
*/
rootpaerror_t isSpContainerRegistered(mcSpid_t spid, bool* isRegisteredP);
@@ -124,7 +124,7 @@ rootpaerror_t isSpContainerRegistered(mcSpid_t spid, bool* isRegisteredP);
@param spid service provider id
@param stateP writes here the state of the container
@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful,
- ROOTPA_ERROR_INTERNAL_NO_CONTAINER if the container does not exist.
+ ROOTPA_ERROR_INTERNAL_NO_CONTAINER if the container does not exist.
*/
rootpaerror_t getSpContainerState(mcSpid_t spid, mcContainerState_t* stateP);
@@ -135,62 +135,62 @@ rootpaerror_t getSpContainerState(mcSpid_t spid, mcContainerState_t* stateP);
@param spid service provider id
@param spContainerStructureP writes here the structure of the container. The structure must be allocated before the call.
@return one of the return values defined in rootpaErrors.h ROOTPA_OK in case the call is successful,
- ROOTPA_ERROR_INTERNAL_NO_CONTAINER if the container does not exist.
+ ROOTPA_ERROR_INTERNAL_NO_CONTAINER if the container does not exist.
*/
rootpaerror_t getSpContainerStructure(mcSpid_t spid, SpContainerStructure* spContainerStructureP);
/**
-Creates a thread and returns, the thread contacts SE and executes the commands received from SE.
+Creates a thread and returns, the thread contacts SE and executes the commands received from SE.
-The state of the execution is informed in the calls to callback. The last callback, just before
+The state of the execution is informed in the calls to callback. The last callback, just before
the thread exits contains always state PROVISIONING_STATE_THREAD_EXITING.
-The calling operating system specific part has to take care that no other calls are executed before
+The calling operating system specific part has to take care that no other calls are executed before
doProvisioning and the actual provisioining thread have exited.
@param spid service provider id
-@param callbackP callback function that handles information delivery to operating system specific client.
- This is called at different states of provisioining (see type ProvisioningState to find out more
- about the states). Since doProvisioining executes it's own thread the callback function has to be
+@param callbackP callback function that handles information delivery to operating system specific client.
+ This is called at different states of provisioining (see type ProvisioningState to find out more
+ about the states). Since doProvisioining executes it's own thread the callback function has to be
thread safe.
-@param systemInfoCallbackP pointer to a function that can provide RootPA system information
- that is only available in the operting system specific part. Since doProvisioining executes it's own thread the
+@param systemInfoCallbackP pointer to a function that can provide RootPA system information
+ that is only available in the operting system specific part. Since doProvisioining executes it's own thread the
callback function has to be thread safe.
-@return ROOTPA_OK on success and and error code if thread creation fails. The results of actual execution of
+@return ROOTPA_OK on success and and error code if thread creation fails. The results of actual execution of
the provisioining are returned in the callback functions.
*/
rootpaerror_t doProvisioning(mcSpid_t spid, CallbackFunctionP callbackP, SystemInfoCallbackFunctionP systemInfoCallbackP);
/**
-Creates a thread and returns, the thread contacts SE and executes the commands received from SE.
+Creates a thread and returns, the thread contacts SE and executes the commands received from SE.
This is similar to do provisioning but takes in information on trustlet to be installed and asks SE
to "install the trustlet". This is used for testing and developer trustlet installation.
-The state of the execution is informed in the calls to callback. The last callback, just before
+The state of the execution is informed in the calls to callback. The last callback, just before
the thread exits contains always state PROVISIONING_STATE_THREAD_EXITING.
-The calling operating system specific part has to take care that no other calls are executed before
+The calling operating system specific part has to take care that no other calls are executed before
doProvisioning and the actual provisioining thread have exited.
@param spid service provider id
-@param callbackP callback function that handles information delivery to operating system specific client.
- This is called at different states of provisioining (see type ProvisioningState to find out more
- about the states). Since doProvisioining executes it's own thread the callback function has to be
+@param callbackP callback function that handles information delivery to operating system specific client.
+ This is called at different states of provisioining (see type ProvisioningState to find out more
+ about the states). Since doProvisioining executes it's own thread the callback function has to be
thread safe.
-@param systemInfoCallbackP pointer to a function that can provide RootPA system information
- that is only available in the operting system specific part. Since doProvisioining executes it's own thread the
+@param systemInfoCallbackP pointer to a function that can provide RootPA system information
+ that is only available in the operting system specific part. Since doProvisioining executes it's own thread the
callback function has to be thread safe.
@param dataP pointer to the data needed in trutlet installation
-@return ROOTPA_OK on success and and error code if thread creation fails. ROOTPA_ERROR_ILLEGAL_ARGUMENT if dataP is NULL.
+@return ROOTPA_OK on success and and error code if thread creation fails. ROOTPA_ERROR_ILLEGAL_ARGUMENT if dataP is NULL.
The results of actual execution of the provisioining are returned in the callback functions.
*/
rootpaerror_t installTrustlet(mcSpid_t spid, CallbackFunctionP callbackP, SystemInfoCallbackFunctionP systemInfoCallbackP, trustletInstallationData_t* dataP);
@@ -212,8 +212,21 @@ This is helper function for unregistering root container.
*/
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
+This is helper function for the platform dependent part to inform the platform independent part
on the file storage location
@param storageDirP NULL terminated char array containing the path to the storage location
@@ -224,9 +237,9 @@ on the file storage location
void setPaths(const char* storageDirP, const char* certDirP);
/**
-This is helper function for setting SE address.
+This is helper function for setting SE address.
-@param addrP pointer to the address, it can but does not need to be null terminated. The address needs
+@param addrP pointer to the address, it can but does not need to be null terminated. The address needs
to begin with "http(s)://" and end with "/".
@param length length of the address
@return ROOTPA_OK is setting succeeded, an error code otherwise
@@ -234,7 +247,7 @@ This is helper function for setting SE address.
rootpaerror_t setSeAddress(const char* addrP, uint32_t length);
#ifdef __cplusplus
-}
+}
#endif
#endif // PROVISIONINGAGENT_H
diff --git a/mobicore/rootpa/Code/Common/include/rootpa.h b/mobicore/rootpa/Code/Common/include/rootpa.h
index 23f8ffe..ce293e5 100644
--- a/mobicore/rootpa/Code/Common/include/rootpa.h
+++ b/mobicore/rootpa/Code/Common/include/rootpa.h
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -35,7 +35,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
extern "C" {
#endif
-#include <stdbool.h>
+#include <wrapper.h>
#include <mcUuid.h>
#include <mcContainer.h>
@@ -50,15 +50,15 @@ typedef enum {
AUTHENTICATING_ROOT=4,
CREATING_SP_CONTAINER=5,
FINISHED_PROVISIONING=6,
- ERROR=7,
+ ERROR_STATE=7,
UNREGISTERING_ROOT_CONTAINER=8,
PROVISIONING_STATE_INSTALL_TRUSTLET=0xFEED,
PROVISIONING_STATE_THREAD_EXITING=0xDEAD
} ProvisioningState;
-typedef struct
+typedef struct
{
- char* imeiEsnP; // IMEI or ESN (CDMA) code
+ char* imeiEsnP; // IMEI or ESN (CDMA) code
char* mnoP; // network operator (based on the SIM card, not current network)
char* brandP;
char* manufacturerP;
@@ -74,15 +74,15 @@ typedef struct
} tltInfo_t;
/**
- callback function that has to be imlemented in the os specific wrapper. RootPA calls this at various stages of
- provisioning, depending on the messages sent by SE. Note that PROVISIONING_STATE_THREAD_EXITING is always the
+ callback function that has to be imlemented in the os specific wrapper. RootPA calls this at various stages of
+ provisioning, depending on the messages sent by SE. Note that PROVISIONING_STATE_THREAD_EXITING is always the
last state, even if errors are retrned beforehand. This alows the wrapper to perform necessary cleanup actions
just before the provisioning thread exists
@param st state of the provisioning
@param err in case the state is ERROR, this field contains error code, otherwise the value is indetermined
- @param tltInfo, in case the state is PROVISIONING_STATE_INSTALL_TRUSTLET this field contains information on
- the trustlet to be installed. The callback function has to copy the trustlet before it returns.
+ @param tltInfo, in case the state is PROVISIONING_STATE_INSTALL_TRUSTLET this field contains information on
+ the trustlet to be installed. The callback function has to copy the trustlet before it returns.
In other states the field is NULL.
*/
typedef void (*CallbackFunctionP)(ProvisioningState st, rootpaerror_t err, tltInfo_t* tltInfo);
@@ -90,7 +90,7 @@ typedef void (*CallbackFunctionP)(ProvisioningState st, rootpaerror_t err, tltIn
/**
callback function for RootPA to get information on the device. The os specific part needs to reserve the memory
to the pointers of osInfo_t with malloc, RootPA the frees it when it does not need it anymore. Possible memory
- allocation and relase for the actual osInfo_t struct is in the hands of the wrapper.
+ allocation and relase for the actual osInfo_t struct is in the hands of the wrapper.
*/
typedef rootpaerror_t (*SystemInfoCallbackFunctionP)(osInfo_t* );
@@ -144,35 +144,35 @@ typedef struct
{
/**
UUID of the trustlet container
- */
+ */
mcUuid_t uuid;
/**
state of the trustlet container
- */
- int state;
+ */
+ int state;
} TltContainerData;
typedef struct
{
/**
state of the servce provider container
- */
+ */
int state;
/**
number of trustlets in the container
- */
+ */
int nbrOfTlts;
/**
array of trustlet containers in the service provider container. Only the number of elements indicated in nbrOfTlts are set.
- */
+ */
TltContainerData tltContainers[MC_CONT_CHILDREN_COUNT];
} SpContainerStructure;
typedef enum {
- REQUEST_DATA_NO_DATA=0,
+ REQUEST_DATA_NO_DATA=0,
REQUEST_DATA_TLT=1,
REQUEST_DATA_KEY=2
}TltInstallationRequestDataType;
@@ -181,7 +181,7 @@ typedef struct {
/**
pointer to either the trustlet binary or encryption key, depending on the request type
*/
- const uint8_t* dataP;
+ const uint8_t* dataP;
/**
length of the data pointed by the pointer
*/
@@ -194,7 +194,7 @@ typedef struct {
uuid of the trustlet
*/
mcUuid_t uuid;
-
+
/**
minimum version of the trustlet
*/
@@ -211,9 +211,9 @@ typedef struct {
uint32_t tltPukHashLength;
/**
- 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,
+ 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
*/
uint32_t memoryType;
@@ -222,16 +222,16 @@ typedef struct {
indicates how many instances of a trustlet can be installed (run) in parallel
*/
uint32_t numberOfInstances;
-
+
/**
current flags are: 1 - permanent, 2 - service has no WSW control interface, 4 - debuggable
*/
uint32_t flags;
-
+
}trustletInstallationData_t;
#ifdef __cplusplus
-}
+}
#endif
#endif // ROOTPA_H
diff --git a/mobicore/rootpa/Code/Common/include/rootpaErrors.h b/mobicore/rootpa/Code/Common/include/rootpaErrors.h
index 4dff37e..7d98755 100644
--- a/mobicore/rootpa/Code/Common/include/rootpaErrors.h
+++ b/mobicore/rootpa/Code/Common/include/rootpaErrors.h
@@ -3,36 +3,36 @@ Copyright © Trustonic Limited 2013
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.
*/
#ifndef ROOTPAERRORS_H
#define ROOTPAERRORS_H
-#include<stdint.h>
+#include<stdint.h>
typedef uint32_t rootpaerror_t;
@@ -53,7 +53,7 @@ NOTE to the maintainer. These values and documentation needs to be in line with
#define ROOTPA_COMMAND_NOT_SUPPORTED 0x00000001
#define STRING_ROOTPA_COMMAND_NOT_SUPPORTED "COMMAND_NOT_SUPPORTED_ERROR"
-/**
+/**
Either rootpa is locked by another client, or the client requests lock or unlock when it is not allowed to do that.
Possible steps to recover: wait until the lock is released
*/
@@ -66,11 +66,11 @@ Possible steps to recover: wait until the lock is released
#define ROOTPA_ERROR_COMMAND_EXECUTION 0x00000003
#define STRING_ROOTPA_ERROR_COMMAND_EXECUTION "COMMAND_EXECUTION_ERROR"
-/**
+/**
Registry returned an error when trying to write a container. mcDaemon could be dead or something seriously wrong in the file system.
Possible steps to recover: rebooting the device may help
*/
-#define ROOTPA_ERROR_REGISTRY 0x00000004
+#define ROOTPA_ERROR_REGISTRY 0x00000004
#define STRING_ROOTPA_ERROR_REGISTRY "REGISTRY_ERROR"
/**
@@ -80,59 +80,59 @@ Possible steps to recover: rebooting the device may help
#define ROOTPA_ERROR_MOBICORE_CONNECTION 0x00000005
#define STRING_ROOTPA_ERROR_MOBICORE_CONNECTION "MOBICORE_CONNECTION_ERROR"
-/**
+/**
Either Nwd or Swd software is out of memory.
Possible steps to recover: release memory
*/
#define ROOTPA_ERROR_OUT_OF_MEMORY 0x00000006
#define STRING_ROOTPA_ERROR_OUT_OF_MEMORY "OUT_OF_MEMORY_ERROR"
-/**
+/**
Rootpa internal error. This error is returned in various situations when something unexpected went wrong e.g. message from CMTL can‘t be interpreted, SE returned an error indicating invalid data, bad request or similar or base64 decoding failed
Possible steps to recover: rebooting or updating the device may help
*/
#define ROOTPA_ERROR_INTERNAL 0x00000007
#define STRING_ROOTPA_ERROR_INTERNAL "INTERNAL_ERROR"
-/**
+/**
Given argument is not allowed (in many cases it is NULL) or e.g. the format of xml is unsupported.
Possible steps to recover: give correct argument
*/
#define ROOTPA_ERROR_ILLEGAL_ARGUMENT 0x00000008
-/**
+/**
Error in network connection or use of networking library.
Possible steps to recover: create working network connection (avoid firewalls and proxies that require password)
*/
#define ROOTPA_ERROR_NETWORK 0x00000009
-/**
+/**
Error returned by XML library. Problems in parsing received XML command or creating new XML response.
*/
#define ROOTPA_ERROR_XML 0x0000000A
#define STRING_ROOTPA_ERROR_XML "XML_ERROR"
-/**
+/**
Registry returned an error when trying to read a container. Most likely the container does not exist.
*/
#define ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE 0x0000000B
#define STRING_ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE "REGISTRY_OBJECT_NOT_AVAILABLE"
-/**
+/**
CMP version of the device is not supported by SE.
Possible steps to recover: use CMP version supported by SE (>=3.0)
*/
#define ROOTPA_ERROR_SE_CMP_VERSION 0x0000000C
-/**
-Precoditions for SP container installation are not met in SE.
+/**
+Precoditions for SP container installation are not met in SE.
Possible steps to recover: register used SPID to SE
*/
#define ROOTPA_ERROR_SE_PRECONDITION_NOT_MET 0x0000000D
-/**
+/**
Requested SP container does not exist. This is not always considered an error but is used as an informative return code. As this is internal return code, user of RootPA services should never see this.
Possible steps to recover: add SP container or request container with different SPID
*/
diff --git a/mobicore/rootpa/Code/Common/include/version.h b/mobicore/rootpa/Code/Common/include/version.h
index e04c037..fb5d2a8 100644
--- a/mobicore/rootpa/Code/Common/include/version.h
+++ b/mobicore/rootpa/Code/Common/include/version.h
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -34,7 +34,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ROOTPA_VERSION_H_
#define ROOTPA_VERSION_H_
-#define ROOTPA_VERSION_MAJOR 2
-#define ROOTPA_VERSION_MINOR 68
+#define ROOTPA_VERSION_MAJOR 3
+#define ROOTPA_VERSION_MINOR 79
#endif /** ROOTPA_VERSION_H_ */
diff --git a/mobicore/rootpa/Code/Common/include/wrapper.h b/mobicore/rootpa/Code/Common/include/wrapper.h
new file mode 100644
index 0000000..baaada4
--- /dev/null
+++ b/mobicore/rootpa/Code/Common/include/wrapper.h
@@ -0,0 +1,30 @@
+#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_
diff --git a/mobicore/rootpa/Code/Common/pacmp3.c b/mobicore/rootpa/Code/Common/pacmp3.c
index 1b4ffc1..874683d 100644
--- a/mobicore/rootpa/Code/Common/pacmp3.c
+++ b/mobicore/rootpa/Code/Common/pacmp3.c
@@ -3,44 +3,44 @@ Copyright © Trustonic Limited 2013
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 <string.h>
#include <stdlib.h>
-#include <stdbool.h>
+#include <wrapper.h>
#include <TlCm/3.0/cmpMap.h>
#include <TlCm/tlCmApiCommon.h>
#include "tools.h"
#include "logging.h"
#include "rootpaErrors.h"
-#include "pacmtl.h"
-#include "pacmp3.h"
-#include "registry.h"
+#include "pacmtl.h"
+#include "pacmp3.h"
+#include "registry.h"
static mcSpid_t spid_;
static mcUuid_t tltUuid_;
@@ -51,7 +51,7 @@ void setCallbackP(CallbackFunctionP callbackP)
callbackP_=callbackP;
}
-// recovery from factory reset
+// recovery from factory reset
bool factoryResetAssumed()
{
uint32_t contSize=0;
@@ -71,7 +71,7 @@ bool factoryResetAssumed()
return false;
}
- // if neither root container, nor auth token container exists, we assume that factory reset has been performed.
+ // if neither root container, nor auth token container exists, we assume that factory reset has been performed.
if(MC_DRV_ERR_INVALID_DEVICE_FILE==result1 && MC_DRV_ERR_INVALID_DEVICE_FILE==result2)
{
LOGD("factoryResetAssumed returning true");
@@ -80,7 +80,7 @@ bool factoryResetAssumed()
return false;
}
-// recovery from factory reset
+// recovery from factory reset
/*
*/
@@ -111,7 +111,7 @@ rootpaerror_t allocateResponseBuffer(CmpMessage* responseP, CMTHANDLE handle )
return ROOTPA_ERROR_INTERNAL;
}
LOGD("allocateResponseBuffer, size %d", responseP->length);
- responseP->contentP=malloc(responseP->length);
+ responseP->contentP=(uint8_t*)malloc(responseP->length);
if(responseP->contentP==NULL) return ROOTPA_ERROR_OUT_OF_MEMORY;
return ROOTPA_OK;
}
@@ -120,13 +120,13 @@ bool ensureMappedBufferSize(CMTHANDLE handle, uint32_t neededSize)
{
if( neededSize > handle->mappedSize)
{
- uint8_t* newMappedP = realloc(handle->mappedP, neededSize);
+ uint8_t* newMappedP = (uint8_t*)realloc(handle->mappedP, neededSize);
if(!newMappedP)
{
LOGE("ensureMappedBufferSize, unable to allocate more memory %d", neededSize);
return false;
}
- handle->mappedP = newMappedP;
+ handle->mappedP = newMappedP;
}
return true;
}
@@ -135,7 +135,7 @@ rootpaerror_t addAuthTokenContainer(uint32_t* indexP, uint32_t* offsetP, CMTHAND
{
rootpaerror_t ret=ROOTPA_ERROR_OUT_OF_MEMORY;
AUTHTOKENCONTAINERP authTokenP = NULL;
- uint32_t contSize=0;
+ uint32_t contSize=0;
if((*mcRetP=regReadAuthToken(&authTokenP, &contSize))==MC_DRV_OK)
{
@@ -162,7 +162,7 @@ rootpaerror_t addRootContainer(uint32_t* indexP, uint32_t* offsetP, CMTHANDLE ha
{
rootpaerror_t ret=ROOTPA_ERROR_OUT_OF_MEMORY;
ROOTCONTAINERP rootP = NULL;
- uint32_t contSize=0;
+ uint32_t contSize=0;
if((*mcRetP=regReadRoot(&rootP, &contSize))==MC_DRV_OK)
{
@@ -189,7 +189,7 @@ rootpaerror_t addSpContainer(uint32_t* indexP, uint32_t* offsetP, mcSpid_t spid,
{
rootpaerror_t ret=ROOTPA_ERROR_OUT_OF_MEMORY;
SPCONTAINERP spP = NULL;
- uint32_t contSize=0;
+ uint32_t contSize=0;
if((*mcRetP=regReadSp(spid, &spP, &contSize))==MC_DRV_OK)
{
@@ -199,7 +199,7 @@ rootpaerror_t addSpContainer(uint32_t* indexP, uint32_t* offsetP, mcSpid_t spid,
setCmdElementInfo(indexP, handle->wsmP, offsetP, contSize);
ret=ROOTPA_OK;
}
- }
+ }
else if (MC_DRV_ERR_INVALID_DEVICE_FILE==*mcRetP)
{
ret=ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE;
@@ -218,11 +218,11 @@ rootpaerror_t addTltContainer(uint32_t* indexP, uint32_t* offsetP, const mcUuid_
rootpaerror_t ret=ROOTPA_ERROR_OUT_OF_MEMORY;
TLTCONTAINERP tltP = NULL;
uint32_t contSize=0;
-
+
if((*mcRetP=regReadTlt(uuidP, &tltP, &contSize, spid))==MC_DRV_OK)
{
if(ensureMappedBufferSize(handle, (*offsetP) + contSize))
- {
+ {
memcpy(handle->mappedP+(*offsetP),tltP,contSize);
setCmdElementInfo(indexP, handle->wsmP, offsetP, contSize);
ret=ROOTPA_OK;
@@ -244,22 +244,21 @@ rootpaerror_t addTltContainer(uint32_t* indexP, uint32_t* offsetP, const mcUuid_
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());
setCmdMapInfo(handle->wsmP, &handle->mapInfo);
setCmdCmpVersionAndCmdId(handle->wsmP, commandId);
setCmdElementInfo(&elementIndex, handle->wsmP, &offset, inCommandP->length);
if(ensureMappedBufferSize(handle, inCommandP->length))
- {
+ {
memcpy(handle->mappedP, inCommandP->contentP, inCommandP->length);
}
else
@@ -271,36 +270,36 @@ rootpaerror_t prepareCommand(cmpCommandId_t commandId, CmpMessage* inCommandP,
{
case MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION:
if (callbackP_) callbackP_(AUTHENTICATING_SOC, ROOTPA_OK, NULL);
- ret=addAuthTokenContainer(&elementIndex, &offset, handle, &mcRet);
+ ret=addAuthTokenContainer(&elementIndex, &offset, handle, &mcRet);
break;
case MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION:
if (callbackP_) callbackP_(AUTHENTICATING_ROOT, ROOTPA_OK, NULL);
- ret=addRootContainer(&elementIndex, &offset, handle, &mcRet);
- break;
-
+ ret=addRootContainer(&elementIndex, &offset, handle, &mcRet);
+ break;
+
case MC_CMP_CMD_BEGIN_SP_AUTHENTICATION:
ret=addRootContainer(&elementIndex, &offset, handle, &mcRet);
if(ROOTPA_OK==ret)
{
mcSpid_t spid=((cmpCmdBeginSpAuthentication_t*)outCommandP)->cmd.spid;
- ret=addSpContainer(&elementIndex, &offset, spid, handle, &mcRet);
+ ret=addSpContainer(&elementIndex, &offset, spid, handle, &mcRet);
}
break;
case MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE:
if (callbackP_) callbackP_(CREATING_ROOT_CONTAINER, ROOTPA_OK, NULL);
break;
-
+
case MC_CMP_CMD_ROOT_CONT_UNREGISTER:
if (callbackP_) callbackP_(UNREGISTERING_ROOT_CONTAINER, ROOTPA_OK, NULL);
- break;
-
+ break;
+
case MC_CMP_CMD_SP_CONT_ACTIVATE:
spid_=((cmpCmdSpContActivate_t*)outCommandP)->cmd.sdata.spid;
break;
case MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT:
spid_=((cmpCmdSpContLockByRoot_t*)outCommandP)->cmd.sdata.spid;
- ret=addSpContainer(&elementIndex, &offset, spid_, handle, &mcRet);
+ ret=addSpContainer(&elementIndex, &offset, spid_, handle, &mcRet);
break;
case MC_CMP_CMD_SP_CONT_LOCK_BY_SP :
spid_=((cmpCmdSpContLockBySp_t*)outCommandP)->cmd.sdata.spid;
@@ -315,7 +314,7 @@ rootpaerror_t prepareCommand(cmpCommandId_t commandId, CmpMessage* inCommandP,
break;
case MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT:
spid_=((cmpCmdSpContUnlockByRoot_t*)outCommandP)->cmd.sdata.spid;
- ret=addSpContainer(&elementIndex, &offset, spid_, handle, &mcRet);
+ ret=addSpContainer(&elementIndex, &offset, spid_, handle, &mcRet);
break;
case MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP :
spid_=((cmpCmdSpContUnlockBySp_t*)outCommandP)->cmd.sdata.spid;
@@ -326,7 +325,7 @@ rootpaerror_t prepareCommand(cmpCommandId_t commandId, CmpMessage* inCommandP,
case MC_CMP_CMD_TLT_CONT_ACTIVATE:
spid_=((cmpCmdTltContActivate_t*)outCommandP)->cmd.sdata.spid;
memcpy(&tltUuid_,&((cmpCmdTltContActivate_t*)outCommandP)->cmd.sdata.uuid, sizeof(mcUuid_t));
- ret=addTltContainer(&elementIndex, &offset, &tltUuid_, spid_, handle, &mcRet);
+ ret=addTltContainer(&elementIndex, &offset, &tltUuid_, spid_, handle, &mcRet);
break;
case MC_CMP_CMD_TLT_CONT_LOCK_BY_SP:
spid_=((cmpCmdTltContLockBySp_t*)outCommandP)->cmd.sdata.spid;
@@ -334,14 +333,14 @@ rootpaerror_t prepareCommand(cmpCommandId_t commandId, CmpMessage* inCommandP,
ret=addTltContainer(&elementIndex, &offset, &tltUuid_, spid_, handle, &mcRet);
break;
case MC_CMP_CMD_TLT_CONT_PERSONALIZE:
- ret=addTltContainer(&elementIndex, &offset, &((cmpCmdTltContPersonalize_t*)outCommandP)->cmd.sdata.uuid,
+ ret=addTltContainer(&elementIndex, &offset, &((cmpCmdTltContPersonalize_t*)outCommandP)->cmd.sdata.uuid,
((cmpCmdTltContPersonalize_t*)outCommandP)->cmd.sdata.spid,
handle, &mcRet);
break;
case MC_CMP_CMD_TLT_CONT_REGISTER:
spid_=((cmpCmdTltContRegister_t*)outCommandP)->cmd.sdata.spid;
memcpy(&tltUuid_,&((cmpCmdTltContRegister_t*)outCommandP)->cmd.sdata.uuid, sizeof(mcUuid_t));
- break;
+ break;
case MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE:
spid_=((cmpCmdTltContRegisterActivate_t*)outCommandP)->cmd.sdata.spid;
memcpy(&tltUuid_,&((cmpCmdTltContRegisterActivate_t*)outCommandP)->cmd.sdata.uuid, sizeof(mcUuid_t));
@@ -358,7 +357,7 @@ rootpaerror_t prepareCommand(cmpCommandId_t commandId, CmpMessage* inCommandP,
default:
// nothing extra to do, just return ret at the end of function
break;
-
+
}
responseP->hdr.ret=ret;
responseP->hdr.intRet=mcRet;
@@ -368,10 +367,10 @@ rootpaerror_t prepareCommand(cmpCommandId_t commandId, CmpMessage* inCommandP,
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)
{
@@ -395,12 +394,12 @@ mcResult_t storeContainers(cmpCommandId_t commandId, CMTHANDLE handle, uint32_t
{
mcRet=-1;
}
-
+
if(MC_DRV_OK==mcRet)
{
mcSoAuthTokenCont_t* authTokenP=NULL;
uint32_t authTokenSize=0;
-
+
mcRet=regReadAuthToken(&authTokenP, &authTokenSize);
if(mcRet!=MC_DRV_OK)
{
@@ -424,7 +423,7 @@ mcResult_t storeContainers(cmpCommandId_t commandId, CMTHANDLE handle, uint32_t
}
else
{
- LOGE("pacmp3 storeContainers for %d regWriteRoot failed %d", commandId, mcRet);
+ LOGE("pacmp3 storeContainers for %d regWriteRoot failed %d", commandId, mcRet);
}
break;
@@ -442,7 +441,7 @@ mcResult_t storeContainers(cmpCommandId_t commandId, CMTHANDLE handle, uint32_t
break;
- case MC_CMP_CMD_ROOT_CONT_UNREGISTER:
+ case MC_CMP_CMD_ROOT_CONT_UNREGISTER:
mcRet=regCleanupRoot();
break;
@@ -459,14 +458,14 @@ mcResult_t storeContainers(cmpCommandId_t commandId, CMTHANDLE handle, uint32_t
{
mcRet=-1;
}
-
+
break;
case MC_CMP_CMD_SP_CONT_REGISTER:
case MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE:
{
// Root container is in the buffer first, that is why we read it first
- // we write it last since if SP container writing fails we do not want
+ // we write it last since if SP container writing fails we do not want
// to write root container
uint32_t rootLength=0;
ROOTCONTAINERP rootP=NULL;
@@ -477,7 +476,7 @@ mcResult_t storeContainers(cmpCommandId_t commandId, CMTHANDLE handle, uint32_t
{
mcRet=regWriteSp(spid_, (SPCONTAINERP) (handle->mappedP+offset), length);
}
- else
+ else
{
mcRet=-1;
}
@@ -493,26 +492,26 @@ mcResult_t storeContainers(cmpCommandId_t commandId, CMTHANDLE handle, uint32_t
}
else
{
- LOGE("pacmp3 storeContainers for %d regWriteSp failed %d", commandId, mcRet);
+ LOGE("pacmp3 storeContainers for %d regWriteSp failed %d", commandId, mcRet);
}
break;
}
case MC_CMP_CMD_SP_CONT_UNREGISTER:
- mcRet=regCleanupSp(spid_);
+ mcRet=regCleanupSp(spid_);
if(MC_DRV_OK!=mcRet)
{
- LOGE("pacmp3 storeContainers for %d regCleanupSp failed %d, , still attempting storing root", commandId, mcRet);
+ LOGE("pacmp3 storeContainers for %d regCleanupSp failed %d, , still attempting storing root", commandId, mcRet);
}
if(getRspElementInfo(&elementIndex, handle, &offset, &length))
{
mcRet=regWriteRoot((ROOTCONTAINERP) (handle->mappedP+offset), length);
}
- else
+ else
{
mcRet=-1;
- }
+ }
break;
@@ -521,7 +520,7 @@ mcResult_t storeContainers(cmpCommandId_t commandId, CMTHANDLE handle, uint32_t
case MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE:
{
// SP container is in the buffer first, that is why we read it first
- // we write it last since if TLT container writing fails we do not want
+ // we write it last since if TLT container writing fails we do not want
// to write SP container
uint32_t spLength=0;
SPCONTAINERP spP=NULL;
@@ -532,28 +531,28 @@ mcResult_t storeContainers(cmpCommandId_t commandId, CMTHANDLE handle, uint32_t
{
mcRet=regWriteTlt(&tltUuid_,(TLTCONTAINERP) (handle->mappedP+offset), length, spid_);
}
- else
+ else
{
mcRet=-1;
}
}
- else
+ else
{
mcRet=-1;
}
-
+
if(MC_DRV_OK==mcRet)
{
mcRet=regWriteSp(spid_, spP, spLength);
if(MC_DRV_OK!=mcRet)
{
- LOGE("pacmp3 storeContainers for %d regWriteSp failed %d", commandId, mcRet);
+ LOGE("pacmp3 storeContainers for %d regWriteSp failed %d", commandId, mcRet);
regCleanupTlt(&tltUuid_, spid_);
}
}
else
{
- LOGE("pacmp3 storeContainers for %d regWriteTlt failed %d", commandId, mcRet);
+ LOGE("pacmp3 storeContainers for %d regWriteTlt failed %d", commandId, mcRet);
}
break;
@@ -565,18 +564,18 @@ mcResult_t storeContainers(cmpCommandId_t commandId, CMTHANDLE handle, uint32_t
{
mcRet=regWriteTlt(&tltUuid_,(TLTCONTAINERP) (handle->mappedP+offset), length, spid_);
}
- else
+ else
{
mcRet=-1;
}
-
+
break;
case MC_CMP_CMD_TLT_CONT_UNREGISTER:
mcRet=regCleanupTlt(&tltUuid_, spid_);
if(MC_DRV_OK!=mcRet)
{
- LOGE("pacmp3 storeContainers for %d regCleanupTlt failed %d, still attempting storing sp", commandId, mcRet);
+ LOGE("pacmp3 storeContainers for %d regCleanupTlt failed %d, still attempting storing sp", commandId, mcRet);
}
if(getRspElementInfo(&elementIndex, handle, &offset, &length))
@@ -584,35 +583,38 @@ mcResult_t storeContainers(cmpCommandId_t commandId, CMTHANDLE handle, uint32_t
mcRet=regWriteSp(spid_, (SPCONTAINERP) (handle->mappedP+offset), length);
if(MC_DRV_OK!=mcRet)
{
- LOGE("pacmp3 storeContainers for %d regWriteSp failed %d", commandId, mcRet);
- }
+ LOGE("pacmp3 storeContainers for %d regWriteSp failed %d", commandId, mcRet);
+ }
}
- else
+ else
{
mcRet=-1;
}
-
+
break;
- default:
- LOGD("pacmp3 storeContainers nothing to store");
+ default:
+ LOGD("pacmp3 storeContainers nothing to store");
// nothing to do
- break;
+ break;
}
LOGD("<<pacmp3 storeContainers %d %d", commandId, mcRet);
return mcRet;
}
/**
-handleResponse stores the container received in response and copies the response to the buffer to be returned
-to the client Note that the container is not store id cmtl returned an error, but the content of the response is
+handleResponse stores the container received in response and copies the response to the buffer to be returned
+to the client Note that the container is not store id cmtl returned an error, but the content of the response is
returned to the client.
*/
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)
{
@@ -621,10 +623,6 @@ rootpaerror_t handleResponse(cmpCommandId_t commandId, CmpMessage* outResponseP,
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)
@@ -653,10 +651,10 @@ rootpaerror_t handleResponse(cmpCommandId_t commandId, CmpMessage* outResponseP,
}
mcRet=storeContainers(commandId, handle, elementIndex, offset);
-
+
if(mcRet != MC_DRV_OK)
{
- LOGE("pacmp3 handleResponse for %d registry failed %d", commandId, mcRet);
+ LOGE("pacmp3 handleResponse for %d registry failed %d", commandId, mcRet);
if(-1==mcRet)
{
ret = ROOTPA_ERROR_INTERNAL;
@@ -669,8 +667,8 @@ rootpaerror_t handleResponse(cmpCommandId_t commandId, CmpMessage* outResponseP,
{
outResponseP->hdr.intRet=mcRet;
}
- outResponseP->hdr.ret=ret;
+ outResponseP->hdr.ret=ret;
}
- LOGD("<<handleResponse returning %d ", ret);
+ LOGD("<<handleResponse returning %d ", ret);
return ret;
}
diff --git a/mobicore/rootpa/Code/Common/pacmp3.h b/mobicore/rootpa/Code/Common/pacmp3.h
index e063af8..b5936c6 100644
--- a/mobicore/rootpa/Code/Common/pacmp3.h
+++ b/mobicore/rootpa/Code/Common/pacmp3.h
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -40,9 +40,9 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
uint32_t sizeOfCmp();
-// recovery from factory reset
+// recovery from factory reset
bool factoryResetAssumed();
-// recovery from factory reset
+// recovery from factory reset
cmpCommandId_t getCmpCommandId(const uint8_t* commandP);
diff --git a/mobicore/rootpa/Code/Common/pacmtl.c b/mobicore/rootpa/Code/Common/pacmtl.c
index 30c029e..ff97723 100644
--- a/mobicore/rootpa/Code/Common/pacmtl.c
+++ b/mobicore/rootpa/Code/Common/pacmtl.c
@@ -3,36 +3,37 @@ Copyright © Trustonic Limited 2013
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 <string.h>
#include "logging.h"
+
#include "pacmp3.h"
-#include "registry.h"
+#include "registry.h"
#include "pacmtl.h"
#define ILLEGAL_ELEMENT 0
@@ -41,6 +42,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
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);
@@ -53,7 +55,7 @@ void setCmdElementInfo(uint32_t* elementNbrP, uint8_t* wsmP, uint32_t* elementOf
return;
}
- cmpMapOffsetInfo_t* elementP=(&((cmpCommandHeaderTci_t*)wsmP)->cmpCmdMapOffsetInfo);
+ elementP=(&((cmpCommandHeaderTci_t*)wsmP)->cmpCmdMapOffsetInfo);
elementP+=((*elementNbrP)-1);
elementP->offset=*elementOffsetP;
@@ -66,7 +68,7 @@ void setCmdElementInfo(uint32_t* elementNbrP, uint8_t* wsmP, uint32_t* elementOf
void setCmdMapInfo(uint8_t* wsmP, const mcBulkMap_t* mapInfoP)
{
// mapInfo and *mapinfoP are of different type, thats why assignment instead of memcpy.
-
+
((cmpCommandHeaderTci_t*)wsmP)->mapInfo.addr=mapInfoP->sVirtualAddr;
((cmpCommandHeaderTci_t*)wsmP)->mapInfo.len=mapInfoP->sVirtualLen;
}
@@ -74,26 +76,26 @@ void setCmdMapInfo(uint8_t* wsmP, const mcBulkMap_t* mapInfoP)
void setCmdCmpVersionAndCmdId(uint8_t* wsmP, cmpCommandId_t commandId)
{
((cmpCommandHeaderTci_t*)wsmP)->version=CMP_VERSION;
- ((cmpCommandHeaderTci_t*)wsmP)->commandId=commandId;
+ ((cmpCommandHeaderTci_t*)wsmP)->commandId=commandId;
}
bool getRspElementInfo(uint32_t* elementNbrP, CMTHANDLE handle, uint32_t* elementOffsetP, uint32_t* elementLengthP)
{
uint8_t* wsmP=NULL;
cmpMapOffsetInfo_t* elementP=NULL;
-
+
if(NULL==handle)
{
LOGE("pacmtl setCmdElementInfo ho handle");
- *elementLengthP=0;
+ *elementLengthP=0;
return false;
}
wsmP=handle->wsmP;
- LOGD(">>pacmtl getRspElementInfo %x %x %d %d %d %d", ((cmpResponseHeaderTci_t*)wsmP)->version,
- ((cmpResponseHeaderTci_t*)wsmP)->responseId,
- ((cmpResponseHeaderTci_t*)wsmP)->len,
- *((uint32_t*)(wsmP+12)),
- *((uint32_t*)(wsmP+16)),
+ LOGD(">>pacmtl getRspElementInfo %x %x %d %d %d %d", ((cmpResponseHeaderTci_t*)wsmP)->version,
+ ((cmpResponseHeaderTci_t*)wsmP)->responseId,
+ ((cmpResponseHeaderTci_t*)wsmP)->len,
+ *((uint32_t*)(wsmP+12)),
+ *((uint32_t*)(wsmP+16)),
*((uint32_t*)(wsmP+20)));
if(NULL==elementNbrP || NULL == elementOffsetP || NULL == elementLengthP || NULL == handle->wsmP)
{
@@ -108,7 +110,7 @@ bool getRspElementInfo(uint32_t* elementNbrP, CMTHANDLE handle, uint32_t* elemen
*elementLengthP=0;
return false;
}
-
+
elementP=(cmpMapOffsetInfo_t*)(wsmP+sizeof(cmpResponseHeaderTci_t));
elementP+=((*elementNbrP)-1);
@@ -118,7 +120,7 @@ bool getRspElementInfo(uint32_t* elementNbrP, CMTHANDLE handle, uint32_t* elemen
*elementLengthP=0;
return false;
}
-
+
*elementOffsetP=elementP->offset;
*elementLengthP=elementP->len;
LOGD("<<pacmtl getRspElementInfo element %d offset %d length %d", *elementNbrP, *elementOffsetP, *elementLengthP);
@@ -146,11 +148,11 @@ bool isValidResponse(const uint8_t* wsmP)
return false;
}
if(getRspCmpVersion(wsmP) != CMP_VERSION )
- {
+ {
LOGE("pacmtl isValidResponse returning false due to cmpVersion 0x%x", getRspCmpVersion(wsmP));
return false;
}
-
+
if(IS_RSP(getRspCmpId(wsmP)))
{
return true;
@@ -187,10 +189,10 @@ typedef struct {
uint32_t cmdId;
uint32_t cmdRspSize;
uint32_t cmdContainerSize;
- uint32_t rspContainerSize;
+ uint32_t rspContainerSize;
} cmpSizes_t;
//
-// note that the container sizes are
+// note that the container sizes are
//
static const cmpSizes_t sizeTable_[] = {
{
@@ -198,13 +200,13 @@ static const cmpSizes_t sizeTable_[] = {
sizeof(cmpMapAuthenticate_t),
0,
0
- },
+ },
{
- MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION,
+ MC_CMP_CMD_BEGIN_ROOT_AUTHENTICATION,
sizeof(cmpMapBeginRootAuthentication_t),
SIZEOFROOTCONTAINER,
0
- },
+ },
{
MC_CMP_CMD_BEGIN_SOC_AUTHENTICATION,
sizeof(cmpMapBeginSocAuthentication_t),
@@ -216,158 +218,158 @@ static const cmpSizes_t sizeTable_[] = {
sizeof(cmpMapBeginSpAuthentication_t),
SIZEOFROOTCONTAINER+SIZEOFSPCONTAINER,
0
- },
+ },
{
MC_CMP_CMD_GENERATE_AUTH_TOKEN,
sizeof(cmpMapGenAuthToken_t),
0,
0 //SIZEOFAUTHTOKENCONTAINER
- },
+ },
{
MC_CMP_CMD_GET_VERSION,
sizeof(cmpMapGetVersion_t),
0,
0
- },
+ },
{
MC_CMP_CMD_ROOT_CONT_LOCK_BY_ROOT,
sizeof(cmpMapRootContLockByRoot_t),
0,
- SIZEOFROOTCONTAINER
- },
+ SIZEOFROOTCONTAINER
+ },
{
MC_CMP_CMD_ROOT_CONT_REGISTER_ACTIVATE,
sizeof(cmpMapRootContRegisterActivate_t),
0,
SIZEOFROOTCONTAINER
- },
+ },
{
MC_CMP_CMD_ROOT_CONT_UNLOCK_BY_ROOT,
sizeof(cmpMapRootContUnlockByRoot_t),
0,
SIZEOFROOTCONTAINER
- },
+ },
{
MC_CMP_CMD_ROOT_CONT_UNREGISTER,
sizeof(cmpMapRootContUnregister_t),
0,
0
- },
+ },
{
MC_CMP_CMD_SP_CONT_ACTIVATE,
sizeof(cmpMapSpContActivate_t),
0,
- SIZEOFSPCONTAINER
- },
+ SIZEOFSPCONTAINER
+ },
{
MC_CMP_CMD_SP_CONT_LOCK_BY_ROOT,
sizeof(cmpMapSpContLockByRoot_t),
SIZEOFSPCONTAINER,
SIZEOFSPCONTAINER
- },
+ },
{
MC_CMP_CMD_SP_CONT_LOCK_BY_SP,
sizeof(cmpMapSpContLockBySp_t),
0,
- SIZEOFSPCONTAINER
- },
+ SIZEOFSPCONTAINER
+ },
{
MC_CMP_CMD_SP_CONT_REGISTER,
sizeof(cmpMapSpContRegister_t),
0,
SIZEOFROOTCONTAINER+SIZEOFSPCONTAINER
- },
+ },
{
MC_CMP_CMD_SP_CONT_REGISTER_ACTIVATE,
sizeof(cmpMapSpContRegisterActivate_t),
0,
SIZEOFROOTCONTAINER+SIZEOFSPCONTAINER
- },
+ },
{
MC_CMP_CMD_SP_CONT_UNLOCK_BY_ROOT,
sizeof(cmpMapSpContUnlockByRoot_t),
SIZEOFSPCONTAINER,
- SIZEOFSPCONTAINER
- },
+ SIZEOFSPCONTAINER
+ },
{
MC_CMP_CMD_SP_CONT_UNLOCK_BY_SP,
sizeof(cmpMapSpContUnlockBySp_t),
0,
SIZEOFSPCONTAINER
- },
+ },
{
MC_CMP_CMD_SP_CONT_UNREGISTER,
sizeof(cmpMapSpContUnregister_t),
0,
SIZEOFROOTCONTAINER
- },
+ },
{
MC_CMP_CMD_TLT_CONT_ACTIVATE,
sizeof(cmpMapTltContActivate_t),
SIZEOFTLTCONTAINER,
SIZEOFTLTCONTAINER
- },
+ },
{
MC_CMP_CMD_TLT_CONT_LOCK_BY_SP,
sizeof(cmpMapTltContLockBySp_t),
SIZEOFTLTCONTAINER,
- SIZEOFTLTCONTAINER
- },
+ SIZEOFTLTCONTAINER
+ },
{
MC_CMP_CMD_TLT_CONT_PERSONALIZE,
sizeof(cmpMapTltContPersonalize_t),
SIZEOFTLTCONTAINER,
0
- },
+ },
{
MC_CMP_CMD_TLT_CONT_REGISTER,
sizeof(cmpMapTltContRegister_t),
0,
SIZEOFSPCONTAINER+SIZEOFTLTCONTAINER
- },
+ },
{
MC_CMP_CMD_TLT_CONT_REGISTER_ACTIVATE,
sizeof(cmpMapTltContRegisterActivate_t),
0,
SIZEOFSPCONTAINER+SIZEOFTLTCONTAINER
- },
+ },
{
MC_CMP_CMD_TLT_CONT_UNLOCK_BY_SP,
sizeof(cmpMapTltContUnlockBySp_t),
SIZEOFTLTCONTAINER,
SIZEOFTLTCONTAINER
- },
+ },
{
MC_CMP_CMD_TLT_CONT_UNREGISTER,
sizeof(cmpMapTltContUnregister_t),
0,
SIZEOFSPCONTAINER
- },
+ },
{
MC_CMP_CMD_GET_SUID,
sizeof(cmpMapGetSuid_t),
0,
- 0
- },
+ 0
+ },
{
MC_CMP_CMD_AUTHENTICATE_TERMINATE,
sizeof(cmpMapAuthenticateTerminate_t),
0,
0
- }
+ }
};
const cmpSizes_t* getCmpSizeInfo(uint32_t cmdId)
{
int i = 0;
- for ( i = 0; i < sizeof(sizeTable_)/sizeof(cmpSizes_t); i++)
+ for ( i = 0; i < sizeof(sizeTable_)/sizeof(cmpSizes_t); i++)
{
- if (cmdId == sizeTable_[i].cmdId)
+ if (cmdId == sizeTable_[i].cmdId)
{
return &sizeTable_[i];
}
}
- LOGE("getCmpSizeInfo command %d not supported", cmdId);
+ LOGE("getCmpSizeInfo command %d not supported", cmdId);
return NULL;
}
@@ -378,12 +380,14 @@ uint32_t bigger(uint32_t first, uint32_t second)
uint32_t getTotalMappedBufferSize(CmpMessage* commandP)
{
+ uint32_t commandSize;
+ uint32_t containerSize;
const cmpSizes_t* sizesP=getCmpSizeInfo(getCmpCommandId(commandP->contentP));
if(NULL==sizesP) return 0;
- 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,
+ commandSize=bigger(sizesP->cmdRspSize, commandP->length);
+ 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);
return (commandSize+containerSize);
}
diff --git a/mobicore/rootpa/Code/Common/provisioningengine.c b/mobicore/rootpa/Code/Common/provisioningengine.c
index fae9f38..ddcc777 100644
--- a/mobicore/rootpa/Code/Common/provisioningengine.c
+++ b/mobicore/rootpa/Code/Common/provisioningengine.c
@@ -3,36 +3,36 @@ Copyright © Trustonic Limited 2013
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 <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <stdbool.h>
+#include <wrapper.h>
#include "rootpaErrors.h"
@@ -53,11 +53,11 @@ static const char* const RELATION_NEXT = "relation/next";
static const uint8_t* const SLASH= (uint8_t*)"/";
static const char* const RELATION_INITIAL_POST="initial_post"; // this will make us to send HTTP GET, which
- // is the right thing to do since we do not
+ // is the right thing to do since we do not
// have any data to send to SE, this will need to be different in RootPA initiated trustet installation
static const char* const RELATION_INITIAL_DELETE="initial_delete"; // this will make us to send HTTP DELETE
-#define INT_STRING_LENGTH 12 // (32 bit <= 10 decimal numbers) + "/" + trailing zero.
+#define INT_STRING_LENGTH 12 // (32 bit <= 10 decimal numbers) + "/" + trailing zero.
#define INITIAL_URL_BUFFER_LENGTH 255
static char initialUrl_[INITIAL_URL_BUFFER_LENGTH];
@@ -65,18 +65,19 @@ static CallbackFunctionP callbackP_=NULL;
void addSlashToUri(char* uriP)
{
+ int uriidx;
LOGD(">>addSlashToUri");
- int uriidx=strlen(uriP);
+ uriidx=strlen(uriP);
uriP[uriidx]='/';
- LOGD("<<addSlashToUri %s", uriP);
+ LOGD("<<addSlashToUri %s", uriP);
}
void addBytesToUri(char* uriP, uint8_t* bytes, uint32_t length, bool uuid )
{
- LOGD(">>addBytesToUri %d", length);
int uriidx=strlen(uriP);
- int i;
+ uint32_t i;
uint8_t singleNumber=0;
+ LOGD(">>addBytesToUri %d", length);
for(i=0; i<length; i++)
{
singleNumber=(bytes[i]>>4);
@@ -101,27 +102,27 @@ void addIntToUri(char* uriP, uint32_t addThis)
// using signed integer since this is how SE wants it
snprintf(intInString, INT_STRING_LENGTH, "/%d", addThis);
strncpy((uriP+strlen(uriP)), intInString, INT_STRING_LENGTH); // we have earlier made sure there is enough room in uriP, using strncpy here instead strcpy is just to avoid static analysis comments
- LOGD("add int to URI %s %d", uriP, addThis);
+ LOGD("add int to URI %s %d", uriP, addThis);
}
void cleanup(char** linkP, char** relP, char** commandP)
{
if(commandP!=NULL)
- {
+ {
free(*commandP);
*commandP=NULL;
}
if(relP!=NULL)
- {
+ {
if((*relP!=RELATION_INITIAL_POST) &&
(*relP!=RELATION_INITIAL_DELETE)) free(*relP);
*relP=NULL;
}
if(linkP!=NULL)
- {
- free(*linkP);
+ {
+ free(*linkP);
*linkP=NULL;
}
}
@@ -135,7 +136,7 @@ rootpaerror_t setInitialAddress(const char* addrP, uint32_t length)
if(INITIAL_URL_BUFFER_LENGTH < (length + 1))
{
- return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
+ return ROOTPA_ERROR_ILLEGAL_ARGUMENT;
}
memset(initialUrl_, 0, INITIAL_URL_BUFFER_LENGTH);
memcpy(initialUrl_, addrP, length);
@@ -151,27 +152,32 @@ char* createBasicLink(mcSuid_t suid)
{
char* tmpLinkP=NULL;
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=malloc(urlLength);
- memset(tmpLinkP,0,urlLength);
- strncpy(tmpLinkP, initialUrl_, urlLength);
- addBytesToUri(tmpLinkP, (uint8_t*) &suid, sizeof(suid), false);
+ 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");
+ }
return tmpLinkP;
}
void doProvisioningWithSe(
- mcSpid_t spid,
- mcSuid_t suid,
- CallbackFunctionP callbackP,
- SystemInfoCallbackFunctionP getSysInfoP,
+ mcSpid_t spid,
+ mcSuid_t suid,
+ CallbackFunctionP callbackP,
+ SystemInfoCallbackFunctionP getSysInfoP,
GetVersionFunctionP getVersionP,
initialRel_t initialRel,
trustletInstallationData_t* tltDataP)
{
- LOGD(">>doProvisioningWithSe");
-
rootpaerror_t ret=ROOTPA_OK;
rootpaerror_t tmpRet=ROOTPA_OK;
bool workToDo = true;
@@ -186,23 +192,34 @@ void doProvisioningWithSe(
const char* usedRelP=NULL;
const char* usedCommandP=NULL;
- callbackP_=callbackP;
+ LOGD(">>doProvisioningWithSe");
+
+ callbackP_=callbackP;
if(empty(initialUrl_))
{
memset(initialUrl_, 0, INITIAL_URL_BUFFER_LENGTH);
- strncpy(initialUrl_, SE_URL, strlen(SE_URL));
+ strncpy(initialUrl_, SE_URL, strlen(SE_URL));
}
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);
@@ -215,17 +232,17 @@ void doProvisioningWithSe(
ret=openSeClientAndInit();
if(ROOTPA_OK!=ret)
{
- callbackP(ERROR, ret, NULL);
+ callbackP(ERROR_STATE, ret, NULL);
workToDo=false;
}
-
+
if(tltDataP != NULL) // we are installing trustlet
{
ret=buildXmlTrustletInstallationRequest(&responseP, *tltDataP );
if(ROOTPA_OK!=ret || NULL==responseP)
{
- if(ROOTPA_OK==ret) ret=ROOTPA_ERROR_XML;
- callbackP(ERROR, ret, NULL);
+ if(ROOTPA_OK==ret) ret=ROOTPA_ERROR_XML;
+ callbackP(ERROR_STATE, ret, NULL);
workToDo=false;
}
else
@@ -235,7 +252,7 @@ void doProvisioningWithSe(
}
}
-// begin recovery from factory reset 1
+// begin recovery from factory reset 1
if(factoryResetAssumed() && relP != RELATION_INITIAL_DELETE && workToDo == true)
{
pendingLinkP=linkP;
@@ -243,18 +260,18 @@ void doProvisioningWithSe(
relP=RELATION_INITIAL_DELETE;
linkP=createBasicLink(suid);
}
-// end recovery from factory reset 1
-
+// end recovery from factory reset 1
+
while(workToDo)
{
- LOGD("in loop link: %s\nrel: %s\ncommand: %s\nresponse: %s\n", (linkP==NULL)?"null":linkP,
- (relP==NULL)?"null":relP,
- (commandP==NULL)?"null":commandP,
+ LOGD("in loop link: %s\nrel: %s\ncommand: %s\nresponse: %s\n", (linkP==NULL)?"null":linkP,
+ (relP==NULL)?"null":relP,
+ (commandP==NULL)?"null":commandP,
(responseP==NULL)?"null":responseP);
-
+
if(NULL==relP)
{
-// begin recovery from factory reset 2
+// begin recovery from factory reset 2
if(pendingLinkP!=NULL && pendingRelP!=NULL)
{
free((void*)linkP);
@@ -266,12 +283,12 @@ void doProvisioningWithSe(
continue;
}
// end recovery from factory reset 2
-
-
- callbackP(FINISHED_PROVISIONING, ROOTPA_OK, NULL); // this is the only place where we can be sure
+
+
+ callbackP(FINISHED_PROVISIONING, ROOTPA_OK, NULL); // this is the only place where we can be sure
// SE does not want to send any more data to us
- // the other option would be to keep track on the
- // commands received from SE but since we want
+ // the other option would be to keep track on the
+ // commands received from SE but since we want
// SE to have option to execute also other commands
// and also allow modification in provisioning sequence
// without modifying RootPA we use this simpler way.
@@ -294,19 +311,30 @@ void doProvisioningWithSe(
usedLinkP=linkP; // originally linkP
usedRelP=relP; // originally NULL
usedCommandP=commandP; // originally NULL
-
+
if(strstr(relP, RELATION_SYSTEMINFO))
- {
+ {
osInfo_t osSpecificInfo;
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;
+ if(tmpRet!=ROOTPA_OK) ret=tmpRet;
tmpRet=getVersionP(&mcVersionTag, &mcVersion);
if(tmpRet!=ROOTPA_OK) ret=tmpRet;
-
+
tmpRet=buildXmlSystemInfo(&responseP, mcVersionTag, &mcVersion, &osSpecificInfo);
if(tmpRet!=ROOTPA_OK) ret=tmpRet;
@@ -318,23 +346,32 @@ void doProvisioningWithSe(
free(osSpecificInfo.modelP);
free(osSpecificInfo.versionP);
- tmpRet=httpPutAndReceiveCommand(responseP, &linkP, &relP, &commandP);
- if(tmpRet!=ROOTPA_OK) ret=tmpRet;
+ 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;
+ }
+
if(ret!=ROOTPA_OK)
{
LOGE("getSysInfoP, getVersionP or buildXmlSystemInfo or httpPutAndReceiveCommand returned an error %d", ret);
- callbackP(ERROR, ret, NULL);
+ callbackP(ERROR_STATE, ret, NULL);
if(tmpRet!=ROOTPA_OK) workToDo=false; // if sending response succeeded, we rely on "relP" to tell whether we should continue or not
}
}
else if(strstr(relP, RELATION_INITIAL_DELETE))
{
ret=httpDeleteAndReceiveCommand(&linkP, &relP, &commandP);
-
+
if(ret!=ROOTPA_OK)
{
LOGE("httpDeleteAndReceiveCommand returned an error %d", ret);
- callbackP(ERROR, ret, NULL);
+ callbackP(ERROR_STATE, ret, NULL);
workToDo=false;
}
}
@@ -342,11 +379,11 @@ void doProvisioningWithSe(
{
// response may be NULL or trustlet installation request
ret=httpPostAndReceiveCommand(responseP, &linkP, &relP, &commandP);
-
+
if(ret!=ROOTPA_OK)
{
LOGE("httpPostAndReceiveCommand returned an error %d", ret);
- callbackP(ERROR, ret, NULL);
+ callbackP(ERROR_STATE, ret, NULL);
workToDo=false;
}
}
@@ -358,7 +395,7 @@ void doProvisioningWithSe(
if(NULL==responseP)
{
- if(ROOTPA_OK==ret) ret=ROOTPA_ERROR_XML;
+ if(ROOTPA_OK==ret) ret=ROOTPA_ERROR_XML;
// have to set these to NULL since we are not even trying to get them from SE now
linkP=NULL;
relP=NULL;
@@ -367,18 +404,18 @@ void doProvisioningWithSe(
}
else
{
- // attempting to return response to SE even if there was something wrong in handleXmlMessage
+ // attempting to return response to SE even if there was something wrong in handleXmlMessage
tmpRet=httpPostAndReceiveCommand(responseP, &linkP, &relP, &commandP);
if(tmpRet!=ROOTPA_OK) ret=tmpRet;
}
-
- 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(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, ret, NULL);
+ callbackP(ERROR_STATE, ret, NULL);
if(tmpRet!=ROOTPA_OK) workToDo=false; // if sending response succeeded, we rely on "relP" to tell whether we should continue or not
}
-
+
}
else if(strstr(relP, RELATION_NEXT))
{
@@ -386,33 +423,33 @@ void doProvisioningWithSe(
if(ret!=ROOTPA_OK)
{
LOGE("httpGetAndReceiveCommand returned an error %d", ret);
- callbackP(ERROR, ret, NULL);
- workToDo=false;
+ callbackP(ERROR_STATE, ret, NULL);
+ workToDo=false;
}
}
else
{
LOGE("DO NOT UNDERSTAND REL %s", relP);
ret=ROOTPA_ERROR_ILLEGAL_ARGUMENT;
- callbackP(ERROR, ret, NULL);
+ callbackP(ERROR_STATE, ret, NULL);
workToDo=false;
}
LOGD("end of provisioning loop work to do: %d, responseP %ld", workToDo, (long int) responseP);
- }
+ }
// last round cleaning in order to make sure both original and user pointers are released, but only once
if(!workToDo)
{
- LOGD("no more work to do %ld - %ld %ld - %ld %ld - %ld", (long int) linkP, (long int) usedLinkP,
- (long int) relP, (long int) usedRelP,
- (long int) commandP, (long int) usedCommandP);
+ LOGD("no more work to do %ld - %ld %ld - %ld %ld - %ld", (long int) linkP, (long int) usedLinkP,
+ (long int) relP, (long int) usedRelP,
+ (long int) commandP, (long int) usedCommandP);
// final cleanup
// ensure that we do not clean up twice in case used pointers opint to the original one
if(linkP==usedLinkP) usedLinkP=NULL;
- if(relP==usedRelP) usedRelP=NULL;
+ if(relP==usedRelP) usedRelP=NULL;
if(commandP==usedCommandP) usedCommandP=NULL;
cleanup((char**) &linkP, (char**) &relP, (char**) &commandP);
@@ -421,16 +458,16 @@ void doProvisioningWithSe(
// free the used pointers since all the necessary pointers point to new direction.
// when relation is self we need to give the previous command again and so we keep the
// data
-
- if(relP==NULL || strstr(relP, RELATION_SELF)==NULL)
+
+ if(relP==NULL || strstr(relP, RELATION_SELF)==NULL)
{
cleanup((char**) &usedLinkP, (char**) &usedRelP, (char**) &usedCommandP);
- }
+ }
// responseP can be freed at every round
free((void*)responseP);
responseP=NULL;
-
+
} // while
closeSeClientAndCleanup();
@@ -454,3 +491,4 @@ rootpaerror_t uploadTrustlet(uint8_t* containerDataP, uint32_t containerLength)
LOGE("uploadTrustlet, no callbackP_");
return ROOTPA_COMMAND_NOT_SUPPORTED;
}
+
diff --git a/mobicore/rootpa/Code/Common/registry.c b/mobicore/rootpa/Code/Common/registry.c
index b547f55..062bcb3 100644
--- a/mobicore/rootpa/Code/Common/registry.c
+++ b/mobicore/rootpa/Code/Common/registry.c
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -41,8 +41,8 @@ int regWriteAuthToken(const AUTHTOKENCONTAINERP atP, uint32_t containerSize)
int regReadAuthToken(AUTHTOKENCONTAINERP* atP, uint32_t* containerSize)
{
- *containerSize = CONTAINER_BUFFER_SIZE; // this will be updated to actual size with the registry call
- *atP=malloc(CONTAINER_BUFFER_SIZE);
+ *containerSize = CONTAINER_BUFFER_SIZE; // this will be updated to actual size with the registry call
+ *atP=(AUTHTOKENCONTAINERP)malloc(CONTAINER_BUFFER_SIZE);
if(NULL==*atP) return MC_DRV_ERR_NO_FREE_MEMORY;
return mcRegistryReadAuthToken(*atP, containerSize);
}
@@ -57,7 +57,7 @@ int regDeleteAuthToken(void)
int regReadRoot(ROOTCONTAINERP* rootP, uint32_t* containerSize)
{
*containerSize = CONTAINER_BUFFER_SIZE; // this will be updated to actual size with the registry call
- *rootP=malloc(CONTAINER_BUFFER_SIZE);
+ *rootP=(ROOTCONTAINERP)malloc(CONTAINER_BUFFER_SIZE);
if(NULL==*rootP) return MC_DRV_ERR_NO_FREE_MEMORY;
return mcRegistryReadRoot(*rootP, containerSize);
}
@@ -78,9 +78,9 @@ int regCleanupRoot(void)
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=malloc(CONTAINER_BUFFER_SIZE);
- if(NULL==*spP) return MC_DRV_ERR_NO_FREE_MEMORY;
+ *containerSize = CONTAINER_BUFFER_SIZE; // this will be updated to actual size with the registry call
+ *spP= (SPCONTAINERP)malloc(CONTAINER_BUFFER_SIZE);
+ if(NULL==*spP) return MC_DRV_ERR_NO_FREE_MEMORY;
return mcRegistryReadSp(spid, *spP, containerSize);
}
@@ -91,16 +91,17 @@ int regWriteSp(mcSpid_t spid, const SPCONTAINERP spP, uint32_t containerSize)
int regCleanupSp(mcSpid_t spid)
{
- return mcRegistryCleanupSp(spid);
+ return mcRegistryCleanupSp(spid);
}
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
- int ret=regReadSp(spid, &spP, &containerSize);
+ containerSize = CONTAINER_BUFFER_SIZE; // this will be updated to actual size with the registry call
+ ret=regReadSp(spid, &spP, &containerSize);
if(MC_DRV_OK==ret)
{
*stateP=spP->cont.attribs.state;
@@ -114,8 +115,8 @@ int regGetSpState(mcSpid_t spid, mcContainerState_t* stateP)
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=malloc(CONTAINER_BUFFER_SIZE);
+ *containerSize = CONTAINER_BUFFER_SIZE; // this will be update to actual size with the registry call
+ *tltP=(TLTCONTAINERP)malloc(CONTAINER_BUFFER_SIZE);
if(NULL==*tltP) return MC_DRV_ERR_NO_FREE_MEMORY;
return mcRegistryReadTrustletCon(uuidP, spid, *tltP, containerSize);
}
@@ -129,3 +130,26 @@ int regCleanupTlt(const mcUuid_t* uuidP, mcSpid_t spid)
{
return mcRegistryCleanupTrustlet(uuidP, spid);
}
+
+int regStoreTA(mcSpid_t spid, const mcUuid_t* uuidP, const uint8_t* taBinary, uint32_t taBinLength)
+{
+#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;
+}
diff --git a/mobicore/rootpa/Code/Common/registry.h b/mobicore/rootpa/Code/Common/registry.h
index 1760935..f81ff28 100644
--- a/mobicore/rootpa/Code/Common/registry.h
+++ b/mobicore/rootpa/Code/Common/registry.h
@@ -3,29 +3,29 @@ Copyright © Trustonic Limited 2013
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.
*/
@@ -62,3 +62,6 @@ int regGetSpState(mcSpid_t spid, mcContainerState_t* stateP);
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
diff --git a/mobicore/rootpa/Code/Common/seclient.c b/mobicore/rootpa/Code/Common/seclient.c
index e95cbc9..e08a7c7 100644
--- a/mobicore/rootpa/Code/Common/seclient.c
+++ b/mobicore/rootpa/Code/Common/seclient.c
@@ -3,35 +3,35 @@ Copyright © Trustonic Limited 2013
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 <string.h>
#include <stdlib.h>
-#include <stdbool.h>
+#include <wrapper.h>
#include <time.h>
#include <math.h>
@@ -68,11 +68,36 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
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;
-static const struct timespec SLEEPTIME={0,300*1000*1000}; // 0.3 seconds --> 30x0.3 = 9 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
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
+
rootpaerror_t httpPostAndReceiveCommand(const char* const inputP, const char** linkP, const char** relP, const char** commandP)
{
LOGD("httpPostAndReceiveCommand %ld", (long int) inputP);
@@ -104,14 +129,14 @@ rootpaerror_t httpDeleteAndReceiveCommand(const char** linkP, const char** relP,
}
-typedef struct
+typedef struct
{
char* memoryP;
size_t size;
} MemoryStruct;
+
-
-typedef struct
+typedef struct
{
char* linkP;
size_t linkSize;
@@ -119,7 +144,7 @@ typedef struct
size_t relSize;
} HeaderStruct;
-typedef struct
+typedef struct
{
const char* responseP;
size_t size;
@@ -135,7 +160,7 @@ static size_t readResponseCallback(void *ptr, size_t size, size_t nmemb, void *u
LOGD(">>readResponseCallback %d %d %d\n", (int) totalSize, (int) rspP->size, rspP->offset);
if(rspP->offset>=rspP->size) return 0;
-
+
if(totalSize<((rspP->size)))
{
readSize=totalSize;
@@ -152,32 +177,32 @@ static size_t readResponseCallback(void *ptr, size_t size, size_t nmemb, void *u
LOGD("<<readResponseCallback %d %d %d\n", (int) readSize, (int) rspP->size, rspP->offset);
return readSize;
}
-
+
static size_t writeMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsize = size * nmemb;
MemoryStruct* mem = (MemoryStruct *)userp;
-
- mem->memoryP = realloc(mem->memoryP, mem->size + realsize + 1);
+ mem->memoryP = (char*)realloc(mem->memoryP, mem->size + realsize + 1);
if (mem->memoryP == NULL) {
- /* out of memory! */
+ /* out of memory! */
LOGE("not enough memory (realloc returned NULL)\n");
return 0; // returning anything different from what was passed to this function indicates an error
}
-
+
memcpy(&(mem->memoryP[mem->size]), contents, realsize);
mem->size += realsize;
mem->memoryP[mem->size] = 0;
-
+
return realsize;
}
-
+
#ifdef __DEBUG
int debug_function (CURL * curl_handle, curl_infotype info, char* debugMessageP, size_t debugMessageSize, void * extrabufferP)
{
if(debugMessageP!=NULL && debugMessageSize!=0)
{
- char* msgP=malloc(debugMessageSize+1);
+ char* msgP=(char*)malloc(debugMessageSize+1);
+ if(NULL==msgP)return 0;
memcpy(msgP, debugMessageP, debugMessageSize);
msgP[debugMessageSize]=0;
LOGD("curl: %d %s",info, msgP);
@@ -193,20 +218,20 @@ int debug_function (CURL * curl_handle, curl_infotype info, char* debugMessageP,
bool copyHeader(void *contents, size_t length, char** headerP)
{
- *headerP = malloc(length + 1);
+ *headerP = (char *)malloc(length + 1);
if (*headerP == NULL) {
- /* out of memory! */
+ /* out of memory! */
LOGE("not enough memory (malloc returned NULL)\n");
return false;
}
-
+
memcpy(*headerP , contents, length);
- (*headerP)[length] = 0;
+ (*headerP)[length] = 0;
return true;
}
//
-// The header format is as follow
+// The header format is as follow
// Link <https://se.cgbe.trustonic.com:8443/activity/00000000-4455-6677-8899-aabbccddeeff>;rel="http://10.0.2.2/relation/system_info"
// parse out uri's specified in Link and rel
//
@@ -219,11 +244,11 @@ bool updateLinkAndRel(HeaderStruct* memP, void* ptr)
startP=strcasestr((char*) ptr, "Link");
if(NULL==startP) return false;
-
+
startP=strstr(startP,"<");
if(NULL==startP) return false;
startP++;
-
+
endP=strstr(startP,">");
if(NULL==endP) return false;
@@ -239,14 +264,14 @@ bool updateLinkAndRel(HeaderStruct* memP, void* ptr)
if(NULL==startP)
{
return true;
- }
+ }
startP+=5; // sizeof "rel="
-
+
endP=strstr(startP,"\"");
if(NULL==endP)
{
- return true;
- }
+ return true;
+ }
memP->relSize=endP-startP;
if(copyHeader(startP, memP->relSize, &(memP->relP))==false)
{
@@ -281,27 +306,27 @@ void setCertPath(const char* localPathP, const char* certPathP)
{
memset(certificatePath_, 0, CERT_PATH_MAX_LEN);
memset(certificateFilePath_, 0, CERT_PATH_MAX_LEN);
-
- if (certPathP!=NULL && (strlen(certPathP)+1)<CERT_PATH_MAX_LEN)
+
+ if (certPathP!=NULL && (strlen(certPathP)+1)<CERT_PATH_MAX_LEN)
{
- strcpy(certificatePath_, certPathP);
+ strlcpy(certificatePath_, certPathP, sizeof(certificatePath_));
}
-
- if (localPathP!=NULL && (strlen(localPathP)+1+sizeof(CECERT_FILENAME))<CERT_PATH_MAX_LEN)
+
+ if (localPathP!=NULL && (strlen(localPathP)+1+sizeof(CECERT_FILENAME))<CERT_PATH_MAX_LEN)
{
- strcpy(certificateFilePath_, localPathP);
- strcat(certificateFilePath_, "/");
+ strlcpy(certificateFilePath_, localPathP,sizeof(certificateFilePath_));
+ strlcat(certificateFilePath_, "/",sizeof(certificateFilePath_));
}
- strcat(certificateFilePath_, CECERT_FILENAME);
+ strlcat(certificateFilePath_, CECERT_FILENAME,sizeof(certificateFilePath_));
}
//
// TODO-refactor: saveCertFile is duplicate from saveFile in xmlMessageHandler.c, move these to common place
//
void saveCertFile(char* filePath, char* fileContent)
{
- 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
+ LOGD(">>saveCertFile %s", filePath);
+ 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);
fclose(fh);
@@ -315,19 +340,21 @@ void saveCertFile(char* filePath, char* 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;
}
-
+
/* reading response to memory instead of file */
if(curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writeMemoryCallback)!=CURLE_OK)
{
LOGE("curl_easy_setopt CURLOPT_WRITEFUNCTION failed");
return false;
}
-
+
if(curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, writeHeaderCallback)!=CURLE_OK)
{
LOGE("curl_easy_setopt CURLOPT_HEADERFUNCTION failed");
@@ -352,9 +379,9 @@ bool setBasicOpt(CURL* curl_handle, MemoryStruct* chunkP, HeaderStruct* headerCh
LOGE("curl_easy_setopt CURLOPT_HTTPHEADER failed");
return false;
}
-
+
/* some servers don't like requests that are made without a user-agent
- field, so we provide one */
+ field, so we provide one */
if(curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "rpa/1.0")!=CURLE_OK)
{
LOGE("curl_easy_setopt CURLOPT_USERAGENT failed");
@@ -369,7 +396,7 @@ bool setBasicOpt(CURL* curl_handle, MemoryStruct* chunkP, HeaderStruct* headerCh
saveCertFile(certificateFilePath_, CA_CERTIFICATES);
-
+
LOGD("curl_easy_setopt CURLOPT_CAINFO %s", certificateFilePath_);
if(curl_easy_setopt(curl_handle, CURLOPT_CAINFO, certificateFilePath_)!=CURLE_OK)
{
@@ -382,19 +409,18 @@ bool setBasicOpt(CURL* curl_handle, MemoryStruct* chunkP, HeaderStruct* headerCh
{
LOGE("curl_easy_setopt CURLOPT_CAPATH 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);
-
+ curl_easy_setopt(curl_handle, CURLOPT_DEBUGFUNCTION, debug_function);
+
if(strncmp(linkP, NONEXISTENT_TEST_URL, shorter(strlen(NONEXISTENT_TEST_URL), strlen(linkP)))==0)
{
se_connection_timeout=3L; // reducing the connection timeout for testing purposes
MAX_ATTEMPTS=1; // this is for testint code, we are using nonexitent url here so no unncessary attempts
LOGD("setBasicOpt timeout set to %ld", se_connection_timeout);
- }
+ }
#endif
if(curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, se_connection_timeout)!=CURLE_OK)
@@ -404,7 +430,7 @@ bool setBasicOpt(CURL* curl_handle, MemoryStruct* chunkP, HeaderStruct* headerCh
}
/** libcurl uses the http_proxy and https_proxy environment variables for proxy settings.
- That variable is set in the OS specific wrapper. These are left here in order to make
+ That variable is set in the OS specific wrapper. These are left here in order to make
this comment earier to be found in searches.
curl_easy_setopt(curl_handle,CURLOPT_PROXY, "http://proxyaddress");
@@ -412,7 +438,7 @@ bool setBasicOpt(CURL* curl_handle, MemoryStruct* chunkP, HeaderStruct* headerCh
curl_easy_setopt(curl_handle,CURLOPT_PROXYUSERNAME, "read_proxy_username");
curl_easy_setopt(curl_handle,CURLOPT_PROXYPASSWORD, "read_proxy_password");
*/
-
+
return true;
}
@@ -420,6 +446,7 @@ bool setBasicOpt(CURL* curl_handle, MemoryStruct* chunkP, HeaderStruct* headerCh
bool setPutOpt(CURL* curl_handle, ResponseStruct* responseChunk)
{
+ long chunkSize=responseChunk->size;
LOGD(">>setPutOpt");
if (curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, readResponseCallback)!=CURLE_OK)
{
@@ -445,13 +472,13 @@ bool setPutOpt(CURL* curl_handle, ResponseStruct* responseChunk)
return false;
}
- long s=responseChunk->size;
- if (curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE, s)!=CURLE_OK)
+
+ if (curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE, chunkSize)!=CURLE_OK)
{
LOGE("curl_easy_setopt CURLOPT_INFILESIZE_LARGE failed");
return false;
}
-
+
LOGD("<<setPutOpt");
return true;
}
@@ -459,14 +486,14 @@ bool setPutOpt(CURL* curl_handle, ResponseStruct* responseChunk)
bool setPostOpt(CURL* curl_handle, const char* inputP)
{
LOGD(">>setPostOpt %ld %d", (long int) inputP, inputP?(int)strlen(inputP):0);
-
+
if (curl_easy_setopt(curl_handle, CURLOPT_POST, 1L)!=CURLE_OK)
{
LOGE("curl_easy_setopt CURLOPT_POST failed");
return false;
}
- if(NULL==inputP)
+ if(NULL==inputP)
{
if (curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, 0L)!=CURLE_OK)
{
@@ -474,7 +501,7 @@ bool setPostOpt(CURL* curl_handle, const char* inputP)
return false;
}
}
-
+
if (curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, (void*) inputP)!=CURLE_OK)
{
LOGE("curl_easy_setopt CURLOPT_POSTFIELDS failed");
@@ -539,6 +566,14 @@ rootpaerror_t httpCommunicate(const char * const inputP, const char** linkP, con
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)
{
@@ -548,17 +583,8 @@ rootpaerror_t httpCommunicate(const char * const inputP, const char** linkP, con
*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 = malloc(1); /* will be grown as needed by the realloc above */
+ chunk.size = 0; /* no data at this point */
+ chunk.memoryP = (char *)malloc(1); /* will be grown as needed by the realloc above */
if(NULL==chunk.memoryP)
{
return ROOTPA_ERROR_OUT_OF_MEMORY;
@@ -566,7 +592,7 @@ rootpaerror_t httpCommunicate(const char * const inputP, const char** linkP, con
chunk.memoryP[0]=0;
LOGD("HTTP method %d", method);
-
+
//Process HTTP methods
if(method == httpMethod_PUT)
{
@@ -609,24 +635,28 @@ rootpaerror_t httpCommunicate(const char * const inputP, const char** linkP, con
}
}
- /* disable Expect: 100-continue since it creates problems with some proxies, it is only related to post but we do it here for simplicity */
+ /* disable Expect: 100-continue since it creates problems with some proxies, it is only related to post but we do it here for simplicity */
httpHeaderP = curl_slist_append(httpHeaderP, "Expect:");
httpHeaderP = curl_slist_append(httpHeaderP, "Content-Type: application/vnd.mcorecm+xml;v=1.0");
- httpHeaderP = curl_slist_append(httpHeaderP, "Accept: application/vnd.mcorecm+xml;v=1.0");
+ httpHeaderP = curl_slist_append(httpHeaderP, "Accept: application/vnd.mcorecm+xml;v=1.0");
if(setBasicOpt(curl_handle_, &chunk, &headerChunk, *linkP, httpHeaderP)==false)
{
LOGE("setBasicOpt failed");
free(chunk.memoryP);
- return ROOTPA_ERROR_NETWORK;
+ return ROOTPA_ERROR_NETWORK;
}
- begintime=time(NULL);
+ begintime=time(NULL);
while(curlRet!=CURLE_OK && attempts++ < MAX_ATTEMPTS)
{
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);
@@ -638,37 +668,37 @@ rootpaerror_t httpCommunicate(const char * const inputP, const char** linkP, con
}
curl_easy_getinfo (curl_handle_, CURLINFO_RESPONSE_CODE, &http_code);
- if(curlRet!=CURLE_OK)
+ if(curlRet!=CURLE_OK)
{
LOGE("curl_easy_perform failed %ld", curlRet);
free(chunk.memoryP);
free(headerChunk.linkP);
free(headerChunk.relP);
- curl_easy_reset(curl_handle_);
+ curl_easy_reset(curl_handle_);
return ROOTPA_ERROR_NETWORK;
}
-
+
LOGD("http return code from SE %ld", (long int) http_code);
- if ((200 <= http_code && http_code < 300))
+ if ((200 <= http_code && http_code < 300))
{
- ret=ROOTPA_OK;
+ ret=ROOTPA_OK;
}
- else if (HTTP_CODE_BAD_REQUEST == http_code ||
- HTTP_CODE_METHOD_NOT_ALLOWED == http_code ||
- HTTP_CODE_NOT_ACCEPTABLE == http_code ||
- HTTP_CODE_CONFLICT == http_code ||
+ else if (HTTP_CODE_BAD_REQUEST == http_code ||
+ HTTP_CODE_METHOD_NOT_ALLOWED == http_code ||
+ HTTP_CODE_NOT_ACCEPTABLE == http_code ||
+ HTTP_CODE_CONFLICT == http_code ||
HTTP_CODE_LENGTH_REQUIRED == http_code ||
HTTP_CODE_TOO_LONG == http_code ||
HTTP_CODE_UNSUPPORTED_MEDIA == http_code ||
HTTP_CODE_INVALID_DATA == http_code ||
- HTTP_CODE_INTERNAL_ERROR == http_code ||
+ HTTP_CODE_INTERNAL_ERROR == http_code ||
HTTP_CODE_HTTP_VERSION == http_code)
{
LOGE("SE returned http error %ld", (long int) http_code);
ret=ROOTPA_ERROR_INTERNAL;
}
else if(HTTP_CODE_MOVED == http_code || // new URL would be in Location: header but RootPA does not support in currently (unless libcurl supports it transparently)
- HTTP_CODE_REQUEST_TIMEOUT == http_code ||
+ HTTP_CODE_REQUEST_TIMEOUT == http_code ||
HTTP_CODE_SERVICE_UNAVAILABLE == http_code)
{
LOGE("SE returned http error %ld", (long int) http_code);
@@ -678,7 +708,7 @@ rootpaerror_t httpCommunicate(const char * const inputP, const char** linkP, con
{
LOGE("SE returned http error %ld", (long int) http_code);
ret=ROOTPA_ERROR_SE_CMP_VERSION;
- }
+ }
else if (HTTP_CODE_FAILED_DEPENDENCY == http_code)
{
LOGE("SE returned http error %ld", (long int) http_code);
@@ -687,26 +717,27 @@ rootpaerror_t httpCommunicate(const char * const inputP, const char** linkP, con
else if (HTTP_CODE_NOT_FOUND == http_code)
{
LOGE("SE returned http error %ld", (long int) http_code);
- ret=ROOTPA_ERROR_ILLEGAL_ARGUMENT; // since the arguments (spid, in some cases uuid) for the URL are received from the client,
- // this can be returned. It is also possible that suid is wrong (corrupted in device or info
+ ret=ROOTPA_ERROR_ILLEGAL_ARGUMENT; // since the arguments (spid, in some cases uuid) for the URL are received from the client,
+ // this can be returned. It is also possible that suid is wrong (corrupted in device or info
// from device binding missing from SE, but we can not detect that easily.
}
else
{
LOGE("unexpected http return code from SE %ld", (long int)http_code);
- ret=ROOTPA_ERROR_NETWORK;
+ ret=ROOTPA_ERROR_NETWORK;
}
-
- /* cleanup curl stuff */
-
+
+ /* cleanup curl stuff */
+
*commandP=chunk.memoryP; // this needs to be freed by client
*linkP=headerChunk.linkP; // this needs to be freed by client
*relP=headerChunk.relP; // this needs to be freed by client
- if (httpHeaderP) curl_slist_free_all(httpHeaderP); // since we disabled some headers
+ if (httpHeaderP) curl_slist_free_all(httpHeaderP); // since we disabled some headers
curl_easy_reset(curl_handle_);
LOGD("%lu bytes retrieved\n", (long)chunk.size);
-
- LOGD("<<httpCommunicate %d %ld %ld", (int) ret, (long int) http_code, (long int) curlRet);
+
+ LOGD("<<httpCommunicate %d %ld %ld", (int) ret, (long int) http_code, (long int) curlRet);
return ret;
}
+
diff --git a/mobicore/rootpa/Code/Common/tools.h b/mobicore/rootpa/Code/Common/tools.h
index 3722c52..46dd0d9 100644
--- a/mobicore/rootpa/Code/Common/tools.h
+++ b/mobicore/rootpa/Code/Common/tools.h
@@ -32,9 +32,22 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef OWNTOOLS_H
#define OWNTOOLS_H
+#ifdef WIN32
+
+#include <windows.h>
+
+#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))
+
+#else
+
#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
diff --git a/mobicore/rootpa/Code/Common/trustletchannel.c b/mobicore/rootpa/Code/Common/trustletchannel.c
index ae1f957..37ca308 100644
--- a/mobicore/rootpa/Code/Common/trustletchannel.c
+++ b/mobicore/rootpa/Code/Common/trustletchannel.c
@@ -3,33 +3,38 @@ Copyright © Trustonic Limited 2013
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 <string.h>
+#ifdef WIN32
+ #include <cstring>
+ #include <sys/stat.h>
+#endif
+#include <wrapper.h>
#include <stdlib.h>
#include <TlCm/tlCmUuid.h>
#include "tools.h"
@@ -42,13 +47,96 @@ start using other than default device id if need arises */
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 handle = (CMTHANDLE)malloc(sizeof(CMTSTRUCT));
+CMTHANDLE tltChannelOpen(int sizeOfWsmBuffer, mcResult_t* result)
+{
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 ))
{
@@ -58,33 +146,42 @@ CMTHANDLE tltChannelOpen(int sizeOfWsmBuffer, mcResult_t* result){
memset(handle,0,sizeof(CMTSTRUCT));
-#if ! ( defined(LINUX) || (defined(WIN32) && defined(_TEST_SUITE)) )
-
*result = mcOpenDevice(tltChannelDeviceId);
- if (MC_DRV_OK != *result)
+ if (MC_DRV_OK != *result)
{
- LOGE("tltChannelOpen: Unable to open device, error: %d", *result);
+ LOGE("taChannelOpen: 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)
+ if (MC_DRV_OK != *result)
{
- LOGE("tltChannelOpen: Allocation of CMP WSM failed, error: %d", *result);
+ LOGE("taChannelOpen: Allocation of CMP WSM failed, error: %d", *result);
mcCloseDevice(tltChannelDeviceId);
free(handle);
return NULL;
}
- *result = mcOpenSession(&handle->session,(const mcUuid_t *)&UUID,handle->wsmP,(uint32_t)sizeOfWsmBuffer);
+ 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
+ }
+
if (MC_DRV_OK != *result)
{
- LOGE("tltChannelOpen: Open session failed, error: %d", *result);
+ LOGE("taChannelOpen: Open session failed, error: %d", *result);
mcFreeWsm(tltChannelDeviceId,handle->wsmP);
mcCloseDevice(tltChannelDeviceId);
free(handle);
@@ -93,6 +190,7 @@ CMTHANDLE tltChannelOpen(int sizeOfWsmBuffer, mcResult_t* result){
return handle;
}
+
/*
Close the communication channel and free resources
*/
@@ -102,26 +200,24 @@ void tltChannelClose(CMTHANDLE handle){
if (!bad_read_ptr(handle,sizeof(CMTSTRUCT)))
{
result = mcCloseSession(&handle->session);
- if (MC_DRV_OK != result)
+ if (MC_DRV_OK != result)
{
LOGE("tltChannelClose: Closing session failed:, error: %d", result);
}
if (NULL!=handle->wsmP) mcFreeWsm(tltChannelDeviceId, handle->wsmP);
-#if ! ( defined(LINUX) || (defined(WIN32) && defined(_TEST_SUITE)) )
result = mcCloseDevice(tltChannelDeviceId);
- if (MC_DRV_OK != result)
+ if (MC_DRV_OK != result)
{
LOGE("tltChannelClose: Closing MobiCore device failed, error: %d", result);
}
-#endif
free(handle);
}
}
/*
-Initiate transfer of the data between NWD and SWD. The actual data needs to be copied to wsmP beforehand
+Initiate transfer of the data between NWD and SWD. The actual data needs to be copied to wsmP beforehand
(and from it afterwards in case of response)
*/
bool tltChannelTransmit(CMTHANDLE handle, int timeout){
@@ -141,7 +237,7 @@ bool tltChannelTransmit(CMTHANDLE handle, int timeout){
handle->lasterror = mcWaitNotification(&handle->session, timeout);
- if (unlikely( MC_DRV_OK!=handle->lasterror ))
+ if (unlikely( MC_DRV_OK!=handle->lasterror ))
{
LOGE("tltChannelTransmit: Wait for response notification failed, error: %d", handle->lasterror);
return false;
diff --git a/mobicore/rootpa/Code/Common/trustletchannel.h b/mobicore/rootpa/Code/Common/trustletchannel.h
index bec2961..9840075 100644
--- a/mobicore/rootpa/Code/Common/trustletchannel.h
+++ b/mobicore/rootpa/Code/Common/trustletchannel.h
@@ -3,36 +3,37 @@ Copyright © Trustonic Limited 2013
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.
*/
#ifndef TRUSTLETCHANNEL_H
#define TRUSTLETCHANNEL_H
-#include<stdbool.h>
+#include<wrapper.h>
+
#include<MobiCoreDriverApi.h>
typedef struct cmtstruct CMTSTRUCT;
@@ -55,6 +56,11 @@ Open session to content management trustlet and allocate enough memory for commu
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);
/**
diff --git a/mobicore/rootpa/Code/Common/xmlmessagehandler.c b/mobicore/rootpa/Code/Common/xmlmessagehandler.c
index 136e3e7..4383d02 100644
--- a/mobicore/rootpa/Code/Common/xmlmessagehandler.c
+++ b/mobicore/rootpa/Code/Common/xmlmessagehandler.c
@@ -3,41 +3,41 @@ Copyright © Trustonic Limited 2013
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 <string.h>
#include <stdlib.h>
#include <stdio.h>
-#include <stdbool.h>
+#include <wrapper.h>
#include <stdint.h>
-#include <libxml/parser.h>
-#include <libxml/valid.h>
-#include <libxml/xmlschemas.h>
+#include <libxml/parser.h>
+#include <libxml/valid.h>
+#include <libxml/xmlschemas.h>
#include <mcVersionInfo.h>
@@ -48,10 +48,10 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
#include "provisioningengine.h"
#include "base64.h"
-#define ENROLLMENT_SERVICE_NS_PREFIX 0 // "mces"
+#define ENROLLMENT_SERVICE_NS_PREFIX 0 // "mces"
#define ENROLLMENT_SERVICE_NAMESPACE "http://www.mcore.gi-de.com/2012/04/schema/EnrollmentService"
-#define PLATFORM_TYPES_NS_PREFIX "mcpt"
+#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 256
@@ -75,13 +75,12 @@ static char enrollmentServiceFullPath_[XSD_PATH_MAX_LEN];
static char platformTypesFullPath_[XSD_PATH_MAX_LEN];
static xmlNsPtr nameSpace_=NULL;
static xmlNsPtr typesNameSpace_=NULL;
-
// file internal functions
xmlDocPtr createXmlResponse()
{
- xmlDocPtr docP = NULL;
- xmlNodePtr root_node = NULL;
+ xmlDocPtr docP = NULL;
+ xmlNodePtr root_node = NULL;
docP = xmlNewDoc(BAD_CAST "1.0");
root_node = xmlNewNode(nameSpace_, BAD_CAST "ContentManagementResponse");
@@ -96,14 +95,15 @@ 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;
- char* element="encryptedKey";
+ element ="encryptedKey";
if(tltBin)
{
element="tltBin";
}
-
+
if(xmlNewChild(trustletDataNode, nameSpace_, BAD_CAST element, BAD_CAST contentP)==NULL ) return false;
return true;
}
@@ -127,7 +127,7 @@ char* errorCodeToString(rootpaerror_t errorCode)
case ROOTPA_ERROR_REGISTRY:
return STRING_ROOTPA_ERROR_REGISTRY;
-
+
case ROOTPA_ERROR_MOBICORE_CONNECTION:
return STRING_ROOTPA_ERROR_MOBICORE_CONNECTION;
@@ -142,7 +142,7 @@ char* errorCodeToString(rootpaerror_t errorCode)
case ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE:
return STRING_ROOTPA_ERROR_REGISTRY_OBJECT_NOT_AVAILABLE;
-
+
}
LOGD("errorCodeToString: unknown error code %d", errorCode);
return STRING_ROOTPA_ERROR_INTERNAL;
@@ -150,12 +150,13 @@ char* errorCodeToString(rootpaerror_t errorCode)
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;
- bool retValue=true;
- char intBuffer[INT_BUFFER_LENGTH];
-
+ retValue=true;
snprintf(intBuffer,INT_BUFFER_LENGTH,"%u",(uint32_t) id);
if(xmlNewProp(commandResultNode, BAD_CAST "id", BAD_CAST intBuffer)==NULL) return false;
@@ -165,14 +166,14 @@ bool addCommandResultData(xmlNodePtr resultListNode, int id, char* commandResul
if( NULL==errorNode ) return false; // CommandExecutionError
if(xmlNewProp(errorNode, BAD_CAST "errorCode", BAD_CAST errorCodeToString(errorCode))==NULL)
- {
+ {
retValue=false;
- }
+ }
else if(errorDetail!=0)
{
snprintf(intBuffer,INT_BUFFER_LENGTH,"%u",errorDetail);
if(xmlNewProp(errorNode, BAD_CAST "errorDetail", BAD_CAST intBuffer)==NULL)
- {
+ {
retValue=false;
}
}
@@ -180,7 +181,7 @@ bool addCommandResultData(xmlNodePtr resultListNode, int id, char* commandResul
else
{
if(xmlNewChild(commandResultNode, nameSpace_, BAD_CAST "resultValue", BAD_CAST commandResultP)==NULL )
- {
+ {
retValue=false;
}
}
@@ -190,25 +191,29 @@ bool addCommandResultData(xmlNodePtr resultListNode, int id, char* commandResul
xmlNodePtr findFirstCommandNode(xmlDocPtr xmlDocP)
{
- xmlNodePtr rootElementP = xmlDocGetRootElement(xmlDocP);
+ xmlNodePtr commandsNodeP;
+ xmlNodePtr rootElementP;
+
+ rootElementP = xmlDocGetRootElement(xmlDocP);
if(NULL==rootElementP) return NULL;
- xmlNodePtr commandsNodeP=rootElementP->children;
- for (; commandsNodeP; commandsNodeP = commandsNodeP->next)
+ commandsNodeP=rootElementP->children;
+ for (; commandsNodeP; commandsNodeP = commandsNodeP->next)
{
- if (commandsNodeP->type == XML_ELEMENT_NODE && strcmp((char*)commandsNodeP->name, "commands")==0)
+ if (commandsNodeP->type == XML_ELEMENT_NODE && strcmp((char*)commandsNodeP->name, "commands")==0)
{
break;
}
}
- if(NULL==commandsNodeP) return NULL;
+ if(NULL==commandsNodeP) return NULL;
return commandsNodeP->children;
}
xmlNodePtr getNextCommand(xmlDocPtr xmlDocP, xmlNodePtr prevNode)
{
- LOGD(">> getNextCommand %ld %ld", (long int) xmlDocP, (long int) prevNode);
xmlNodePtr firstNode;
+ xmlNodePtr commandNode;
+ LOGD(">> getNextCommand %ld %ld", (long int) xmlDocP, (long int) prevNode);
if(NULL==prevNode)
{
firstNode=findFirstCommandNode(xmlDocP);
@@ -218,10 +223,9 @@ xmlNodePtr getNextCommand(xmlDocPtr xmlDocP, xmlNodePtr prevNode)
firstNode=prevNode->next;
}
- xmlNodePtr commandNode;
- for (commandNode = firstNode; commandNode; commandNode = commandNode->next)
+ for (commandNode = firstNode; commandNode; commandNode = commandNode->next)
{
- if (commandNode->type == XML_ELEMENT_NODE && strcmp((char*)commandNode->name, "command")==0)
+ if (commandNode->type == XML_ELEMENT_NODE && strcmp((char*)commandNode->name, "command")==0)
{
break;
}
@@ -233,21 +237,25 @@ xmlNodePtr getNextCommand(xmlDocPtr xmlDocP, xmlNodePtr prevNode)
int getCommandId(xmlNodePtr commandNode)
{
- xmlChar* idP=xmlGetProp(commandNode, BAD_CAST "id");
+ int id;
+ xmlChar* idP;
+ idP=xmlGetProp(commandNode, BAD_CAST "id");
if(NULL==idP)
{
return UNKNOWN_ID;
}
- int id=atoi((char*)idP);
+ id=atoi((char*)idP);
xmlFree(idP);
return id;
}
commandtype_t getCommandType(xmlNodePtr commandNode)
{
+ xmlChar* typeP;
+ commandtype_t type;
if(NULL==commandNode) return UNKNOWN_TYPE;
- xmlChar* typeP=xmlGetProp(commandNode, BAD_CAST "type");
- commandtype_t type=UNKNOWN_TYPE;
+ typeP=xmlGetProp(commandNode, BAD_CAST "type");
+ type=UNKNOWN_TYPE;
if(typeP!=NULL)
{
if(strcmp((char*)typeP,"CMP")==0) type=CMP;
@@ -257,7 +265,7 @@ commandtype_t getCommandType(xmlNodePtr commandNode)
}
else
{
- LOGE("type property does not exist");
+ LOGE("type property does not exist");
}
return type;
}
@@ -269,15 +277,15 @@ char* getCommandValue(xmlNodePtr commandNode)
{
xmlNodePtr commandValueNodeP=commandNode->children;
- for (; commandValueNodeP; commandValueNodeP = commandValueNodeP->next)
+ for (; commandValueNodeP; commandValueNodeP = commandValueNodeP->next)
{
- if (commandValueNodeP->type == XML_ELEMENT_NODE && strcmp((char*)commandValueNodeP->name, "commandValue")==0)
+ if (commandValueNodeP->type == XML_ELEMENT_NODE && strcmp((char*)commandValueNodeP->name, "commandValue")==0)
{
break;
}
}
- if(NULL==commandValueNodeP) return NULL;
-
+ if(NULL==commandValueNodeP) return NULL;
+
return (char*) xmlNodeGetContent(commandValueNodeP);
}
@@ -295,13 +303,13 @@ bool getCommandIgnoreError(xmlNodePtr commandNode)
xmlFree(attribute);
}
- return ignoreError;
+ return ignoreError;
}
void getValues(xmlNodePtr commandNodeP, commandtype_t* commandTypeP, uint32_t* idP, char** commandValueP, bool* ignoreErrorP)
{
*commandTypeP=getCommandType(commandNodeP);
- *idP=getCommandId(commandNodeP);
+ *idP=getCommandId(commandNodeP);
*commandValueP=(char*) getCommandValue(commandNodeP);
*ignoreErrorP=getCommandIgnoreError(commandNodeP);
}
@@ -309,17 +317,17 @@ void getValues(xmlNodePtr commandNodeP, commandtype_t* commandTypeP, uint32_t* i
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=realloc(localCommandsP, sizeof(CmpMessage)*(numberOfCmpCommands+1));
+ CmpMessage* tmpCommandsP=(CmpMessage*)realloc(localCommandsP, sizeof(CmpMessage)*(numberOfCmpCommands+1));
if(tmpCommandsP!=NULL)
{
localCommandsP=tmpCommandsP;
- *cmpCommandsP=localCommandsP;
-
+ *cmpCommandsP=localCommandsP;
+
memset(&(localCommandsP[numberOfCmpCommands]), 0,sizeof(CmpMessage));
if(commandValueP)
{
- localCommandsP[numberOfCmpCommands].length= base64DecodeStringRemoveEndZero(commandValueP,
+ localCommandsP[numberOfCmpCommands].length= base64DecodeStringRemoveEndZero(commandValueP,
(char**) &(localCommandsP[numberOfCmpCommands].contentP));
if(0==localCommandsP[numberOfCmpCommands].length)
{
@@ -332,12 +340,12 @@ uint32_t extractCmpCommand(CmpMessage** cmpCommandsP, uint32_t numberOfCmpComman
else
{
localCommandsP[numberOfCmpCommands].hdr.ret=ROOTPA_ERROR_XML;
- }
+ }
}
else
{
LOGE("handleCmpCommand: was not able to realloc");
- // In this case we can not return an error to SE unless we set some of the earlier errors.
+ // In this case we can not return an error to SE unless we set some of the earlier errors.
if(!ignoreError)
{
free(*cmpCommandsP);
@@ -350,23 +358,24 @@ uint32_t extractCmpCommand(CmpMessage** cmpCommandsP, uint32_t numberOfCmpComman
rootpaerror_t handleCmpResponses(uint32_t maxNumberOfCmpResponses, CmpMessage* cmpResponsesP, xmlNodePtr rspResultElementP)
{
- LOGD(">>handleCmpResponses %d", maxNumberOfCmpResponses);
rootpaerror_t ret=ROOTPA_OK;
uint32_t i;
- if(cmpResponsesP == NULL)
+ LOGD(">>handleCmpResponses %d", maxNumberOfCmpResponses);
+
+ if(cmpResponsesP == NULL)
{
if(maxNumberOfCmpResponses>0)
{
LOGE("maxNumberOfCmpResponses %d while pointer is NULL", maxNumberOfCmpResponses);
return ROOTPA_ERROR_INTERNAL;
- }
+ }
return ROOTPA_OK;
- }
+ }
for(i=0; (i<maxNumberOfCmpResponses) && (ROOTPA_OK==ret); i++)
{
char* encodedResponseP=NULL;
- if((ROOTPA_ERROR_COMMAND_EXECUTION==cmpResponsesP[i].hdr.ret ||
+ if((ROOTPA_ERROR_COMMAND_EXECUTION==cmpResponsesP[i].hdr.ret ||
ROOTPA_OK==cmpResponsesP[i].hdr.ret) && cmpResponsesP[i].contentP!=NULL)
{
encodedResponseP=base64EncodeAddEndZero((char*) cmpResponsesP[i].contentP, cmpResponsesP[i].length);
@@ -394,17 +403,18 @@ rootpaerror_t handleCmpResponses(uint32_t maxNumberOfCmpResponses, CmpMessage* c
return ret;
}
-uint32_t handleUploadCommand(commandtype_t commandType,
- CommonMessage** uploadCommandsP,
- uint32_t numberOfUploadCommands,
- uint32_t id,
- char* commandValueP,
+uint32_t handleUploadCommand(commandtype_t commandType,
+ CommonMessage** uploadCommandsP,
+ uint32_t numberOfUploadCommands,
+ uint32_t id,
+ char* commandValueP,
bool ignoreError)
{
- LOGD(">>handleUploadCommand %d %lx %lx", commandType, (long int) uploadCommandsP, (long int) *uploadCommandsP);
+ uint8_t* containerDataP = NULL;
+ int containerLength;
CommonMessage* localCommandsP=*uploadCommandsP; // localCommandsP is just to make the code a bit more readable
- CommonMessage* tmpCommandsP=realloc(localCommandsP, sizeof(CommonMessage)*(numberOfUploadCommands+1));
-
+ CommonMessage* tmpCommandsP=(CommonMessage*)realloc(localCommandsP, sizeof(CommonMessage)*(numberOfUploadCommands+1));
+ LOGD(">>handleUploadCommand %d %lx %lx", commandType, (long int) uploadCommandsP, (long int) *uploadCommandsP);
if(NULL == tmpCommandsP)
{
LOGE("handleUploadCommand: was not able to realloc, returning %d", ignoreError);
@@ -415,13 +425,13 @@ uint32_t handleUploadCommand(commandtype_t commandType,
numberOfUploadCommands=0;
}
return numberOfUploadCommands;
- // In this case we can not return an error to SE unless we set some of the earlier errors.
+ // In this case we can not return an error to SE unless we set some of the earlier errors.
}
-
+
localCommandsP=tmpCommandsP;
*uploadCommandsP=localCommandsP;
memset(&(localCommandsP[numberOfUploadCommands]), 0,sizeof(CommonMessage));
-
+
if(NULL == commandValueP)
{
localCommandsP[numberOfUploadCommands++].ret=ROOTPA_ERROR_XML;
@@ -429,29 +439,29 @@ uint32_t handleUploadCommand(commandtype_t commandType,
}
localCommandsP[numberOfUploadCommands].ret=ROOTPA_OK;
- uint8_t* containerDataP = NULL;
- int containerLength= base64DecodeStringRemoveEndZero(commandValueP, (char**) &(containerDataP));
+
+ containerLength= base64DecodeStringRemoveEndZero(commandValueP, (char**) &(containerDataP));
if(0 == containerLength)
{
LOGE("handleUploadCommand: base64 decoding failed");
localCommandsP[numberOfUploadCommands].ret=ROOTPA_ERROR_INTERNAL;
}
-
+
if(TLT_UPLOAD == commandType)
{
localCommandsP[numberOfUploadCommands].ret = uploadTrustlet(containerDataP, containerLength);
}
else if (SO_UPLOAD == commandType)
- {
- localCommandsP[numberOfUploadCommands].ret = uploadSo(containerDataP,
- containerLength,
+ {
+ localCommandsP[numberOfUploadCommands].ret = uploadSo(containerDataP,
+ containerLength,
&localCommandsP[numberOfUploadCommands].intRet);
}
else
{
LOGE("handleUploadCommand: unknown command type %d this should not have happened", commandType);
- localCommandsP[numberOfUploadCommands].ret=ROOTPA_ERROR_INTERNAL;
+ localCommandsP[numberOfUploadCommands].ret=ROOTPA_ERROR_INTERNAL;
}
free(containerDataP);
localCommandsP[numberOfUploadCommands].id=id;
@@ -464,11 +474,12 @@ uint32_t handleUploadCommand(commandtype_t commandType,
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;
- if(uploadResponsesP == NULL)
+ LOGD(">>handleUploadResponses %d", numberOfUploadResponses);
+
+ if(uploadResponsesP == NULL)
{
if(numberOfUploadResponses>0)
{
@@ -483,17 +494,17 @@ rootpaerror_t handleUploadResponses(uint32_t numberOfUploadResponses, CommonMess
char* encodedResponseP=NULL;
if(ROOTPA_OK == uploadResponsesP[i].ret)
{
- // in success case TLT_UPLOAD and SO_UPLOAD return "0" (encoded) in the resultValue
+ // in success case TLT_UPLOAD and SO_UPLOAD return "0" (encoded) in the resultValue
// field (discussed and agreed with Dimi Jan 10, 2013)
encodedResponseP=base64EncodeAddEndZero(&zero, 1);
}
-
+
if( addCommandResultData(rspResultElementP, uploadResponsesP[i].id, encodedResponseP, uploadResponsesP[i].ret, uploadResponsesP[i].intRet )==false)
{
ret=ROOTPA_ERROR_XML;
}
free(encodedResponseP);
-
+
LOGD("handleUploadResponses, in loop idx %d ret %d ignore %d", i, uploadResponsesP[i].ret , uploadResponsesP[i].ignoreError);
if(uploadResponsesP[i].ret != ROOTPA_OK && false == uploadResponsesP[i].ignoreError)
{
@@ -507,13 +518,10 @@ rootpaerror_t handleUploadResponses(uint32_t numberOfUploadResponses, CommonMess
rootpaerror_t handleCommandAndFillResponse(xmlDocPtr xmlCommandP, xmlDocPtr xmlResponseP)
{
- LOGD(">>handleCommandAndFillResponse");
rootpaerror_t ret=ROOTPA_OK;
rootpaerror_t tmpRet=ROOTPA_OK;
-
- xmlNodePtr rspRootElementP = xmlDocGetRootElement(xmlResponseP);
- if(NULL==rspRootElementP) return ROOTPA_ERROR_XML;
-
+ xmlNodePtr rspRootElementP;
+
CmpMessage* cmpCommandsP=NULL;
CommonMessage* uploadCommandsP=NULL;
@@ -523,22 +531,29 @@ rootpaerror_t handleCommandAndFillResponse(xmlDocPtr xmlCommandP, xmlDocPtr xmlR
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
-
+
while((commandNode=getNextCommand(xmlCommandP, commandNode))!=NULL)
{
getValues(commandNode, &commandType, &id, &commandValueP, &ignoreError);
switch(commandType)
{
case CMP:
- {
+ {
numberOfCmpCommands=extractCmpCommand(&cmpCommandsP, numberOfCmpCommands, id, commandValueP, ignoreError);
if(0==numberOfCmpCommands)
{
- ret=ROOTPA_ERROR_OUT_OF_MEMORY;
+ ret=ROOTPA_ERROR_OUT_OF_MEMORY;
}
break;
}
@@ -549,9 +564,9 @@ rootpaerror_t handleCommandAndFillResponse(xmlDocPtr xmlCommandP, xmlDocPtr xmlR
if(0==numberOfUploadCommands)
{
ret=ROOTPA_ERROR_OUT_OF_MEMORY;
- }
+ }
break;
- default:
+ default:
LOGE("handleCommandAndFillResponse: received unknown command");
// we will still work with the other commands in case there are any
break;
@@ -559,21 +574,18 @@ rootpaerror_t handleCommandAndFillResponse(xmlDocPtr xmlCommandP, xmlDocPtr xmlR
xmlFree(commandValueP);
if(ROOTPA_ERROR_OUT_OF_MEMORY == ret) break;
-
- if(commandType != CMP &&
- false == ignoreError &&
+
+ if(commandType != CMP &&
+ false == ignoreError &&
uploadCommandsP &&
uploadCommandsP[numberOfUploadCommands-1].ret != ROOTPA_OK) break; // since upload commands are already executed in this loop
}
// execute the actual content management protocol commands, if there are any
-
- CmpMessage* cmpResponsesP=NULL;
if(cmpCommandsP)
{
uint32_t internalError;
- cmpResponsesP=malloc(sizeof(CmpMessage)*numberOfCmpCommands);
- memset(cmpResponsesP, 0, sizeof(CmpMessage)*numberOfCmpCommands);
+ cmpResponsesP=(CmpMessage *)malloc(sizeof(CmpMessage)*numberOfCmpCommands);
if(NULL==cmpResponsesP)
{
@@ -581,40 +593,40 @@ rootpaerror_t handleCommandAndFillResponse(xmlDocPtr xmlCommandP, xmlDocPtr xmlR
}
else
{
+ memset(cmpResponsesP, 0, sizeof(CmpMessage)*numberOfCmpCommands);
tmpRet=executeContentManagementCommands(numberOfCmpCommands, cmpCommandsP, cmpResponsesP, &internalError);
if(ROOTPA_OK!=tmpRet)
{
LOGE("call to executeContentManagementCommands failed with %d, continuing anyway", tmpRet);
// return code from executeContentManagementCommands is here more informative than anything else
- // even in an error case we need to return response to SE, the errors are also included in the
+ // even in an error case we need to return response to SE, the errors are also included in the
// actual CMP messages.
ret=tmpRet;
}
}
}
-
+
// fill response
if (ret!=ROOTPA_ERROR_OUT_OF_MEMORY)
{
xmlNodePtr resultListNodeP=xmlNewChild(rspRootElementP, nameSpace_, BAD_CAST "commandResultList", NULL);
- tmpRet=handleCmpResponses(numberOfCmpCommands, cmpResponsesP, resultListNodeP);
+ tmpRet=handleCmpResponses(numberOfCmpCommands, cmpResponsesP, resultListNodeP);
if(ROOTPA_OK!=tmpRet)
{
LOGE("handleCommandAndFillResponse: not able to handle all Cmp responses, still continuing with UploadResponses %d", tmpRet);
ret=tmpRet;
- }
+ }
tmpRet=handleUploadResponses(numberOfUploadCommands, uploadCommandsP, resultListNodeP);
if(ROOTPA_OK!=tmpRet)
{
LOGE("handleCommandAndFillResponse: not able to handle all Upload responses %d", tmpRet);
ret=tmpRet;
- }
+ }
}
// cleanup what has not yet been cleaned
- int i;
for(i=0; i<numberOfCmpCommands; i++)
- {
+ {
if(cmpCommandsP) free(cmpCommandsP[i].contentP);
if(cmpResponsesP) free(cmpResponsesP[i].contentP);
}
@@ -626,27 +638,41 @@ rootpaerror_t handleCommandAndFillResponse(xmlDocPtr xmlCommandP, xmlDocPtr xmlR
return ret;
}
-void handleError(void* ctx, const char *format, ...)
-{
- char *errMsg;
- va_list args;
- va_start(args, format);
- vasprintf(&errMsg, format, args);
+void handleError(void* ctx, const char *format, ...)
+{
+#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);
+
+ LOGW("From libxml2: %s", errMsg);
+#else
+ char *errMsg;
+
+ va_list args;
+ va_start(args, format);
+ vasprintf(&errMsg, format, args);
+ va_end(args);
+
+ LOGW("From libxml2: %s", errMsg);
free(errMsg);
-}
+#endif
+}
/*
-This is for saving the required xml schema files so that the libxml2 code can read it,
+This is for saving the required xml schema files so that the libxml2 code can read it,
to be called only if the files do not exist of can not be parsed
*/
void saveFile(char* filePath, char* fileContent)
{
- LOGD(">>saveFile %s", filePath);
+
FILE* fh;
-
+ LOGD(">>saveFile %s", filePath);
if ((fh = fopen(filePath, "w")) != NULL)
{
fprintf(fh, "%s", fileContent);
@@ -661,82 +687,83 @@ void saveFile(char* filePath, char* fileContent)
bool validXmlMessage(xmlDocPtr xmlDocP)
-{
- LOGD(">>validXmlMessage %s", enrollmentServiceFullPath_);
-
+{
+
int result=-2;
-#ifdef LIBXML_SCHEMAS_ENABLED
-
- xmlSchemaParserCtxtPtr parserCtxtP = NULL;
- xmlSchemaPtr schemaP = NULL;
- xmlSchemaValidCtxtPtr validCtxtP = NULL;
-
+#ifdef LIBXML_SCHEMAS_ENABLED
+
+ 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
-// created if schemaP==NULL. Since we are using static library, this can be
+// xmlSchemaParse that requires the file to exists. That is why the files are
+// created if schemaP==NULL. Since we are using static library, this can be
// easily controlled even if there are changes in the behavior
parserCtxtP = xmlSchemaNewParserCtxt(enrollmentServiceFullPath_);
- schemaP = xmlSchemaParse(parserCtxtP);
+ schemaP = xmlSchemaParse(parserCtxtP);
if (!schemaP)
{
LOGW("validXmlMessage, no schema ctxt, attempting to save xsd files");
saveFile(platformTypesFullPath_, PLATFORM_TYPES_XSD);
saveFile(enrollmentServiceFullPath_, ENROLLMENT_SERVICE_XSD);
- schemaP = xmlSchemaParse(parserCtxtP);
- if (!schemaP){
+ schemaP = xmlSchemaParse(parserCtxtP);
+ if (!schemaP){
LOGE("validXmlMessage, was not able to save xsd files");
- goto cleanup;
+ goto cleanup;
}
- }
+ }
- validCtxtP = xmlSchemaNewValidCtxt(schemaP);
- if (!validCtxtP){
+ validCtxtP = xmlSchemaNewValidCtxt(schemaP);
+ if (!validCtxtP){
LOGE("validXmlMessage, no validCtxtP");
goto cleanup;
}
- result=xmlSchemaValidateDoc(validCtxtP, xmlDocP);
+ result=xmlSchemaValidateDoc(validCtxtP, xmlDocP);
cleanup:
-
+
if (parserCtxtP) xmlSchemaFreeParserCtxt(parserCtxtP);
- if (schemaP) xmlSchemaFree(schemaP);
+ if (schemaP) xmlSchemaFree(schemaP);
if (validCtxtP) xmlSchemaFreeValidCtxt(validCtxtP);
-
- LOGD("<<validXmlMessage %d", result);
+
+ LOGD("<<validXmlMessage %d", result);
return ((0==result)?true:false);
-
- #else // !LIBXML_SCHEMAS_ENABLED
+
+ #else // !LIBXML_SCHEMAS_ENABLED
LOGD("<<validXmlMessage");
return true;
- #endif // LIBXML_SCHEMAS_ENABLED
-
+ #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");
}
- int size=0;
- xmlChar* dumpP;
-// xmlDocDumpMemory(xmlResponseP, &dumpP, &size);
- xmlDocDumpMemoryEnc(xmlResponseP, &dumpP, &size, "UTF-8");
+
+ xmlDocDumpMemoryEnc(xmlResponseP, &dumpP, &size, "UTF-8");
if(dumpP!=NULL)
{
// doing this copy only because libxml2 documentation tells to
- // release the memory with xmlFree, not free and we want to keep
- // libxml use strictly in this file. It is likely that xmlFree is
+ // release the memory with xmlFree, not free and we want to keep
+ // libxml use strictly in this file. It is likely that xmlFree is
// compatible with free but since I have not verified it, this is to
// be on the safe side
- dumpedP=malloc(size+1);
- strncpy((char*) dumpedP, (char*) dumpP, size+1);
+ dumpedP=(uint8_t*)malloc(size+1);
+ if(dumpedP!=NULL)
+ {
+ strncpy((char*) dumpedP, (char*) dumpP, size+1);
+ }
xmlFree(dumpP);
}
xmlFreeDoc(xmlResponseP);
@@ -746,16 +773,20 @@ uint8_t* validateDumpAndFree(xmlDocPtr xmlResponseP)
// functions used from outside of this file
-/**
+/**
in case an error is returned *responseP is set to NULL
*/
rootpaerror_t handleXmlMessage(const char* messageP, const char** responseP)
{
- LOGD(">>handleXmlMessage");
+
rootpaerror_t ret=ROOTPA_OK;
- rootpaerror_t tmpRet=ROOTPA_OK;
- *responseP=NULL;
+ rootpaerror_t tmpRet=ROOTPA_OK;
+ xmlDocPtr xmlDocP;
+ xmlDocPtr xmlResponseP;
+ *responseP=NULL;
+ LOGD(">>handleXmlMessage");
+
if (NULL==messageP)
{
LOGE("handleXmlMessage, no messageP");
@@ -767,7 +798,7 @@ rootpaerror_t handleXmlMessage(const char* messageP, const char** responseP)
xmlThrDefSetStructuredErrorFunc(NULL, NULL);
xmlThrDefSetGenericErrorFunc(NULL, handleError);
- xmlDocPtr xmlDocP= xmlParseMemory(messageP, strlen(messageP));
+ xmlDocP= xmlParseMemory(messageP, strlen(messageP));
if(NULL==xmlDocP)
{
LOGE("handleXmlMessage, can not parse xmlMessageP %s", messageP);
@@ -776,13 +807,13 @@ rootpaerror_t handleXmlMessage(const char* messageP, const char** responseP)
if(!validXmlMessage(xmlDocP))
{
- LOGE("handleXmlMessage, invalid message %s", messageP);
+ LOGE("handleXmlMessage, invalid message %s", messageP);
ret=ROOTPA_ERROR_XML;
// attempting to parse the message anyway.
}
- xmlDocPtr xmlResponseP=createXmlResponse();
-
+ xmlResponseP=createXmlResponse();
+
// parse received command
if(xmlResponseP)
@@ -794,14 +825,14 @@ rootpaerror_t handleXmlMessage(const char* messageP, const char** responseP)
{
ret=ROOTPA_ERROR_XML;
}
-
+
if(xmlResponseP && xmlResponseP->children) // if there is something to return to SE, return it.
- {
+ {
*responseP = (char*)validateDumpAndFree(xmlResponseP);
}
else
{
- if(xmlResponseP) xmlFreeDoc(xmlResponseP);
+ if(xmlResponseP) xmlFreeDoc(xmlResponseP);
}
if(xmlDocP) xmlFreeDoc(xmlDocP);
@@ -819,31 +850,31 @@ rootpaerror_t fillSystemInfo(xmlNodePtr systemInfoNode, const osInfo_t* osSpecif
LOGD("imei %s", osSpecificInfoP->imeiEsnP);
if(xmlNewProp(systemInfoNode, BAD_CAST "imei", BAD_CAST osSpecificInfoP->imeiEsnP)==NULL) return ROOTPA_ERROR_XML;
}
-
+
if(osSpecificInfoP->mnoP)
{
LOGD("mno %s", osSpecificInfoP->mnoP);
if(xmlNewProp(systemInfoNode, BAD_CAST "mno", BAD_CAST osSpecificInfoP->mnoP)==NULL) return ROOTPA_ERROR_XML;
}
-
+
if(osSpecificInfoP->brandP)
{
LOGD("brand %s", osSpecificInfoP->brandP);
if(xmlNewProp(systemInfoNode, BAD_CAST "brand", BAD_CAST osSpecificInfoP->brandP)==NULL) return ROOTPA_ERROR_XML;
}
-
+
if(osSpecificInfoP->manufacturerP)
{
LOGD("manufacturer %s", osSpecificInfoP->manufacturerP);
if(xmlNewProp(systemInfoNode, BAD_CAST "manufacturer", BAD_CAST osSpecificInfoP->manufacturerP)==NULL) return ROOTPA_ERROR_XML;
}
-
+
if(osSpecificInfoP->hardwareP)
{
LOGD("hardware %s", osSpecificInfoP->hardwareP);
if(xmlNewProp(systemInfoNode, BAD_CAST "hardware", BAD_CAST osSpecificInfoP->hardwareP)==NULL) return ROOTPA_ERROR_XML;
}
-
+
if(osSpecificInfoP->modelP)
{
LOGD("model %s", osSpecificInfoP->modelP);
@@ -862,39 +893,38 @@ rootpaerror_t fillSystemInfo(xmlNodePtr systemInfoNode, const osInfo_t* osSpecif
rootpaerror_t fillMcVersion(xmlNodePtr mcVersionNode, int mcVersionTag, const mcVersionInfo_t* mcVersionP)
{
- LOGD(">>fillMcVersion");
char intBuffer[INT_BUFFER_LENGTH];
-
+ LOGD(">>fillMcVersion");
xmlSetStructuredErrorFunc(NULL, NULL);
xmlSetGenericErrorFunc(NULL, handleError);
xmlThrDefSetStructuredErrorFunc(NULL, NULL);
- xmlThrDefSetGenericErrorFunc(NULL, handleError);
-
+ xmlThrDefSetGenericErrorFunc(NULL, handleError);
+
if(xmlNewProp(mcVersionNode, BAD_CAST "productId", BAD_CAST mcVersionP->productId)==NULL) return ROOTPA_ERROR_XML;
snprintf(intBuffer,INT_BUFFER_LENGTH,"%u",mcVersionP->versionMci);
if(xmlNewProp(mcVersionNode, BAD_CAST "versionMci", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
snprintf(intBuffer,INT_BUFFER_LENGTH,"%u",mcVersionP->versionSo);
- if(xmlNewProp(mcVersionNode, BAD_CAST "versionSo", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
+ if(xmlNewProp(mcVersionNode, BAD_CAST "versionSo", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
snprintf(intBuffer,INT_BUFFER_LENGTH,"%u",mcVersionP->versionMclf);
- if(xmlNewProp(mcVersionNode, BAD_CAST "versionMclf", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
+ if(xmlNewProp(mcVersionNode, BAD_CAST "versionMclf", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
snprintf(intBuffer,INT_BUFFER_LENGTH,"%u",mcVersionP->versionContainer);
- if(xmlNewProp(mcVersionNode, BAD_CAST "versionContainer", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
+ if(xmlNewProp(mcVersionNode, BAD_CAST "versionContainer", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
snprintf(intBuffer,INT_BUFFER_LENGTH,"%u",mcVersionP->versionMcConfig);
- if(xmlNewProp(mcVersionNode, BAD_CAST "versionMcConfig", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
+ if(xmlNewProp(mcVersionNode, BAD_CAST "versionMcConfig", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
snprintf(intBuffer,INT_BUFFER_LENGTH,"%u",mcVersionP->versionTlApi);
- if(xmlNewProp(mcVersionNode, BAD_CAST "versionTlApi", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
+ if(xmlNewProp(mcVersionNode, BAD_CAST "versionTlApi", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
snprintf(intBuffer,INT_BUFFER_LENGTH,"%u",mcVersionP->versionDrApi);
- if(xmlNewProp(mcVersionNode, BAD_CAST "versionDrApi", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
+ if(xmlNewProp(mcVersionNode, BAD_CAST "versionDrApi", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
snprintf(intBuffer,INT_BUFFER_LENGTH,"%u",mcVersionP->versionCmp);
- if(xmlNewProp(mcVersionNode, BAD_CAST "versionCmp", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
+ if(xmlNewProp(mcVersionNode, BAD_CAST "versionCmp", BAD_CAST intBuffer)==NULL) return ROOTPA_ERROR_XML;
LOGD("<<fillMcVersion");
return ROOTPA_OK;
@@ -903,25 +933,30 @@ rootpaerror_t fillMcVersion(xmlNodePtr mcVersionNode, int mcVersionTag, const mc
rootpaerror_t buildXmlTrustletInstallationRequest(const char** responseP, trustletInstallationData_t data )
{
char intBuffer[INT_BUFFER_LENGTH];
- LOGD(">>buildXmlTrustletInstallationRequest %ld (%ld %d %d)", (long int) responseP, (long int) data.dataP, data.dataLength, data.dataType);
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);
if(NULL == responseP) return ROOTPA_ERROR_ILLEGAL_ARGUMENT; // data content checked earlier in commandhandler.c
- xmlDocPtr xmlResponseDocP=createXmlResponse();
- xmlNodePtr rspRootElementP = xmlDocGetRootElement(xmlResponseDocP);
+ xmlResponseDocP=createXmlResponse();
+ rspRootElementP = xmlDocGetRootElement(xmlResponseDocP);
if(NULL==rspRootElementP) return ROOTPA_ERROR_XML;
-
- xmlNodePtr systemInfoNode=xmlNewChild(rspRootElementP, nameSpace_, BAD_CAST "tltInstallationRequest", NULL);
+
+ systemInfoNode=xmlNewChild(rspRootElementP, nameSpace_, BAD_CAST "tltInstallationRequest", NULL);
if(NULL==systemInfoNode) return ROOTPA_ERROR_XML;
- xmlNodePtr mcDataNode=NULL;
- char* encodedDataP=base64EncodeAddEndZero((char*) data.dataP, data.dataLength);
+ encodedDataP=base64EncodeAddEndZero((char*) data.dataP, data.dataLength);
if(NULL==encodedDataP)
{
LOGE("buildXmlTrustletInstallationRequest: base64 encoding of data failed");
return ROOTPA_ERROR_INTERNAL;
}
-
+
if(data.dataType == REQUEST_DATA_TLT)
{
mcDataNode = xmlNewChild(systemInfoNode, nameSpace_, BAD_CAST "trustletAxf", BAD_CAST encodedDataP);
@@ -947,7 +982,7 @@ rootpaerror_t buildXmlTrustletInstallationRequest(const char** responseP, trustl
if(data.flags != DEFAULT_FLAGS)
{
- snprintf(intBuffer,INT_BUFFER_LENGTH,"%d",data.flags);
+ snprintf(intBuffer,INT_BUFFER_LENGTH,"%d",data.flags);
if(xmlNewProp(mcDataNode, BAD_CAST "flags", BAD_CAST intBuffer)==NULL)
{
free(encodedDataP);
@@ -957,67 +992,72 @@ rootpaerror_t buildXmlTrustletInstallationRequest(const char** responseP, trustl
}
else
{
- mcDataNode = xmlNewChild(systemInfoNode, nameSpace_, BAD_CAST "trustletEncryptionKey", BAD_CAST encodedDataP);
+ mcDataNode = xmlNewChild(systemInfoNode, nameSpace_, BAD_CAST "trustletEncryptionKey", BAD_CAST encodedDataP);
}
-
+
snprintf(intBuffer,INT_BUFFER_LENGTH,"%d",data.minTltVersion);
if(xmlNewProp(mcDataNode, BAD_CAST "minTltVersion", BAD_CAST intBuffer)==NULL)
{
free(encodedDataP);
return ROOTPA_ERROR_XML;
}
-
- char* pukHashStringP=base64EncodeAddEndZero((char*) data.tltPukHashP, data.tltPukHashLength);
+
+ pukHashStringP=base64EncodeAddEndZero((char*) data.tltPukHashP, data.tltPukHashLength);
if(NULL==pukHashStringP)
{
LOGE("buildXmlTrustletInstallationRequest: base64 encoding of PukHash failed");
- free(encodedDataP);
+ free(encodedDataP);
return ROOTPA_ERROR_INTERNAL;
}
if(xmlNewProp(mcDataNode, BAD_CAST "tltPukHash", BAD_CAST pukHashStringP)==NULL)
- {
- LOGE("buildXmlTrustletInstallationRequest: xmlNewProp failed");
+ {
+ LOGE("buildXmlTrustletInstallationRequest: xmlNewProp failed");
free(pukHashStringP);
- free(encodedDataP);
+ free(encodedDataP);
return ROOTPA_ERROR_XML;
}
free(pukHashStringP);
free(encodedDataP);
if(NULL==mcDataNode) return ROOTPA_ERROR_XML;
-
+
if(ROOTPA_OK==ret)
- {
+ {
*responseP=(char*)validateDumpAndFree(xmlResponseDocP);
}
xmlCleanupParser();
return ret;
- LOGD("<<buildXmlTrustletInstallationRequest");
+ LOGD("<<buildXmlTrustletInstallationRequest");
}
-/**
+/**
in case an error is returned *responseP is set to NULL
*/
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);
-
- xmlDocPtr xmlResponseDocP=createXmlResponse();
- xmlNodePtr rspRootElementP = xmlDocGetRootElement(xmlResponseDocP);
+ xmlThrDefSetGenericErrorFunc(NULL, handleError);
+
+ xmlResponseDocP=createXmlResponse();
+ rspRootElementP= xmlDocGetRootElement(xmlResponseDocP);
if(NULL==rspRootElementP) return ROOTPA_ERROR_XML;
-
- xmlNodePtr systemInfoNode=xmlNewChild(rspRootElementP, nameSpace_, BAD_CAST "systemInformation", NULL);
+
+ systemInfoNode=xmlNewChild(rspRootElementP, nameSpace_, BAD_CAST "systemInformation", NULL);
if(NULL==systemInfoNode) return ROOTPA_ERROR_XML;
- xmlNodePtr mcVersionNode=xmlNewChild(systemInfoNode, typesNameSpace_, BAD_CAST "mcVersion", NULL);
+ mcVersionNode=xmlNewChild(systemInfoNode, typesNameSpace_, BAD_CAST "mcVersion", NULL);
if(NULL==mcVersionNode) return ROOTPA_ERROR_XML;
ret=fillSystemInfo(systemInfoNode, osSpecificInfoP);
@@ -1032,19 +1072,19 @@ rootpaerror_t buildXmlSystemInfo(const char** responseP, int mcVersionTag, const
LOGE("buildXmlSystemInfo: could not fill Mc version %d, continuing anyway", ret);
}
-
+
if(ROOTPA_OK==ret)
- {
+ {
*responseP=(char*)validateDumpAndFree(xmlResponseDocP);
}
xmlCleanupParser();
return ret;
- LOGD("<<buildXmlSystemInfo");
+ LOGD("<<buildXmlSystemInfo");
}
/**
-set the path where to look for and store the xsd files
+set the path where to look for and store the xsd files
*/
void setXsdPaths(const char* xsdpathP)
{