From: Uladzislau Harbuz Date: Fri, 10 Nov 2017 17:23:01 +0000 (+0100) Subject: Fix C++Test static analysis violations X-Git-Tag: submit/tizen/20171205.070457~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4bf6c192dc128b4407372f96450b7fa181a60f81;p=platform%2Fcore%2Fsecurity%2Ftef-simulator.git Fix C++Test static analysis violations Change-Id: Ia458bb472af6f3cd18cc9dd1ccaacb9bc7558805 --- diff --git a/TEEStub/PropertyAccess/Property.h b/TEEStub/PropertyAccess/Property.h index 80ecb4c..23c81bc 100644 --- a/TEEStub/PropertyAccess/Property.h +++ b/TEEStub/PropertyAccess/Property.h @@ -52,15 +52,15 @@ public: virtual void reset() = 0; virtual bool getPropertyValue(PropertyValue&) = 0; void setPropSet(uintptr_t propset) { - this->propset = propset; + this->m_propset = propset; }; - Property() : propset(0) { + Property() : m_propset(0) { } ; virtual ~Property() { } ; - uintptr_t propset; + uintptr_t m_propset; }; #endif /* PROPERTYACCESS_PROPERTY_H_ */ diff --git a/TEEStub/PropertyAccess/PropertyApi.cpp b/TEEStub/PropertyAccess/PropertyApi.cpp index 2a52fdf..50e3a99 100644 --- a/TEEStub/PropertyAccess/PropertyApi.cpp +++ b/TEEStub/PropertyAccess/PropertyApi.cpp @@ -413,7 +413,7 @@ uintptr_t _GetTargetPropsetType(TEE_PropSetHandle propsetOrEnumerator) { (PropertyEnumHandle*)propsetOrEnumerator; if (enumHandle && enumHandle->property) { targetProperty = enumHandle->property; - return targetProperty->propset; + return targetProperty->m_propset; } } return 0; diff --git a/TEEStub/PropertyAccess/PropertyUtility.cpp b/TEEStub/PropertyAccess/PropertyUtility.cpp index 930f5d3..d7dfec9 100644 --- a/TEEStub/PropertyAccess/PropertyUtility.cpp +++ b/TEEStub/PropertyAccess/PropertyUtility.cpp @@ -127,7 +127,6 @@ TEE_Result PropertyUtility::convertToUUID(const PropertyValue& in, uint64_t clockSeq; string clockSeqStr = tokensString[4] + tokensString[5] + tokensString[6] + tokensString[7]; - //TEST CODE: string clockSeqStr("0123456789ABCDEF"); clockSeq = std::stoll(clockSeqStr); memcpy(uuid.clockSeqAndNode, &clockSeq, sizeof(uint64_t)); // Change endian-ness diff --git a/TEEStub/TACommands/CommandCloseSession.cpp b/TEEStub/TACommands/CommandCloseSession.cpp index 74433bc..17db1d3 100644 --- a/TEEStub/TACommands/CommandCloseSession.cpp +++ b/TEEStub/TACommands/CommandCloseSession.cpp @@ -37,7 +37,7 @@ */ CommandCloseSession::CommandCloseSession(CloseTASessionData data) : CommandBase(CLOSESESSION) { - this->data = data; + this->m_data = data; sessionID = data.sessionID; } @@ -61,7 +61,7 @@ TEE_Result CommandCloseSession::execute() { */ std::string CommandCloseSession::getCommandUID() const { std::stringstream ss; - ss << data.sessionID; + ss << m_data.sessionID; ss << ":"; ss << "0"; return ss.str(); @@ -81,6 +81,6 @@ CommandCloseSession::~CommandCloseSession() { void CommandCloseSession::getSerializedData(unsigned char *data, unsigned int &size) { data[0] = command; - memcpy(&data[1], (unsigned char*)&this->data, sizeof(CloseTASessionData)); + memcpy(&data[1], (unsigned char*)&this->m_data, sizeof(CloseTASessionData)); size = sizeof(CloseTASessionData); } diff --git a/TEEStub/TACommands/CommandCloseSession.h b/TEEStub/TACommands/CommandCloseSession.h index 67b38d3..fb37242 100644 --- a/TEEStub/TACommands/CommandCloseSession.h +++ b/TEEStub/TACommands/CommandCloseSession.h @@ -39,7 +39,7 @@ class CommandCloseSession: public CommandBase { public: - CloseTASessionData data; + CloseTASessionData m_data; void getSerializedData(unsigned char *data, unsigned int &size); CommandCloseSession(CloseTASessionData data); TEE_Result execute(); diff --git a/TEEStub/TACommands/CommandCreateEntryPoint.cpp b/TEEStub/TACommands/CommandCreateEntryPoint.cpp index 15c0df9..bb32028 100644 --- a/TEEStub/TACommands/CommandCreateEntryPoint.cpp +++ b/TEEStub/TACommands/CommandCreateEntryPoint.cpp @@ -31,10 +31,10 @@ /*----------------------------------------------------------------------------- * Member functions *-----------------------------------------------------------------------------*/ -CommandCreateEntryPoint::CommandCreateEntryPoint(CreateTAEntryPointData data) : +CommandCreateEntryPoint::CommandCreateEntryPoint(CreateTAEntryPointData _data) : CommandBase(CREATE) { - this->data = data; - sessionID = data.sessionID; + this->data = _data; + sessionID = _data.sessionID; } /** @@ -69,9 +69,9 @@ CommandCreateEntryPoint::~CommandCreateEntryPoint() { * @param data[out] serialized object data * @param size[out] size in bytes */ -void CommandCreateEntryPoint::getSerializedData(unsigned char *data, +void CommandCreateEntryPoint::getSerializedData(unsigned char *_data, unsigned int &size) { - data[0] = command; - memcpy(&data[1], (unsigned char*)&this->data, sizeof(CreateTAEntryPointData)); + _data[0] = command; + memcpy(&_data[1], (unsigned char*)&this->data, sizeof(CreateTAEntryPointData)); size = sizeof(CreateTAEntryPointData); } diff --git a/TEEStub/TACommands/CommandDestroyEntryPoint.cpp b/TEEStub/TACommands/CommandDestroyEntryPoint.cpp index 84af8c9..616b12f 100644 --- a/TEEStub/TACommands/CommandDestroyEntryPoint.cpp +++ b/TEEStub/TACommands/CommandDestroyEntryPoint.cpp @@ -31,10 +31,10 @@ /*----------------------------------------------------------------------------- * Member functions *-----------------------------------------------------------------------------*/ -CommandDestroyEntryPoint::CommandDestroyEntryPoint(DestroyTAEntryPointData data) : +CommandDestroyEntryPoint::CommandDestroyEntryPoint(DestroyTAEntryPointData _data) : CommandBase(DESTROY) { - this->data = data; - sessionID = data.sessionID; + this->data = _data; + sessionID = _data.sessionID; } //TODO: Handle exit of TA instance in a clean way @@ -71,10 +71,10 @@ CommandDestroyEntryPoint::~CommandDestroyEntryPoint() { * @param data[out] serialized object data * @param size[out] size in bytes */ -void CommandDestroyEntryPoint::getSerializedData(unsigned char *data, +void CommandDestroyEntryPoint::getSerializedData(unsigned char *_data, unsigned int &size) { - data[0] = command; - memcpy(&data[1], (unsigned char*)&this->data, + _data[0] = command; + memcpy(&_data[1], (unsigned char*)&this->data, sizeof(DestroyTAEntryPointData)); size = sizeof(DestroyTAEntryPointData); } diff --git a/include/include/tee_command.h b/include/include/tee_command.h index c3f2c4a..f2197cd 100644 --- a/include/include/tee_command.h +++ b/include/include/tee_command.h @@ -36,7 +36,6 @@ typedef enum { OPEN_TA_SESSION, INVOKE_TA_COMMAND, CLOSE_TA_SESSION, - CHECK_MEMORY, PANIC } TEE_CMD; #endif /* __TEE_COMMAND_H__ */ diff --git a/log/log.c b/log/log.c index afe0f81..4b1e3d6 100644 --- a/log/log.c +++ b/log/log.c @@ -125,6 +125,9 @@ const char *GetModuleLevel(IN int32_t module_level) case SSF_LIB: return "SSF_LIB"; + case OSA_LIB: + return "OSA_LIB"; + default: return "TA_SDK"; } diff --git a/log/log.h b/log/log.h index 8c31f2d..2658c0c 100644 --- a/log/log.h +++ b/log/log.h @@ -36,7 +36,6 @@ #define INOUT #define OUT -//#define _LOGGING #ifdef _WIN typedef int timer_t; @@ -77,6 +76,7 @@ typedef enum { TEE_STUB = 0x08, TEST = 0x10, SSF_LIB = 0x11, + OSA_LIB = 0x12, ALL_MODULES = 0xFFFFFFF, } ModuleLevel; diff --git a/osal/CMakeLists.txt b/osal/CMakeLists.txt index 755cd04..82f6c8d 100644 --- a/osal/CMakeLists.txt +++ b/osal/CMakeLists.txt @@ -26,6 +26,10 @@ SET(OSAL_SOURCES ${OSAL_PATH}/OsaTask.c ) +INCLUDE_DIRECTORIES( + ${LOG_PATH} +) + ADD_LIBRARY(${TARGET_TEF_SIMULATOR_OSAL} ${OSAL_SOURCES}) INSTALL(TARGETS ${TARGET_TEF_SIMULATOR_OSAL} DESTINATION ${LIB_DIR}) diff --git a/osal/OsaCommon.c b/osal/OsaCommon.c index 3caabef..a2c652b 100644 --- a/osal/OsaCommon.c +++ b/osal/OsaCommon.c @@ -24,6 +24,7 @@ * Include files *-----------------------------------------------------------------------------*/ #include "OsaLinuxUser.h" +#include /*----------------------------------------------------------------------------- * Globals @@ -148,7 +149,7 @@ int OsaTimerCreate(int *pTimerId, int periodic, int s32Time, * Add SIGALRM in the list */ if (sigaddset(&(Action_t.sa_mask), SIGALRM) < 0) { - //PrintError("In OsaTimerCreate() : Could Not Stop \n"); + LOGE(OSA_LIB, "In OsaTimerCreate() : Could Not Stop \n"); return OSAL_ERROR; } @@ -156,7 +157,7 @@ int OsaTimerCreate(int *pTimerId, int periodic, int s32Time, * Unblock the SIGALRM,if it is blocked */ if (sigprocmask(SIG_UNBLOCK, &(Action_t.sa_mask), NULL) < 0) { - //PrintError("In OsaTimerCreate() : Could not mask the Signal \n"); + LOGE(OSA_LIB, "In OsaTimerCreate() : Could not mask the Signal \n"); return OSAL_ERROR; } @@ -197,7 +198,7 @@ int OsaTimerStart(int iTimerId) /* The timer is started */ if (Timer_data_t.start_timer != TRUE) { if (setitimer(ITIMER_REAL, &Timer_data_t.iTval_t, NULL) < 0) { - //PrintError("In OsaTimerStart() : OsaTimerStart failed \n "); + LOGE(OSA_LIB, "In OsaTimerStart() : OsaTimerStart failed \n "); return OSAL_ERROR; } @@ -221,44 +222,19 @@ int OsaTimerStart(int iTimerId) */ int OsaTimerStop(int iTimerId) { - //struct sigaction Action_t; - //Action_t.sa_flags = 0; struct itimerval trivial_it; /* OSAL_080918_1 */ if (Timer_data_t.start_timer == FALSE) { - //PrintError("In OsaTimerStop() : Timer not yet started \n"); - return OSAL_ERROR; - } - - /* OSAL_080920 : Don't block the alarm signal */ -#if 0 - /* OSAL_080918_2 : init signal set variable */ - sigemptyset(&(Action_t.sa_mask)); - - /* - * Add SIGALRM in the signal List - */ - if (sigaddset(&(Action_t.sa_mask), SIGALRM) < 0) { - PrintError("In OsaTimerStop() : Could Not Stop \n"); - return OSAL_ERROR; - } - - /* - * Block SIGALRM - */ - if (sigprocmask(SIG_BLOCK, &(Action_t.sa_mask), NULL) < 0) { - PrintError("In OsaTimerStop() : Could not mask the Signal \n"); return OSAL_ERROR; } -#endif /* OSAL_080918_1 : stop interval timer after alarm signal blocked */ trivial_it.it_value.tv_sec = 0; trivial_it.it_value.tv_usec = 0; if (setitimer(ITIMER_REAL, &trivial_it, NULL) == -1) { - //PrintError("OsaTimerStop failed\n "); + LOGE(OSA_LIB, "OsaTimerStop failed\n "); return OSAL_ERROR; } @@ -285,7 +261,7 @@ int OsaTimerDelete(int iTimerId) //Action_t.sa_flags = 0; if (Timer_data_t.start_timer == FALSE) { - //PrintError("In OsaTimerDelete() : No timer present to be deleted \n"); + LOGE(OSA_LIB, "In OsaTimerDelete() : No timer present to be deleted \n"); return OSAL_ERROR; } @@ -297,7 +273,7 @@ int OsaTimerDelete(int iTimerId) /* The Timer is deleted */ if (setitimer(ITIMER_REAL, &iTmpval_t, NULL) < 0) { - //PrintError("In OsaTimerDelete() : pOsaTimerDelete failed \n"); + LOGE(OSA_LIB, "In OsaTimerDelete() : pOsaTimerDelete failed \n"); return -1; } @@ -323,14 +299,14 @@ int OsaTimerRestart(int iTimerId) struct sigaction Action_t; if (Timer_data_t.stop_timer == TRUE) { - //PrintError("In OsaTimerRestart() : Has been stopped forever \n"); + LOGE(OSA_LIB, "In OsaTimerRestart() : Has been stopped forever \n"); return OSAL_ERROR; } /* OSAL_080918_1 : reset it_value to keep the first expiration after restart */ if (setitimer(ITIMER_REAL, &Timer_data_t.iTval_t, NULL) == -1) { - //PrintError("OsaTimerRestart failed\n "); + LOGE(OSA_LIB, "OsaTimerRestart failed\n "); return OSAL_ERROR; } @@ -341,7 +317,7 @@ int OsaTimerRestart(int iTimerId) Action_t.sa_flags = 0; if (sigprocmask(SIG_UNBLOCK, &(Action_t.sa_mask), NULL) < 0) { - //PrintError("In OsaTimerRestart() : Could Not Start Again \n"); + LOGE(OSA_LIB, "In OsaTimerRestart() : Could Not Start Again \n"); return OSAL_ERROR; } diff --git a/osal/OsaIpc.c b/osal/OsaIpc.c index 07d2f89..89b5190 100644 --- a/osal/OsaIpc.c +++ b/osal/OsaIpc.c @@ -25,6 +25,7 @@ * Include files *-----------------------------------------------------------------------------*/ #include "OsaLinuxUser.h" +#include key_t OsaGetKey(const char pcName[10]) { @@ -36,7 +37,7 @@ key_t OsaGetKey(const char pcName[10]) memset(aName, 0x00, 10); memcpy(aName, pcName, 9); - uid = 1; //getuid(); + uid = 1; // getuid was here acc = 0; len = strlen(aName); @@ -103,7 +104,7 @@ int OsaShmDetach(const void *pShmAddr) return OSAL_ERROR; if (shmdt(pShmAddr) == -1) { - //PrintError("Error in Detaching"); + LOGE(OSA_LIB, "Error in Detaching"); return OSAL_ERROR; } @@ -147,7 +148,7 @@ static int UlOsaNamedSemCreate(const char pcName[10], int iCount, sem = (UlOsaSem_t *)malloc(sizeof(*sem)); if (!sem) { - //PrintError ("UlOsaSemCreate, Out of memory!\n"); + LOGE(OSA_LIB, "UlOsaSemCreate, Out of memory!\n"); return OSAL_ERROR; } @@ -163,7 +164,7 @@ static int UlOsaNamedSemCreate(const char pcName[10], int iCount, if (semctl(sem->iSemId, 0, SETVAL, semUnion) == -1) { semctl(sem->iSemId, 0, IPC_RMID, NULL); free(sem); - //PrintError ("UlOsaSemCreate, semctl Failed!\n"); + LOGE(OSA_LIB, "UlOsaSemCreate, semctl Failed!\n"); return OSAL_ERROR; } } else { @@ -172,7 +173,7 @@ static int UlOsaNamedSemCreate(const char pcName[10], int iCount, iRetVal = OSAL_EXIST; } else { free(sem); - //PrintError ("UlOsaSemCreate, semget Failed!\n"); + LOGE(OSA_LIB, "UlOsaSemCreate, semget Failed!\n"); return OSAL_ERROR; } } @@ -226,7 +227,7 @@ static int UlOsaNamedSemGet(void *uiSmid, int iFlags, int iTimeout) ret = semop(sem->iSemId, &semBuf, 1); } else if (iTimeout == 0) { /* wait _inifinite_ */ - //PrintDbg ("UlOsaSemGet-infinite(%s).\n", sem->bName); + LOGD(OSA_LIB, "UlOsaSemGet-infinite(%s).\n", sem->bName); semBuf.sem_num = 0; semBuf.sem_op = -1; semBuf.sem_flg = SEM_UNDO; @@ -234,9 +235,9 @@ static int UlOsaNamedSemGet(void *uiSmid, int iFlags, int iTimeout) ret = OSAL_FAILURE_RETRY(semop(sem->iSemId, &semBuf, 1)); } else { /* with _timeout_ */ - //PrintDbg ("UlOsaSemGet-timeout(%s).\n", sem->bName); + LOGD(OSA_LIB, "UlOsaSemGet-timeout(%s).\n", sem->bName); if (iTimeout < 0) { - //PrintError ("UlOsaSemGet-timeout: invalid arg!\n"); + LOGE(OSA_LIB, "UlOsaSemGet-timeout: invalid arg!\n"); return OSAL_ERROR; } @@ -257,17 +258,17 @@ static int UlOsaNamedSemGet(void *uiSmid, int iFlags, int iTimeout) /* result */ if (ret == 0) { - //PrintDbg ("UlOsaSemGet(%s) success.\n", sem->bName); + LOGD(OSA_LIB, "UlOsaSemGet(%s) success.\n", sem->bName); return OSAL_OK; } else { if (iFlags == OSAL_SEM_NOWAIT && errno == EAGAIN) { - //PrintError ("UlOsaSemGet-nowait: now locked, failed to get.\n"); + LOGE(OSA_LIB, "UlOsaSemGet-nowait: now locked, failed to get.\n"); return OSAL_ERROR; } else if (iTimeout > 0 && errno == EAGAIN) { - //PrintError ("UlOsaSemGet-timeout(%s): time-out\n", sem->bName); + LOGE(OSA_LIB, "UlOsaSemGet-timeout(%s): time-out\n", sem->bName); return OSAL_ERR_TIMEOUT; } else { - //PrintError ("UlOsaSemGet error, errno=%d\n", errno); + LOGE(OSA_LIB, "UlOsaSemGet error, errno=%d\n", errno); return OSAL_ERROR; } } @@ -281,13 +282,13 @@ static int UlOsaNamedSemRelease(void *uiSmid) if (!sem) return OSAL_ERROR; - //PrintDbg ("UlOsaSemRelease(%s)\n", sem->bName); + LOGD(OSA_LIB, "UlOsaSemRelease(%s)\n", sem->bName); semBuf.sem_num = 0; semBuf.sem_op = 1; semBuf.sem_flg = SEM_UNDO; if (semop(sem->iSemId, &semBuf, 1) == -1) { - //PrintError ("UlOsaSemRelease(%s) error! errno=%d.\n", sem->bName, errno); + LOGE(OSA_LIB, "UlOsaSemRelease(%s) error! errno=%d.\n", sem->bName, errno); return OSAL_ERROR; } else return OSAL_OK; @@ -301,11 +302,11 @@ static int UlOsaNamedSemReset(void *uiSmid) if (!sem) return OSAL_ERROR; - //PrintDbg ("UlOsaSemReset(%s).\n", sem->bName); + LOGD(OSA_LIB, "UlOsaSemReset(%s).\n", sem->bName); semUnion.val = sem->iCount; if (semctl(sem->iSemId, 0, SETVAL, semUnion) == -1) { - //PrintError ("UlOsaSemReset, semctl Failed!\n"); + LOGE(OSA_LIB, "UlOsaSemReset, semctl Failed!\n"); return OSAL_ERROR; } @@ -323,10 +324,10 @@ static int UlOsaNamedSemGetval(void *uiSmid) n = semctl(sem->iSemId, 0, GETVAL, NULL); if (n == -1) { - //PrintError ("UlOsaSemGetval, semctl Failed!\n"); + LOGE(OSA_LIB, "UlOsaSemGetval, semctl Failed!\n"); return OSAL_ERROR; } else { - //PrintDbg ("UlOsaSemGetval(%s): now %d\n", sem->bName, n); + LOGD(OSA_LIB, "UlOsaSemGetval(%s): now %d\n", sem->bName, n); return (int)n; } } @@ -347,10 +348,8 @@ int OsaNamedSemRelease(void *uiSmid) return UlOsaNamedSemRelease(uiSmid); } -int OsaNamedSemDelete(void - *uiSmid) // Deleting Semaphore : Never USE!!! - junhyeong.kim, sukki.min 12.04.20 +int OsaNamedSemDelete(void *uiSmid) { - //return UlOsaNamedSemDelete (uiSmid); return -1; } diff --git a/osal/OsaQueue.c b/osal/OsaQueue.c index ac5567b..75d39c0 100644 --- a/osal/OsaQueue.c +++ b/osal/OsaQueue.c @@ -24,6 +24,7 @@ * Include files *-----------------------------------------------------------------------------*/ #include "OsaLinuxUser.h" +#include /*----------------------------------------------------------------------------- * Globals @@ -59,7 +60,7 @@ int OsaQueueCreate(const char bName[10], unsigned int uiFlags, mqd_t QuId; if (puiQid == NULL) { - PrintDbg("Null Argument(s) \n"); + LOGD(OSA_LIB, "Null Argument(s) \n"); return OSAL_ERROR; } @@ -88,14 +89,14 @@ int OsaQueueCreate(const char bName[10], unsigned int uiFlags, if (((int)*puiQid) == -1) { //IPC_CREATE perror("In OsaQueueCreate() : msgget: msgget failed"); - //PrintError("In OsaQueueCreate() : Error no. : %d\n",errno); + LOGE(OSA_LIB, "In OsaQueueCreate() : Error no. : %d\n", errno); return ((int)errno); } /* Get the current value from the structure for the message queue and copy it in buf_t*/ if (msgctl((int)(*puiQid), IPC_STAT, &tSetMqAttr) == -1) { perror("In OsaQueueCreate() : msgctl: msgctl failed"); - //PrintError("In OsaQueueCreate() : Error no. : %d\n",errno); + LOGE(OSA_LIB, "In OsaQueueCreate() : Error no. : %d\n", errno); return ((int)errno); } @@ -104,7 +105,7 @@ int OsaQueueCreate(const char bName[10], unsigned int uiFlags, if (msgctl((int)(*puiQid), IPC_SET, &tSetMqAttr) == -1) { perror("In OsaQueueCreate() : msgctl: msgctl failed"); - //PrintError("In OsaQueueCreate() : Error no. : %d\n",errno); + LOGE(OSA_LIB, "In OsaQueueCreate() : Error no. : %d\n", errno); return ((int)errno); } @@ -168,7 +169,7 @@ int OsaQueueDelete(const char *bName, unsigned int uiQid) if (msgctl((int)uiQid, IPC_RMID, NULL) == -1) { perror("In OsaQueueDelete(): msgctl: msgctl failed"); - //PrintError("In OsaQueueDelete(): Error no. : %d\n",errno); + LOGE(OSA_LIB, "In OsaQueueDelete(): Error no. : %d\n", errno); return ((int)errno); } @@ -204,27 +205,22 @@ int OsaQueueSend(unsigned int uiQid, unsigned int uiFlags, void *pvMsg_buf, tMqAttr.mq_flags = O_NONBLOCK; if ((err_no = mq_setattr((mqd_t)uiQid, &tMqAttr, (struct mq_attr *)NULL)) < 0) { - ////PrintError("mq_setattr(): mq_setattr() Failed errno=%d\n",err_no,0,0,0,0,0); //COMMON_071024_1 + LOGE(OSA_LIB, "mq_setattr(): mq_setattr() Failed errno=%d\n", err_no, 0, 0, 0, 0, 0); return (OSAL_ERROR); } } - if ((err_no = mq_send((mqd_t)uiQid, (const char *)pvMsg_buf, uiMsgLen, - uiPriority)) < 0) { - ////PrintError("mq_send():Failed errno=%d qid=%x flag=%d\n",err_no,uiQid,uiFlags,0,0,0); //COMMON_071024_1 + if ((err_no = mq_send((mqd_t)uiQid, (const char *)pvMsg_buf, uiMsgLen, uiPriority)) < 0) { + LOGE(OSA_LIB, "mq_send():Failed errno=%d qid=%x flag=%d\n", err_no, uiQid, uiFlags, 0, 0, 0); return (OSAL_ERROR); } #else /*SYS5 MSG QUEUE*/ - /* - uiFlags : IPC_NOWAIT , ZERO - pMsgLen: len - sizeof(int); - */ osaMsgBuf_t osaMsg; int ret; if (uiMsgLen > MAXML) { - ////PrintError("Message length exceeds max limit of %d\n",MAXML); //COMMON_071024_1 + LOGE(OSA_LIB, "Message length exceeds max limit of %d\n", MAXML); return OSAL_ERROR; } @@ -238,7 +234,7 @@ int OsaQueueSend(unsigned int uiQid, unsigned int uiFlags, void *pvMsg_buf, if (ret != 0) { //perror("In OsaQueueSend () : msgsnd failed"); //COMMON_071024_1 - ////PrintError("In OsaQueueSend() : Error no. : %d\n",errno); //COMMON_071024_1 + LOGE(OSA_LIB, "In OsaQueueSend() : Error no. : %d\n", errno); return ((int)errno); } @@ -267,12 +263,6 @@ int OsaQueueReceive(unsigned int uiQid, unsigned int uiFlags, void *pvMsgBuf, { #ifndef __NO_OS__ #ifdef POSIX_QUEUE - /* - uiFlags : IPC_NOWAIT , ZERO - */ -#if 0 - struct timespec absTimeOut; -#endif struct mq_attr tMqAttr; int uiMsgLen = 0; @@ -282,18 +272,6 @@ int OsaQueueReceive(unsigned int uiQid, unsigned int uiFlags, void *pvMsgBuf, else tMqAttr.mq_flags = 0; -#if 0 - - if (ptTimeOut && (!(uiFlags & OSAL_Q_NOWAIT))) { - absTimeOut.tv_sec = ptTimeOut->Sec; - absTimeOut.tv_nsec = ptTimeOut->NanoSec; - } else { - absTimeOut.tv_sec = 0; - absTimeOut.tv_nsec = 0; - } - -#endif - if (mq_setattr((mqd_t)uiQid, &tMqAttr, (struct mq_attr *)NULL) < 0) { perror("OsaQueueSend(): mq_setattr() Failed \n"); return ((int)errno); @@ -308,10 +286,6 @@ int OsaQueueReceive(unsigned int uiQid, unsigned int uiFlags, void *pvMsgBuf, // Update the received message length *pMsgLen = uiMsgLen; #else /*SYS5 MSG QUEUE*/ - /* - uiFlags : IPC_NOWAIT, MSG_NOERROR - buf_len : len - sizeof(int); - */ int iRet = 0; osaMsgBuf_t osaMsg; @@ -329,7 +303,7 @@ int OsaQueueReceive(unsigned int uiQid, unsigned int uiFlags, void *pvMsgBuf, if (errno != ENOMSG) { perror("In OsaQueueReceive() : msgrcv failed"); - //PrintError("In OsaQueueReceive() : Msg id %d, Error no. : %d\n", uiQid, errno); + LOGE(OSA_LIB, "In OsaQueueReceive() : Msg id %d, Error no. : %d\n", uiQid, errno); } return ((int)errno); @@ -363,7 +337,7 @@ int OsaQueueGetinfo(unsigned int uiQid, void *pvBuf) struct mq_attr tMqAttr; if (pvBuf == NULL) { - //PrintError("Null Argument(s) \n"); + LOGE(OSA_LIB, "Null Argument(s) \n"); return OSAL_ERROR; } @@ -387,7 +361,7 @@ int OsaQueueGetinfo(unsigned int uiQid, void *pvBuf) if (msgctl((int)uiQid, IPC_STAT, &buf) < 0) { perror("In OsaQueueGetinfo() : msgctl: msgctl failed"); - //PrintError("In OsaQueueGetinfo() : Error no. : %d\n",errno); + LOGE(OSA_LIB, "In OsaQueueGetinfo() : Error no. : %d\n", errno); return ((int)errno); } @@ -426,7 +400,7 @@ int OsaQueueSetinfo(unsigned int uiQid, void *pvBuf) struct mq_attr tMqAttr; if (pvBuf == NULL) { - //PrintError("Null Argument(s) \n"); + LOGE(OSA_LIB, "Null Argument(s) \n"); return OSAL_ERROR; } @@ -455,7 +429,7 @@ int OsaQueueSetinfo(unsigned int uiQid, void *pvBuf) if (msgctl((int)uiQid, IPC_SET, &buf) < 0) { perror("In OsaQueueGetinfo() : msgctl: msgctl failed"); - //PrintError("In OsaQueueGetinfo() : Error no. : %d\n",errno); + LOGE(OSA_LIB, "In OsaQueueGetinfo() : Error no. : %d\n", errno); return ((int)errno); } diff --git a/osal/OsaSem.c b/osal/OsaSem.c index 710a009..82af922 100644 --- a/osal/OsaSem.c +++ b/osal/OsaSem.c @@ -24,6 +24,7 @@ * Include files *-----------------------------------------------------------------------------*/ #include "OsaLinuxUser.h" +#include /*----------------------------------------------------------------------------- * Globals @@ -49,12 +50,12 @@ static int UlOsaSemCreate(const char bName[10], int iCount, int iAttribute, sem = (UlOsaSem_t *)malloc(sizeof(*sem)); if (!sem) { - //PrintError ("UlOsaSemCreate, Out of memory!\n"); + LOGE(OSA_LIB, "UlOsaSemCreate, Out of memory!\n"); return OSAL_ERROR; } if (sem_init(&sem->sem, 1, (unsigned int)iCount) < 0) { - //PrintError ("UlOsaSemCreate, sem_init Failed!\n"); + LOGE(OSA_LIB, "UlOsaSemCreate, sem_init Failed!\n"); free(sem); return OSAL_ERROR; } @@ -93,38 +94,19 @@ static int UlOsaSemGet(void *uiSmid, int iFlags, int iTimeout) if (iFlags == OSAL_SEM_NOWAIT) { /* no wait */ - //PrintDbg ("UlOsaSemGet-nowait(%s).\n", sem->bName); + LOGD(OSA_LIB, "UlOsaSemGet-nowait(%s).\n", sem->bName); ret = sem_trywait(&sem->sem); } else if (iTimeout == 0) { /* wait _inifinite_ */ - //PrintDbg ("UlOsaSemGet-infinite(%s).\n", sem->bName); + LOGD(OSA_LIB, "UlOsaSemGet-infinite(%s).\n", sem->bName); ret = OSAL_FAILURE_RETRY(sem_wait(&sem->sem)); } else { /* with _timeout_ */ - //PrintDbg ("UlOsaSemGet-timeout(%s).\n", sem->bName); + LOGD(OSA_LIB, "UlOsaSemGet-timeout(%s).\n", sem->bName); if (iTimeout < 0) { - //PrintError ("UlOsaSemGet-timeout: invalid arg!\n"); + LOGE(OSA_LIB, "UlOsaSemGet-timeout: invalid arg!\n"); return OSAL_ERROR; } - -#if 0 - struct timeval tv; - - gettimeofday(&tv, NULL); - tv.tv_sec += iTimeout / 1000000; - tv.tv_usec += iTimeout % 1000000; - - if (tv.tv_usec >= 1000000) { - tv.tv_sec += tv.tv_usec / 1000000; - tv.tv_usec %= 1000000; - } - - ts.tv_sec = tv.tv_sec; - ts.tv_nsec = tv.tv_usec * 1000; - - ret = OSAL_FAILURE_RETRY(sem_timedwait(&sem->sem, &ts)); -#endif - do { // SoC_D00003324 ret = sem_trywait(&sem->sem); @@ -138,18 +120,17 @@ static int UlOsaSemGet(void *uiSmid, int iFlags, int iTimeout) /* result */ if (ret == 0) { - //PrintDbg ("UlOsaSemGet(%s) success.\n", sem->bName); + LOGD(OSA_LIB, "UlOsaSemGet(%s) success.\n", sem->bName); return OSAL_OK; } else { if (iFlags == OSAL_SEM_NOWAIT && errno == EAGAIN) { - // PrintError ("UlOsaSemGet-nowait: now locked, failed to get.\n"); + // LOGE(OSA_LIB, "UlOsaSemGet-nowait: now locked, failed to get.\n"); return OSAL_ERROR; - } else if (iFlags == OSAL_SEM_WAIT && - iTimeout <= 0) {// Before : cond - (iTimeout > 0 && errno == ETIMEDOUT) - //PrintError ("UlOsaSemGet-timeout(%s): time-out\n",sem->bName); + } else if (iFlags == OSAL_SEM_WAIT && iTimeout <= 0) { + LOGE(OSA_LIB, "UlOsaSemGet-timeout(%s): time-out\n", sem->bName); return OSAL_ERR_TIMEOUT; } else { - //PrintError ("UlOsaSemGet error, errno=%d\n", errno); + LOGE(OSA_LIB, "UlOsaSemGet error, errno=%d\n", errno); return OSAL_ERROR; } } @@ -162,9 +143,9 @@ static int UlOsaSemRelease(void *uiSmid) if (!sem) return OSAL_ERROR; - //PrintDbg ("UlOsaSemRelease(%s)\n", sem->bName); + LOGD(OSA_LIB, "UlOsaSemRelease(%s)\n", sem->bName); if (sem_post(&sem->sem) != 0) { - //PrintError ("UlOsaSemRelease(%s) error! errno=%d.\n", sem->bName, errno); + LOGE(OSA_LIB, "UlOsaSemRelease(%s) error! errno=%d.\n", sem->bName, errno); return OSAL_ERROR; } else return OSAL_OK; @@ -177,12 +158,12 @@ static int UlOsaSemReset(void *uiSmid) if (!sem) return OSAL_ERROR; - //PrintDbg ("UlOsaSemReset(%s).\n", sem->bName); + LOGD(OSA_LIB, "UlOsaSemReset(%s).\n", sem->bName); /* For threads currently blocked, the effect of destroying is not defined in POSIX. Currently, this will not release any blocked threads. */ if (sem_destroy(&sem->sem) < 0) { - //PrintError ("UlOsaSemReset, sem_destroy errno=%d\n", errno); + LOGE(OSA_LIB, "UlOsaSemReset, sem_destroy errno=%d\n", errno); return OSAL_ERROR; } @@ -201,10 +182,10 @@ static int UlOsaSemGetval(void *uiSmid) return OSAL_ERROR; if (sem_getvalue(&sem->sem, &n) != 0) { - //PrintError ("UlOsaSemGetval(%s), sem_getvalue errno=%d\n", sem->bName, errno); + LOGE(OSA_LIB, "UlOsaSemGetval(%s), sem_getvalue errno=%d\n", sem->bName, errno); return OSAL_ERROR; } else { - //PrintDbg ("UlOsaSemGetval(%s): now %d\n", sem->bName, n); + LOGD(OSA_LIB, "UlOsaSemGetval(%s): now %d\n", sem->bName, n); return (int)n; } } @@ -324,7 +305,7 @@ int OsaMutCreate(const char bName[10], int iAttributes, void **puiMutid) pthread_mutex_t *pmutex_t; if (puiMutid == NULL) { - //PrintError("In OsaMutCreate() : NULL PTR ERROR"); + LOGE(OSA_LIB, "In OsaMutCreate() : NULL PTR ERROR"); return OSAL_ERROR; } @@ -353,7 +334,7 @@ int OsaMutCreate(const char bName[10], int iAttributes, void **puiMutid) pthread_mutexattr_destroy(&attr_t); } else { - //PrintError("In OsaMutCreate() : No memory"); + LOGE(OSA_LIB, "In OsaMutCreate() : No memory"); return OSAL_ERROR; } @@ -389,7 +370,7 @@ int OsaMutDelete(void *uiMutid) if (iRet < 0) { perror("In OsaMutDelete() : failed "); - //PrintError("Error no. : %d\n",errno); + LOGE(OSA_LIB, "Error no. : %d\n", errno); return ((int)errno); } @@ -419,7 +400,7 @@ int OsaMutRelease(void *uiMutid) if (iRet < 0) { perror("In OsaMutRelease() : failed "); - //PrintError("Error no. : %d\n",errno); + LOGE(OSA_LIB, "Error no. : %d\n", errno); return ((int)errno); } @@ -446,7 +427,7 @@ int OsaMutGet(void *uiMutid, int iFlags, int iTimeout) if (iRet < 0) { perror("In OsaMutGet() : failed "); - //PrintError("Error no. : %d\n",errno); + LOGE(OSA_LIB, "Error no. : %d\n", errno); return ((int)errno); } diff --git a/osal/OsaSignal.c b/osal/OsaSignal.c index 14edc56..bf09d3b 100644 --- a/osal/OsaSignal.c +++ b/osal/OsaSignal.c @@ -24,6 +24,7 @@ * Include files *-----------------------------------------------------------------------------*/ #include "OsaLinuxUser.h" +#include /*----------------------------------------------------------------------------- * Functions @@ -50,7 +51,7 @@ int OsaSigProcmask(int iMode, const unsigned int *puiNewmask, if (iRet) { perror("SigProcMask: SigProcMask Failed "); - //PrintError("Error No. : %d\n",errno); + LOGE(OSA_LIB, "Error No. : %d\n", errno); return ((int)errno); } @@ -77,7 +78,7 @@ int OsaSigSuspend(unsigned int *puiPending) if (iRet) { perror("SigSuspend: SigSuspend INTR "); - //PrintError("Error No. : %d\n",errno); + LOGE(OSA_LIB, "Error No. : %d\n", errno); return ((int)errno); } @@ -105,7 +106,7 @@ int OsaSigTimedwait(void) if (iRet) { perror("TimeWait: TimeWait INTR "); - //PrintError("Error No. : %d\n",errno); + LOGE(OSA_LIB, "Error No. : %d\n", errno); return ((int)errno); } @@ -133,7 +134,7 @@ int OsaSigSetmask(int iSigno) if (sigaddset(&(Action_t.sa_mask), iSigno) < 0) { perror("sigaddset: sigaddset Failed "); - //PrintError("Error No. : %d\n",errno); + LOGE(OSA_LIB, "Error No. : %d\n", errno); return ((int)errno); } diff --git a/osal/OsaTask.c b/osal/OsaTask.c index afcc382..3c719bf 100644 --- a/osal/OsaTask.c +++ b/osal/OsaTask.c @@ -24,6 +24,7 @@ * Include files *-----------------------------------------------------------------------------*/ #include "OsaLinuxUser.h" +#include /*----------------------------------------------------------------------------- * MACROS @@ -59,7 +60,7 @@ static void *_thread_start_handler(void *pArg) if (iRet) { perror("In OsaTaskSpawn() : prctl() Failed\n "); - //PrintError("In OsaTaskSpawn() : prctl() error no. : %d\n", iRet); + LOGE(OSA_LIB, "In OsaTaskSpawn() : prctl() error no. : %d\n", iRet); } (*sThreadParam.pEntryFunc)(sThreadParam.pArg); @@ -132,7 +133,7 @@ int OsaTaskSpawn(const char *pName, void **puiTid, int iPriority, *puiTid = NULL; free(pThreadParam); perror("In OsaTaskSpawn() : pthread create Failed\n "); - //PrintError("In OsaTaskSpawn() : error no. : %d\n", iRet); + LOGE(OSA_LIB, "In OsaTaskSpawn() : error no. : %d\n", iRet); return ((int)iRet); } } @@ -144,7 +145,7 @@ int OsaTaskSpawn(const char *pName, void **puiTid, int iPriority, *puiTid = NULL; free(pThreadParam); perror("In OsaTaskSpawn() : pthread attr init Failed\n "); - //PrintError("In OsaTaskSpawn() : error no. : %d\n", iRet); + LOGE(OSA_LIB, "In OsaTaskSpawn() : error no. : %d\n", iRet); return ((int)iRet); } @@ -154,7 +155,7 @@ int OsaTaskSpawn(const char *pName, void **puiTid, int iPriority, *puiTid = NULL; free(pThreadParam); perror("In OsaTaskSpawn() : pthread attr setstacksize Failed\n "); - //PrintError("In OsaTaskSpawn() : error no. : %d\n", iRet); + LOGE(OSA_LIB, "In OsaTaskSpawn() : error no. : %d\n", iRet); pthread_attr_destroy(&tattr_t); return ((int)iRet); } @@ -166,7 +167,7 @@ int OsaTaskSpawn(const char *pName, void **puiTid, int iPriority, *puiTid = NULL; free(pThreadParam); perror("In OsaTaskSpawn() : pthread create Failed\n "); - //PrintError("In OsaTaskSpawn() : error no. : %d\n", iRet); + LOGE(OSA_LIB, "In OsaTaskSpawn() : error no. : %d\n", iRet); pthread_attr_destroy(&tattr_t); return ((int)iRet); } @@ -182,7 +183,7 @@ int OsaTaskSpawn(const char *pName, void **puiTid, int iPriority, if (iRet) { *puiTid = NULL; perror("In OsaTaskSpawn() : pthread setschedparam Failed\n "); - //PrintError("In OsaTaskSpawn() : error no. : %d\n", iRet); + LOGE(OSA_LIB, "In OsaTaskSpawn() : error no. : %d\n", iRet); pthread_kill(createThread, 0); return ((int)iRet); } @@ -193,14 +194,14 @@ int OsaTaskSpawn(const char *pName, void **puiTid, int iPriority, if (iRet) { *puiTid = NULL; perror("In OsaTaskSpawn() : pthread_detach Failed\n "); - //PrintError("In OsaTaskSpawn() : detach error no. : %d\n", iRet); + LOGE(OSA_LIB, "In OsaTaskSpawn() : detach error no. : %d\n", iRet); pthread_kill(createThread, 0); return ((int)iRet); } *puiTid = (void *)createThread; - //PrintDbg("%s thread created policy: %d, priority %d\n", pName, createThreadPolicy, iPriority); + LOGD(OSA_LIB, "%s thread created policy: %d, priority %d\n", pName, createThreadPolicy, iPriority); return OSAL_OK; } @@ -241,7 +242,7 @@ int OsaTaskDelete(void *uiTid) if (iRet) { perror("In OsaTaskDelete() : TaskDelete Failed "); - //PrintError("In OsaTaskDelete() : error no. : %d\n",errno); + LOGE(OSA_LIB, "In OsaTaskDelete() : error no. : %d\n",errno); return ((int)errno); } @@ -273,7 +274,7 @@ int OsaTaskSetPriority(unsigned int uiTid, int iNewpriority) if (iRet) { perror("In OsaTaskSetPriority() : TaskSetPriority set Failed "); - //PrintError("In OsaTaskSetPriority() : error no. : %d\n",errno); + LOGE(OSA_LIB, "In OsaTaskSetPriority() : error no. : %d\n",errno); return ((int)errno); } @@ -303,7 +304,7 @@ int OsaTaskGetPriority(unsigned int uiTid, int *piPriority) if (iRet) { piPriority = NULL; perror("In OsaTaskGetPriority() : TaskGetPriority Failed "); - //PrintError("In OsaTaskGetPriority() : error no. : %d\n",errno); + LOGE(OSA_LIB, "In OsaTaskGetPriority() : error no. : %d\n",errno); return ((int)errno); } @@ -341,7 +342,7 @@ int OsaTaskNanosleep(int iNanosec) if (iRetval) { perror("TaskNanoSleep: TaskNanoSleep Failed "); - //PrintError("Error No. : %d\n",errno); + LOGE(OSA_LIB, "Error No. : %d\n",errno); return ((int)errno); } @@ -395,7 +396,7 @@ int OsaTaskDelaymsecs(unsigned int uiMsec) if (iRetval) { perror("In OsaTaskDelaymsecs() : TaskNanoSleep Failed "); - //PrintError("In OsaTaskDelaymsecs() : error no. : %d\n",errno); + LOGE(OSA_LIB, "In OsaTaskDelaymsecs() : error no. : %d\n",errno); return ((int)errno); } diff --git a/simulatordaemon/inc/SecurityContext.h b/simulatordaemon/inc/SecurityContext.h index 6dddfef..2008a57 100644 --- a/simulatordaemon/inc/SecurityContext.h +++ b/simulatordaemon/inc/SecurityContext.h @@ -33,7 +33,7 @@ class SecurityContext { private: - int connFd; + int m_connFd; static constexpr const size_t CYNARA_CACHE_SIZE = 100U; diff --git a/simulatordaemon/src/ClientCommands/MakeCommand.cpp b/simulatordaemon/src/ClientCommands/MakeCommand.cpp index 6ea78cb..a41f178 100644 --- a/simulatordaemon/src/ClientCommands/MakeCommand.cpp +++ b/simulatordaemon/src/ClientCommands/MakeCommand.cpp @@ -179,10 +179,6 @@ uint32_t MakeCommand::getDataSize(TEE_CMD command) { size = sizeof(IntTACloseSessionData); LOGD(SIM_DAEMON, "[TEEC] IntTACloseSessionData Size: %d", size); break; - case CHECK_MEMORY: - // size = sizeof(CheckMemoryData); - LOGD(SIM_DAEMON, "[TEEC] CheckMemoryData Size: %d", size); - break; case PANIC: size = sizeof(IntTAPanicData); LOGD(SIM_DAEMON, "[TEEC] PanicData Size: %d", size); diff --git a/simulatordaemon/src/SecurityContext.cpp b/simulatordaemon/src/SecurityContext.cpp index 109170f..70b867f 100644 --- a/simulatordaemon/src/SecurityContext.cpp +++ b/simulatordaemon/src/SecurityContext.cpp @@ -51,7 +51,7 @@ bool SecurityContext::clientHasCynaraPermission(const std::string &privelege) { pthread_mutex_lock(&cynara_mutex); char *label = nullptr; - ret = cynara_creds_socket_get_client(connFd, CLIENT_METHOD_SMACK, &label); + ret = cynara_creds_socket_get_client(m_connFd, CLIENT_METHOD_SMACK, &label); if (ret != CYNARA_API_SUCCESS) { LOGE(SIM_DAEMON, "Couldn't get smack label of the client. Error code: %d", ret); RETURN_UNLOCK(false, cynara_mutex); @@ -59,7 +59,7 @@ bool SecurityContext::clientHasCynaraPermission(const std::string &privelege) { p_char p_label(label, &free); pid_t ca_pid = -1; - ret = cynara_creds_socket_get_pid(connFd, &ca_pid); + ret = cynara_creds_socket_get_pid(m_connFd, &ca_pid); if (ret != CYNARA_API_SUCCESS) { LOGE(SIM_DAEMON, "Couldn't get pid of the client. Error code: %d", ret); RETURN_UNLOCK(false, cynara_mutex); @@ -74,7 +74,7 @@ bool SecurityContext::clientHasCynaraPermission(const std::string &privelege) { p_char p_session(session, &free); char *user = nullptr; - ret = cynara_creds_socket_get_user(connFd, USER_METHOD_DEFAULT, &user); + ret = cynara_creds_socket_get_user(m_connFd, USER_METHOD_DEFAULT, &user); if (ret != CYNARA_API_SUCCESS) { LOGE(SIM_DAEMON, "Couldn't get user. Error code: %d", ret); RETURN_UNLOCK(false, cynara_mutex); @@ -131,7 +131,7 @@ SecurityContext::SecurityContext(): SecurityContext::SecurityContext(int connFd): - connFd(connFd) { + m_connFd(connFd) { if (_cynara == nullptr) throw std::runtime_error("Cynara is not initialized"); } diff --git a/simulatordaemon/src/TABinaryManager/TAManifest.cpp b/simulatordaemon/src/TABinaryManager/TAManifest.cpp index 90eb3bb..1f9c397 100644 --- a/simulatordaemon/src/TABinaryManager/TAManifest.cpp +++ b/simulatordaemon/src/TABinaryManager/TAManifest.cpp @@ -86,13 +86,8 @@ bool TAManifest::processXML(const string &xmlManifestPath) { properties.extension.appName = string(propertiesExtension->first_attribute("appName")->value()); properties.extension.appVersion = string(propertiesExtension->first_attribute("appVersion")->value()); - /*properties.extension.type = string(propertiesExtension->first_attribute("type")->value()); - properties.extension.zone = string(propertiesExtension->first_attribute("zone")->value());*/ properties.extension.sdkVersion = string(propertiesExtension->first_attribute("sdkVersion")->value()); - // Removed, taEncrypion flag used now - //properties.extension.secret = string(propertiesExtension->first_attribute("secret")->value()); - properties.extension.launchMode = string(propertiesExtension->first_attribute("launchMode")->value()); } } diff --git a/simulatordaemon/src/TABinaryManager/TAUnpack.cpp b/simulatordaemon/src/TABinaryManager/TAUnpack.cpp index e2aa854..01a4a32 100644 --- a/simulatordaemon/src/TABinaryManager/TAUnpack.cpp +++ b/simulatordaemon/src/TABinaryManager/TAUnpack.cpp @@ -86,7 +86,6 @@ int TAUnpack::unpackTA(string path, string uuid) { LOGE(SIM_DAEMON, "Read failed"); return -1; } - // fixHeaderEndianness(&packageHeader); // 2. Verify header if (SECURITY_HEADER_MAGIC1 == packageHeader.magic1 && SECURITY_HEADER_MAGIC2 == packageHeader.magic2) { @@ -120,7 +119,6 @@ int TAUnpack::unpackTA(string path, string uuid) { LOGE(SIM_DAEMON, "Read failed"); return -1; } - //manifest.write(manifestdump, sizeWithoutPadding(manifestdump, packageHeader.manifest_size)); manifest.write(manifestdump, packageHeader.manifest_size); manifest.flush(); delete[] manifestdump; diff --git a/ssflib/dep/cryptocore/source/base/cc_bignum.c b/ssflib/dep/cryptocore/source/base/cc_bignum.c index 2119c79..d6c96d7 100644 --- a/ssflib/dep/cryptocore/source/base/cc_bignum.c +++ b/ssflib/dep/cryptocore/source/base/cc_bignum.c @@ -424,18 +424,7 @@ static cc_u32 SDRM_DWD_MulAdd(cc_u32 *pdDest, cc_u32 dDstLen, cc_u32 *pdSrc, pdDest[i] = (cc_u32)pdDigit2; dTemp = pdDigit2 >> 32; - /*SDRM_DIGIT_Mul(pdDigit, dMultiplier, pdSrc[i]); - if ((dTemp += pdDigit[0]) < pdDigit[0]) - { - pdDigit[1]++; - } - - if ((pdDest[i] += dTemp) < dTemp) - { - pdDigit[1]++; - } - dTemp = pdDigit[1];*/ } if (i == dDstLen) @@ -536,18 +525,7 @@ static void SDRM_DWD_Mul(cc_u32 *pdDest, cc_u32 *pdSrc1, cc_u32 dSrcLen1, dTemp = pdDigit2 >> 32; - /*SDRM_DIGIT_Mul(pdDigit, pdSrc1[i], pdSrc2[j]); - if ((dTemp += pdDigit[0]) < pdDigit[0]) - { - pdDigit[1]++; - } - if ((pdDest[i + j] += dTemp) < dTemp) - { - pdDigit[1]++; - } - - dTemp = pdDigit[1];*/ } pdDest[i + j] = dTemp; @@ -1436,8 +1414,6 @@ int SDRM_BN_Div(SDRM_BIG_NUM *BN_Quotient, SDRM_BIG_NUM *BN_Remainder, if (SDRM_BN_Cmp(temp_Dividend, temp_Divisor) < 0) { if (BN_Remainder != NULL) { SDRM_BN_Copy(BN_Remainder, temp_Dividend); - //free(pbBuf); - //return CRYPTO_SUCCESS; modify by Chalyi Aleksandr: it is not correct } if (BN_Quotient != NULL) @@ -1911,10 +1887,8 @@ int SDRM_MONT_Rzn2zn(SDRM_BIG_NUM *BN_Dst, SDRM_BIG_NUM *BN_Src1, SDRM_BN_OPTIMIZE_LENGTH(Src1); SDRM_BN_SHR(BN_Dst, Src1, (Mod_Len) * 32); - //BN_Dst->Length = Src1->Length - ri; - BN_Dst->Length = Src1->Length - ri - 1; //Added by yhhwang + BN_Dst->Length = Src1->Length - ri - 1;//Added by yhhwang - //if (SDRM_BN_Cmp(BN_Dst, Mont->Mod) >= 0) while (SDRM_BN_Cmp(BN_Dst, Mont->Mod) >= 0) SDRM_BN_Sub(BN_Dst, BN_Dst, Mont->Mod); @@ -1939,45 +1913,6 @@ int SDRM_MONT_Mul(SDRM_BIG_NUM *BN_Dst, SDRM_BIG_NUM *BN_Src1, { int ret; - /* Begin - Add to test input range by Yong Ho Hwang (20120809) */ - /* - if (SDRM_BN_Cmp(BN_Src1, Mont->Mod) >= 0) - { - ret = SDRM_BN_ModRed(BN_Src1, BN_Src1, Mont->Mod); - if (ret != CRYPTO_SUCCESS) - { - return ret; - } - } else if ( BN_Src1->sign == 1) - { - printf("Minus Value\n"); - ret = SDRM_BN_Add(BN_Src1, BN_Src1, Mont->Mod); - if (BN_Src1->sign == 1) - { - printf("Value Fail.\n"); - return CRYPTO_ERROR; - } - } - - if (SDRM_BN_Cmp(BN_Src2, Mont->Mod) >= 0) - { - ret = SDRM_BN_ModRed(BN_Src2, BN_Src2, Mont->Mod); - if (ret != CRYPTO_SUCCESS) - { - return ret; - } - } else if ( BN_Src2->sign == 1) - { - printf("Minus Value\n"); - ret = SDRM_BN_Add(BN_Src2, BN_Src2, Mont->Mod); - if (BN_Src2->sign == 1) - { - printf("Value Fail.\n"); - return CRYPTO_ERROR; - } - } - */ - /* End - Add to test input range by Yong Ho Hwang (20120809) */ ret = SDRM_BN_Mul(BN_Dst, BN_Src1, BN_Src2); @@ -1986,17 +1921,6 @@ int SDRM_MONT_Mul(SDRM_BIG_NUM *BN_Dst, SDRM_BIG_NUM *BN_Src1, ret = SDRM_MONT_Rzn2zn(BN_Dst, BN_Dst, Mont); - /* Begin - Add to test input range by Yong Ho Hwang (20120809) */ - /* - if (SDRM_BN_Cmp(BN_Dst, Mont->Mod) >= 0) - { - printf("Output is bigger than Mod\n"); - } else if ( BN_Dst->sign == 1) - { - printf("Minus Value\n"); - } - */ - /* End - Add to test input range by Yong Ho Hwang (20120809) */ return ret; } @@ -2049,39 +1973,7 @@ int SDRM_MONT_Set(SDRM_BIG_MONT *Mont, SDRM_BIG_NUM *BN_Modulus) R = SDRM_BN_Alloc((cc_u8 *)Ri + dAllocSize, dSize); temp = SDRM_BN_Alloc((cc_u8 *)R + dAllocSize, dSize); - //++ 2012.08.20 - modified by yhhwang to apply R=2^(160+32) - /* == DELETED == - SDRM_BN_Copy(Mont->Mod, BN_Modulus); - - Mont->ri = (SDRM_BN_num_bits(BN_Modulus) + (SDRM_BitsInDWORD - 1)) / SDRM_BitsInDWORD * SDRM_BitsInDWORD; - - SDRM_BN_SHL(R, BN_One, SDRM_BitsInDWORD); - - buf[0] = BN_Modulus->pData[0]; - buf[1] = 0; - temp->pData[0] = buf[0]; - temp->Length = 1; - temp->sign = BN_Modulus->sign; - - SDRM_BN_ModInv(Ri, R, temp); - if (Ri == NULL) - { - free(pbBuf); - - return CRYPTO_INVERSE_NOT_EXIST; - } - - SDRM_BN_SHL(Ri, Ri, SDRM_BitsInDWORD); - SDRM_BN_Sub(Ri, Ri, BN_One); - SDRM_BN_Div(Ri, NULL, Ri, temp); - SDRM_BN_Copy(Mont->Inv_Mod, Ri); - Mont->N0 = Ri->pData[0]; - - SDRM_BN_SHL(Mont->R, BN_One, 2 * (32 + Mont->ri)); - SDRM_BN_ModRed(Mont->R, Mont->R, Mont->Mod); - */ - // == NEW CODE == SDRM_BN_Copy(Mont->Mod, BN_Modulus); Mont->Mod->pData[Mont->Mod->Length] = 0; @@ -2113,7 +2005,6 @@ int SDRM_MONT_Set(SDRM_BIG_MONT *Mont, SDRM_BIG_NUM *BN_Modulus) // Compute R and R^2 mod M SDRM_BN_SHL(Rsquare, BN_One, r2Size); SDRM_BN_ModRed(Mont->R, Rsquare, BN_Modulus); - //-- 2012.08.20 - modified by yhhwang free(pbBuf); free(Rsquare); @@ -2595,16 +2486,9 @@ int SDRM_HEX2BN(cc_u8 *pbSrc, SDRM_BIG_NUM *BN_Dst) //normalize length if (n % SDRM_SIZE_BLOCK != 0) - BN_Dst->Length += 1; - -#if 0 //fix prevent problem by guoxing.xu 20140826. move to before - - if (!BN_Dst) - BN_Dst = SDRM_BN_Init(BN_Dst->Length * SDRM_SIZE_OF_DWORD * 8); - -#endif + BN_Dst->Length += 1; - for (i = 0; i < BN_Dst->Length ; i++) + for (i = 0; i < BN_Dst->Length; i++) BN_Dst->pData[i] = 0; //full string: bufferHex mod Length = 0 @@ -2800,10 +2684,8 @@ cc_u8 *SDRM_BN2STRFOUR(cc_u32 *numberBits, SDRM_BIG_NUM *BN_Src) while (!SDRM_BN_isZero(num)) { SDRM_BN_Div(num, tempREM, num, d); - //itoa(tempREM->pData[0], (char *)tempChar, 10); - //sprintf((char*)tempChar, "%d", tempREM->pData[0]); snprintf((char *)tempChar, sizeof(tempChar), "%d", - tempREM->pData[0]); // fix prevnet 60199 by guoxing.xu + tempREM->pData[0]); strDestTemp[(*numberBits)] = tempChar[0]; (*numberBits)++; @@ -2864,14 +2746,11 @@ SDRM_BIG_NUM **SDRM_BN_MassInit(cc_u32 dBufSize, cc_u32 count) ptr = (cc_u8 *)BN_Buf + sizeof(SDRM_BIG_NUM *) * count; for (i = 0; i < count; i++) { - //add by guoxing.xu to avoid warning. 2/15/2014 tmp = ptr; BN_Buf[i] = (SDRM_BIG_NUM *)tmp; - //BN_Buf[i] = (SDRM_BIG_NUM*)ptr; BN_Buf[i]->Size = dBufSize; tmp = (ptr + sizeof(SDRM_BIG_NUM)); BN_Buf[i]->pData = (cc_u32 *)tmp; - //BN_Buf[i]->pData = (cc_u32*)(ptr + sizeof(SDRM_BIG_NUM)); ptr += bnsiz; } diff --git a/ssflib/dep/cryptocore/source/base/cc_ecc.c b/ssflib/dep/cryptocore/source/base/cc_ecc.c index 9908edd..8d52715 100644 --- a/ssflib/dep/cryptocore/source/base/cc_ecc.c +++ b/ssflib/dep/cryptocore/source/base/cc_ecc.c @@ -1040,8 +1040,6 @@ int SDRM_CTX_EC_2kP(SDRM_ECC_CTX *ctx, SDRM_EC_POINT *EC_Dst, SDRM_BIG_NUM *k1, // Precomputation data for (i = 0; i < 2; i++) { - // Pw[i] = (SDRM_EC_POINT **)malloc(sizeof(SDRM_EC_POINT *) * w2); - // if (!Pw[i]) return CRYPTO_MEMORY_ALLOC_FAIL; for (j = 0; j < 9; j++) Pw[i][j] = SDRM_ECC_Init(); } diff --git a/ssflib/dep/cryptocore/source/base/cc_md5.c b/ssflib/dep/cryptocore/source/base/cc_md5.c index cbb667f..6cef2f0 100644 --- a/ssflib/dep/cryptocore/source/base/cc_md5.c +++ b/ssflib/dep/cryptocore/source/base/cc_md5.c @@ -36,13 +36,6 @@ static void SDRM_Decode(cc_u32 *, const unsigned char *, cc_u32); static unsigned char PADDING[64] = {0x80, 0,}; -/* F, G, H and I are basic MD5 functions. - */ -//#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -//#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -//#define H(x, y, z) ((x) ^ (y) ^ (z)) -//#define I(x, y, z) ((y) ^ ((x) | (~z))) - #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) #define G(x, y, z) F(z, x, y) #define H(x, y, z) ((x) ^ (y) ^ (z)) diff --git a/ssflib/dep/cryptocore/source/base/cc_pkcs1_v21.c b/ssflib/dep/cryptocore/source/base/cc_pkcs1_v21.c index 74f7eb5..dfd2171 100644 --- a/ssflib/dep/cryptocore/source/base/cc_pkcs1_v21.c +++ b/ssflib/dep/cryptocore/source/base/cc_pkcs1_v21.c @@ -755,7 +755,6 @@ int SDRM_Enpad_Rsassa_pss(cc_u8 *EM, cc_u32 nBits, cc_u8 *h, cc_u32 hLen, EM[emLen - sLen - hLen - 2] ^= 0x01; - //memset(EM, 0x00, emLen - sLen - hLen - 2); for (i = 0; i < sLen; i++) EM[emLen - sLen - hLen - 1 + i] ^= salt[i]; diff --git a/ssflib/dep/cryptocore/source/base/cc_rc4.c b/ssflib/dep/cryptocore/source/base/cc_rc4.c index ec769e6..245f2e6 100644 --- a/ssflib/dep/cryptocore/source/base/cc_rc4.c +++ b/ssflib/dep/cryptocore/source/base/cc_rc4.c @@ -87,10 +87,8 @@ int SDRM_RC4_Setup(SDRM_RC4Context *ctx, cc_u8 *UserKey, cc_u32 keyLen) i = 0xff; if (((cc_u8 *)&i)[0] == 0xff) { - // LOG4DRM_INFO(&CryptoLogCTX), "is Little Endian machine\n"); memcpy(ctx->s, RC4_S_VALUE_LITTLE, 256); } else { - // LOG4DRM_INFO(&CryptoLogCTX), "is Big Endian machine\n"); memcpy(ctx->s, RC4_S_VALUE_BIG, 256); } diff --git a/ssflib/dep/cryptocore/source/base/cc_sha1.c b/ssflib/dep/cryptocore/source/base/cc_sha1.c index 8f3de28..c64dcbc 100644 --- a/ssflib/dep/cryptocore/source/base/cc_sha1.c +++ b/ssflib/dep/cryptocore/source/base/cc_sha1.c @@ -75,12 +75,10 @@ static void SDRM_SHAtoByte(unsigned char *output, unsigned int *input, save one boolean operation each - thanks to Rich Schroeppel, rcs@cs.arizona.edu for discovering this */ -/*#define SDRM_SHA1_f1(x,y,z) ((x & y) | (~x & z)) // Rounds 0-19 */ -#define SDRM_SHA1_f1(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) /* Rounds 0-19 */ -#define SDRM_SHA1_f2(x, y, z) ((x) ^ (y) ^ (z)) /* Rounds 20-39 */ -/*#define SDRM_SHA1_f3(x,y,z) ((x & y) | (x & z) | (y & z)) // Rounds 40-59 */ -#define SDRM_SHA1_f3(x, y, z) (((x) & (y)) | ((z) & ((x) | (y)))) /* Rounds 40-59 */ -#define SDRM_SHA1_f4(x, y, z) ((x) ^ (y) ^ (z)) /* Rounds 60-79 */ +#define SDRM_SHA1_f1(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) /* Rounds 0-19 */ +#define SDRM_SHA1_f2(x, y, z) ((x) ^ (y) ^ (z)) /* Rounds 20-39 */ +#define SDRM_SHA1_f3(x, y, z) (((x) & (y)) | ((z) & ((x) | (y)))) /* Rounds 40-59 */ +#define SDRM_SHA1_f4(x, y, z) ((x) ^ (y) ^ (z)) /* Rounds 60-79 */ /* The SHS Mysterious Constants */ @@ -464,77 +462,6 @@ static void SDRM_SHAtoByte(unsigned char *output, unsigned int *input, } -//unsigned char digest[20]; -//unsigned char message[3] = {'a', 'b', 'c' }; -//unsigned char *mess56 = -// "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; - -/* Correct solutions from FIPS PUB 180-1 */ -//char *dig1 = "A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D"; -//char *dig2 = "84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1"; -//char *dig3 = "34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F"; - -/* Output should look like:- - a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d - A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D <= correct - 84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1 - 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 <= correct - 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f - 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F <= correct -*/ - -//main() -//{ -// SHA_CTX sha; -// int i; -// BYTE big[1000]; -// -// SHAInit(&sha); -// SHAUpdate(&sha, message, 3); -// SHAFinal(digest, &sha); -// -// for (i = 0; i < 20; i++) -// { -// if ((i % 4) == 0) printf(" "); -// printf("%02x", digest[i]); -// } -// printf("\n"); -// printf(" %s <= correct\n", dig1); -// -// SHAInit(&sha); -// SHAUpdate(&sha, mess56, 56); -// SHAFinal(digest, &sha); -// -// for (i = 0; i < 20; i++) -// { -// if ((i % 4) == 0) printf(" "); -// printf("%02x", digest[i]); -// } -// printf("\n"); -// printf(" %s <= correct\n", dig2); -// -// /* Fill up big array */ -// for (i = 0; i < 1000; i++) -// big[i] = 'a'; -// -// SHAInit(&sha); -// /* Digest 1 million x 'a' */ -// for (i = 0; i < 1000; i++) -// SHAUpdate(&sha, big, 1000); -// SHAFinal(digest, &sha); -// -// for (i = 0; i < 20; i++) -// { -// if ((i % 4) == 0) printf(" "); -// printf("%02x", digest[i]); -// } -// printf("\n"); -// printf(" %s <= correct\n", dig3); -// -// return 0; -//} - -/* endian.c */ void SDRM_endianTest(int *endian_ness) { diff --git a/ssflib/dep/cryptocore/source/middle/cc_cmac.c b/ssflib/dep/cryptocore/source/middle/cc_cmac.c index 1e33d93..0394bf6 100644 --- a/ssflib/dep/cryptocore/source/middle/cc_cmac.c +++ b/ssflib/dep/cryptocore/source/middle/cc_cmac.c @@ -107,8 +107,7 @@ int SDRM_CMAC_init(CryptoCoreContainer *crt, cc_u8 *Key, cc_u32 KeyLen) BlockXor(K2, K2, R_b); } - // LOG4DRM_BUFFER(&CryptoLogCTX), LOG_DEBUG, "K1", K1, 16); - // LOG4DRM_BUFFER(&CryptoLogCTX), LOG_DEBUG, "K2", K2, 16); + return CRYPTO_SUCCESS; } @@ -161,7 +160,7 @@ int SDRM_CMAC_update(CryptoCoreContainer *crt, cc_u8 *msg, cc_u32 msgLen) ptr += SDRM_AES_BLOCK_SIZ; } - // LOG4DRM_BUFFER(&CryptoLogCTX), LOG_DEBUG, "Block", crt->ctx->cmacctx->IV, 16); + memcpy(crt->ctx->cmacctx->Block, ptr, crt->ctx->cmacctx->BlockLen); diff --git a/ssflib/dep/cryptocore/source/middle/cc_dsa.c b/ssflib/dep/cryptocore/source/middle/cc_dsa.c index da53040..4ab673b 100644 --- a/ssflib/dep/cryptocore/source/middle/cc_dsa.c +++ b/ssflib/dep/cryptocore/source/middle/cc_dsa.c @@ -570,8 +570,7 @@ int SDRM_DSA_verify(CryptoCoreContainer *crt, cc_u8 *hash, cc_u32 hashLen, SDRM_BN_ModRed(v, temp3, crt->ctx->dsactx->q); //v = (alpha^u1 x y^u2 mod p) mod q - // SDRM_PrintBN("v : ", v); - // SDRM_PrintBN("Hash : ", BNH_m); + if (SDRM_BN_Cmp(v, BN_r) == 0) *result = CRYPTO_VALID_SIGN; diff --git a/ssflib/dep/cryptocore/source/middle/cc_ecdsa.c b/ssflib/dep/cryptocore/source/middle/cc_ecdsa.c index 1725ead..141797f 100644 --- a/ssflib/dep/cryptocore/source/middle/cc_ecdsa.c +++ b/ssflib/dep/cryptocore/source/middle/cc_ecdsa.c @@ -180,7 +180,6 @@ int SDRM_CTX_ECDSA_SIG_GEN(SDRM_ECC_CTX *ctx, cc_u8 *sig, cc_u8 *hash, return res; } - //SDRM_PrintBN("kP->x", kP->x); SDRM_BN_ModRed(BN_r, kP->x, ctx->ECC_n); if (BN_r->Length > 0) // r = 0 �̸� k �ٽ� ���� @@ -190,9 +189,6 @@ int SDRM_CTX_ECDSA_SIG_GEN(SDRM_ECC_CTX *ctx, cc_u8 *sig, cc_u8 *hash, // 3. k^{-1} mod n ���. SDRM_BN_ModInv(BN_Tmp1, BN_k, ctx->ECC_n); - //SDRM_PrintBN("BN_k", BN_k); - //SDRM_PrintBN("ctx->ECC_n", ctx->ECC_n); - //SDRM_PrintBN("BN_Tmp1 = k^{-1} mod n", BN_Tmp1); // 4. s = k^{-1}(hash + dr) mod n ��� (d = private key). s = 0 �̸� 1������. // BN_Tmp2 = dr @@ -206,9 +202,7 @@ int SDRM_CTX_ECDSA_SIG_GEN(SDRM_ECC_CTX *ctx, cc_u8 *sig, cc_u8 *hash, break; } - // (r, s) �������� ���. - //SDRM_PrintBN("BN_r", BN_r); - //SDRM_PrintBN("BN_s", BN_s); +// (r, s) �������� ���. SDRM_BN2OS(BN_r, ctx->uDimension / 8, sig); SDRM_BN2OS(BN_s, ctx->uDimension / 8, sig + ctx->uDimension / 8); @@ -286,8 +280,6 @@ int SDRM_CTX_ECDSA_SIG_VERIFY(SDRM_ECC_CTX *ctx, cc_u8 *sig, int signLen, SDRM_OS2BN(sig, ctx->uDimension / 8, pBN_r); SDRM_OS2BN(sig + ctx->uDimension / 8, ctx->uDimension / 8, pBN_s); - //SDRM_PrintBN("BN_r", pBN_r); - //SDRM_PrintBN("BN_s", pBN_s); // 1. r�� s�� ���� ���� SDRM_BN_Sub(BN_tmp, ctx->ECC_n, BN_One); @@ -311,7 +303,6 @@ int SDRM_CTX_ECDSA_SIG_VERIFY(SDRM_ECC_CTX *ctx, cc_u8 *sig, int signLen, // 2. w = s^(-1) mod n, BN_hash ��� SDRM_OS2BN(hash, hashLen, BN_hash); res = SDRM_BN_ModInv(BN_w, pBN_s, ctx->ECC_n); - //SDRM_PrintBN("BN_w", BN_w); if (res != CRYPTO_SUCCESS) { free(pbBuf); @@ -324,8 +315,7 @@ int SDRM_CTX_ECDSA_SIG_VERIFY(SDRM_ECC_CTX *ctx, cc_u8 *sig, int signLen, // 3. u1 = BN_hash *w mod n, u2 = rw mod n SDRM_BN_ModMul(BN_u1, BN_hash, BN_w, ctx->ECC_n); SDRM_BN_ModMul(BN_u2, pBN_r, BN_w, ctx->ECC_n); - //SDRM_PrintBN("BN_u1", BN_u1); - //SDRM_PrintBN("BN_u2", BN_u2); + // 4. (x0, y0) = u1P + u2Q, V = x0 mod n res = SDRM_CTX_EC_2kP(ctx, EC_temp1, BN_u1, ctx->ECC_G, BN_u2, ctx->PUBLIC_KEY); @@ -345,12 +335,10 @@ int SDRM_CTX_ECDSA_SIG_VERIFY(SDRM_ECC_CTX *ctx, cc_u8 *sig, int signLen, return res; } - // SDRM_PrintBN("EC_temp1->x", EC_temp1->x); - // SDRM_PrintBN("ctx->ECC_n", ctx->ECC_n); + SDRM_BN_ModRed(BN_tmp, EC_temp1->x, ctx->ECC_n); - // SDRM_PrintBN("BN_tmp", BN_tmp); - // SDRM_PrintBN("pBN_r", pBN_r); + // 5. V = r�� ��� ���� ok res = SDRM_BN_Cmp_sign(BN_tmp, pBN_r); diff --git a/ssflib/dep/cryptocore/source/middle/cc_rsa.c b/ssflib/dep/cryptocore/source/middle/cc_rsa.c index 8aad8ad..9f24538 100644 --- a/ssflib/dep/cryptocore/source/middle/cc_rsa.c +++ b/ssflib/dep/cryptocore/source/middle/cc_rsa.c @@ -311,8 +311,6 @@ GEN_RND: q->pData[q->Length - 1] |= (1L << t1); } while (SDRM_BN_MILLER_RABIN(q, sp) != CRYPTO_ISPRIME); - // SDRM_PrintBN("p", p); - // SDRM_PrintBN("q", q); //temp1 = (p - 1), temp2 = (q - 1) SDRM_BN_Sub(temp1, p, BN_One); @@ -878,8 +876,6 @@ GEN_RND: q->pData[q->Length - 1] |= (1L << t1); } while (SDRM_BN_MILLER_RABIN(q, sp) != CRYPTO_ISPRIME); - // SDRM_PrintBN("p", p); - // SDRM_PrintBN("q", q); //temp1 = (p - 1), temp2 = (q - 1) @@ -1037,7 +1033,6 @@ int SDRM_RSA_encrypt(CryptoCoreContainer *crt, cc_u8 *in, cc_u32 inLen, return CRYPTO_INVALID_ARGUMENT; } - // SDRM_PrintBN("ENPADDED Text : ", BN_pMsg); if (retVal != CRYPTO_SUCCESS) { free(pbBuf); @@ -1293,7 +1288,6 @@ int SDRM_RSA_decryptByCRT(CryptoCoreContainer *crt, cc_u8 *in, cc_u32 inLen, return CRYPTO_INVALID_ARGUMENT; } - // SDRM_PrintBN("OAEP Text : ", BN_dMsg); SDRM_I2OSP(BN_dMsg, RSA_KeyByteLen, pbBuf); @@ -1377,24 +1371,17 @@ int SDRM_RSA_sign(CryptoCoreContainer *crt, cc_u8 *hash, cc_u32 hashLen, //Msg Padding switch (SDRM_LOW_HALF(crt->ctx->rsactx->pm)) { case ID_RSASSA_PKCS15: - retVal = SDRM_Enpad_Rsassa_pkcs15(pbBuf, RSA_KeyByteLen, hash, hashLen, - SDRM_HIGH_HALF(crt->ctx->rsactx->pm)); + retVal = SDRM_Enpad_Rsassa_pkcs15(pbBuf, RSA_KeyByteLen, hash, hashLen, SDRM_HIGH_HALF(crt->ctx->rsactx->pm)); break; - case ID_RSASSA_PSS: SDRM_BN_GETBITLEN(crt->ctx->rsactx->n, nBits); - retVal = SDRM_Enpad_Rsassa_pss(pbBuf, nBits, hash, hashLen, RSA_KeyByteLen, - SDRM_HIGH_HALF(crt->ctx->rsactx->pm)); + retVal = SDRM_Enpad_Rsassa_pss(pbBuf, nBits, hash, hashLen, RSA_KeyByteLen, SDRM_HIGH_HALF(crt->ctx->rsactx->pm)); break; - case ID_NO_PADDING: memset(pbBuf, 0x00, RSA_KeyByteLen - hashLen); - //memcpy(pbBuf + hashLen, hash, RSA_KeyByteLen); - memcpy(pbBuf + RSA_KeyByteLen - hashLen, hash, - hashLen);// fixed by guoxing.xu 20140919 + memcpy(pbBuf + RSA_KeyByteLen - hashLen, hash, hashLen);// fixed by guoxing.xu 20140919 retVal = CRYPTO_SUCCESS; break; - default: free(pbBuf); return CRYPTO_INVALID_ARGUMENT; @@ -1405,7 +1392,6 @@ int SDRM_RSA_sign(CryptoCoreContainer *crt, cc_u8 *hash, cc_u32 hashLen, return retVal; } - // SDRM_PrintBN("ENPADDED Msg : ", BN_pMsg); SDRM_OS2BN(pbBuf, RSA_KeyByteLen, BN_pMsg); @@ -1478,7 +1464,6 @@ int SDRM_RSA_verify(CryptoCoreContainer *crt, cc_u8 *hash, cc_u32 hashLen, SDRM_RSA_BN_BUFSIZE); SDRM_OS2BN(signature, signLen, BN_Sign); - // SDRM_PrintBN("Generated Sign : ", BN_Sign); //RSA Verification by modular exponent #ifndef _OP64_NOTSUPPORTED diff --git a/ssflib/dep/swdss/source/file_op.cpp b/ssflib/dep/swdss/source/file_op.cpp index c731bd0..9e1350b 100644 --- a/ssflib/dep/swdss/source/file_op.cpp +++ b/ssflib/dep/swdss/source/file_op.cpp @@ -74,8 +74,6 @@ int file_op::write_file(const char* filename, unsigned char* buffer, fflush(file); - //sync(fileno(file)); // sync blocked - fclose(file); return SS_RET_SUCCESS; @@ -198,7 +196,6 @@ int file_op::create_folder(const char* folder) { result = SS_RET_FAIL; SLOGE("Failed to create folder %s.", folder); } - //sync(); } else if (!(S_ISDIR(st.st_mode))) { result = SS_RET_FAIL; } diff --git a/ssflib/dep/swdss/source/secure_file.cpp b/ssflib/dep/swdss/source/secure_file.cpp index 9a828f1..8a0700a 100644 --- a/ssflib/dep/swdss/source/secure_file.cpp +++ b/ssflib/dep/swdss/source/secure_file.cpp @@ -24,7 +24,6 @@ #ifdef _SECOS_SIM_ #include "file_op.h" -//#define SWD_SS_ROOT "/opt/usr/apps/tz_simulator/data/swdss/" #define SWD_SS_ROOT "/tmp/tastore2/" #endif @@ -320,12 +319,6 @@ int is_valid_credential(const ss_credential_s& cred) { return SS_RET_INVALID_CREDENTIAL; } - // checking specific values - //if (tmp_uuid[14] != '4' || (tmp_uuid[19] != '8' && tmp_uuid[19] != '9' && tmp_uuid[19] != 'a' && tmp_uuid[19] != 'b')) - //{ - // return SS_RET_INVALID_CREDENTIAL; - //} - // checking that string contains only hexidecimal values if (-1 == is_hex(tmp_uuid, '-')) { return SS_RET_INVALID_CREDENTIAL; } @@ -488,9 +481,16 @@ int secure_file::derive_file_path() { return SS_RET_SUCCESS; } + int remaining = SS_FULL_DATA_NAME_LEN; + memcpy(m_full_path, m_cred.uuid, SS_MAX_UUID_LEN); - strcat(m_full_path, "/"); - strcat(m_full_path, m_data_name); + m_full_path[SS_MAX_UUID_LEN] = '\0'; + remaining -= SS_MAX_UUID_LEN; + + strncat(m_full_path, "/", 1); + remaining -= 1; + + strncat(m_full_path, m_data_name, remaining - 1); m_file_path_ready = true; return SS_RET_SUCCESS; #else @@ -520,10 +520,8 @@ int secure_file::derive_file_path() { // obtain first part of our string byte_to_hex(pFolderName, pHash, CCryptoEngine::Hash_Size); memcpy(sTemp, pFolderName, 2 * CCryptoEngine::Hash_Size); - //sTemp.assign((char*)pFolderName, 2*CCryptoEngine::Hash_Size); // concatenate with UUID and Name - //sTemp += sUUID_and_Name; memcpy(sTemp + 2 * CCryptoEngine::Hash_Size, sUUID_and_Name, strlen(sUUID_and_Name)); @@ -532,14 +530,6 @@ int secure_file::derive_file_path() { CCryptoEngine::Hash(pHash, (CBT_OCTET*)sTemp, strlen(sTemp)); // we will use first 4 bytes of hash value - // convert them into hex format - //byte_to_hex(pFolderName, pHash, 4); - - // set folder name - //sfolder.assign((char*)pFolderName, 8); - //sfolder += "/"; - - //m_full_path = sfolder; memset(m_full_path, 0, SS_FULL_DATA_NAME_LEN); memcpy(m_full_path, pHash, 4); @@ -547,8 +537,6 @@ int secure_file::derive_file_path() { byte_to_hex(dir, pHash, 4); SLOGI("Dir is %s.", (char*)dir); - //m_full_path[8] = '/'; - if (0 != strlen(m_data_name)) { // computing file name uint64_t data_id = transform_id_to_name(transform_name_to_id(m_data_name)); @@ -809,7 +797,6 @@ int secure_file::parse_file_content(unsigned char* buffer, switch (FileStructureType(ptr)) { case 0: { - // [header][hash][data][key] m_file_content.m_pFileHeader = ptr; ptr += HEADER_SIZE; m_file_content.m_pHashMaterial = ptr; @@ -821,7 +808,6 @@ int secure_file::parse_file_content(unsigned char* buffer, break; } case 1: { - // [header][hash][key][data] m_file_content.m_pFileHeader = ptr; ptr += HEADER_SIZE; m_file_content.m_pHashMaterial = ptr; @@ -833,7 +819,6 @@ int secure_file::parse_file_content(unsigned char* buffer, break; } case 2: { - // [header][data][key][hash] m_file_content.m_pFileHeader = ptr; ptr += HEADER_SIZE; m_file_content.m_pFileContent = ptr; @@ -845,7 +830,6 @@ int secure_file::parse_file_content(unsigned char* buffer, break; } case 3: { - // [header][key][data][hash] m_file_content.m_pFileHeader = ptr; ptr += HEADER_SIZE; m_file_content.m_pKeyMaterial = ptr; @@ -857,7 +841,6 @@ int secure_file::parse_file_content(unsigned char* buffer, break; } case 4: { - // [header][key][hash][data] m_file_content.m_pFileHeader = ptr; ptr += HEADER_SIZE; m_file_content.m_pKeyMaterial = ptr; @@ -869,7 +852,6 @@ int secure_file::parse_file_content(unsigned char* buffer, break; } case 5: { - // [header][data][hash][key] m_file_content.m_pFileHeader = ptr; ptr += HEADER_SIZE; m_file_content.m_pFileContent = ptr; @@ -944,7 +926,6 @@ int secure_file::serialize_data(unsigned char** buffer, #ifdef _SECOS_SIM_ *buffer = (unsigned char*)OsaMalloc(m_write_data_size); if (NULL == *buffer) { - //SLOGE("fail to alloc memory for data."); return SS_RET_MALLOC_FAILED; } @@ -975,7 +956,6 @@ int secure_file::serialize_data(unsigned char** buffer, unsigned char* ptr = data; switch (FileStructureType(m_file_content.m_pFileHeader)) { case 0: { - // [header][hash][data][key] memcpy(ptr, m_file_content.m_pFileHeader, HEADER_SIZE); ptr += HEADER_SIZE; memcpy(ptr, m_file_content.m_pHashMaterial, HASH_SIZE); @@ -989,7 +969,6 @@ int secure_file::serialize_data(unsigned char** buffer, break; } case 1: { - // [header][hash][key][data] memcpy(ptr, m_file_content.m_pFileHeader, HEADER_SIZE); ptr += HEADER_SIZE; memcpy(ptr, m_file_content.m_pHashMaterial, HASH_SIZE); @@ -1003,7 +982,6 @@ int secure_file::serialize_data(unsigned char** buffer, break; } case 2: { - // [header][data][key][hash] memcpy(ptr, m_file_content.m_pFileHeader, HEADER_SIZE); ptr += HEADER_SIZE; memcpy(ptr, @@ -1017,7 +995,6 @@ int secure_file::serialize_data(unsigned char** buffer, break; } case 3: { - // [header][key][data][hash] memcpy(ptr, m_file_content.m_pFileHeader, HEADER_SIZE); ptr += HEADER_SIZE; memcpy(ptr, m_file_content.m_pKeyMaterial, KEY_MAT_SIZE); @@ -1031,7 +1008,6 @@ int secure_file::serialize_data(unsigned char** buffer, break; } case 4: { - // [header][key][hash][data] memcpy(ptr, m_file_content.m_pFileHeader, HEADER_SIZE); ptr += HEADER_SIZE; memcpy(ptr, m_file_content.m_pKeyMaterial, KEY_MAT_SIZE); @@ -1045,7 +1021,6 @@ int secure_file::serialize_data(unsigned char** buffer, break; } case 5: { - // [header][data][hash][key] memcpy(ptr, m_file_content.m_pFileHeader, HEADER_SIZE); ptr += HEADER_SIZE; memcpy(ptr, diff --git a/ssflib/dep/swdss/source/ss_crypto.cpp b/ssflib/dep/swdss/source/ss_crypto.cpp index d4c5e99..3b8bb97 100644 --- a/ssflib/dep/swdss/source/ss_crypto.cpp +++ b/ssflib/dep/swdss/source/ss_crypto.cpp @@ -40,8 +40,6 @@ void gen_rand_vec(CBT_OCTET* vec, CBT_UINT32 size) { */ int CCryptoEngine::Encrypt(uint8_t* dest, uint8_t* src, unsigned long data_len, const uint8_t* key, unsigned long key_type) { - //memcpy(dest,src,data_len); - //return data_len; unsigned int cipherTextLen, t; CryptoCoreContainer *crt = create_CryptoCoreContainer(ID_AES); diff --git a/ssflib/dep/uci/source/uci_api.c b/ssflib/dep/uci/source/uci_api.c index a21522c..2873e7d 100644 --- a/ssflib/dep/uci/source/uci_api.c +++ b/ssflib/dep/uci/source/uci_api.c @@ -28,7 +28,6 @@ #include "uci_cryptocore.h" #include "uci_internal.h" #include "uci_hwcrypto.h" -//#include "ae.h" #include "CC_Context.h" #include "uci_aes_xcbc_mac.h" diff --git a/ssflib/dep/uci/source/uci_cryptocore.c b/ssflib/dep/uci/source/uci_cryptocore.c index 6a87eb1..7aed80a 100644 --- a/ssflib/dep/uci/source/uci_cryptocore.c +++ b/ssflib/dep/uci/source/uci_cryptocore.c @@ -844,8 +844,6 @@ int cryptocore_ae_decryptbycrt(UCI_HANDLE oh, unsigned char *input, if (pctx->config != UCI_SW) return UCI_INVALID_HANDLE; - // ctr=(CryptoCoreContainer *)(pctx->imp); - // ctr->MD_update(ctr,msg,msg_len); ret = ((CryptoCoreContainer *)pctx->imp)->AE_decryptByCRT( ((CryptoCoreContainer *)pctx->imp), input, input_len, output, output_len); diff --git a/ssflib/dep/uci/source/uci_hwcrypto.c b/ssflib/dep/uci/source/uci_hwcrypto.c index adcf86e..7642d97 100644 --- a/ssflib/dep/uci/source/uci_hwcrypto.c +++ b/ssflib/dep/uci/source/uci_hwcrypto.c @@ -457,9 +457,7 @@ int hwcrypto_se_init(UCI_HANDLE oh, unsigned int mode, unsigned int padding, else memset(info->iv, 0x0, info->ivlen); - pctx->handle = open("/dev/crypto", 0, 0); //return hndl; - - //TA_PRINT("hand = %d \n",pctx->handle); + pctx->handle = open("/dev/crypto", 0, 0); if (pctx->handle < 0) return UCI_ERROR; @@ -476,22 +474,22 @@ int hwcrypto_se_init(UCI_HANDLE oh, unsigned int mode, unsigned int padding, uci_context_s *pctx = (uci_context_s *)oh; unsigned int keytype; unsigned int alg; - //!AS current hw is not ready, so using SW pseduo way temproray. + unsigned char hwkey_master[32] = { 0xAB, 0x12, 0x45, 0x67, 0x3F, 0x80, 0x98, 0x35, - 0x06, 0x4F, 0x33, 0x39, 0x72, 0x1C, 0xDF, 0x23, - 0xAB, 0x12, 0x45, 0x67, 0x3F, 0x80, 0x98, 0x35, - 0x06, 0x4F, 0x33, 0x39, 0x72, 0x1C, 0xDF, 0x23 - }; + 0x06, 0x4F, 0x33, 0x39, 0x72, 0x1C, 0xDF, 0x23, + 0xAB, 0x12, 0x45, 0x67, 0x3F, 0x80, 0x98, 0x35, + 0x06, 0x4F, 0x33, 0x39, 0x72, 0x1C, 0xDF, 0x23 + }; unsigned char hwiv_master[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; unsigned char hwkey_unique[32] = { 0xF0, 0x22, 0x34, 0x67, 0x66, 0x88, 0xAB, 0xCD, - 0x12, 0x67, 0x89, 0x54, 0x32, 0x10, 0xCC, 0xFE, - 0xAB, 0x12, 0x45, 0x67, 0x3F, 0x80, 0x98, 0x35, - 0x06, 0x4F, 0x33, 0x39, 0x72, 0x1C, 0xDF, 0x23 - }; + 0x12, 0x67, 0x89, 0x54, 0x32, 0x10, 0xCC, 0xFE, + 0xAB, 0x12, 0x45, 0x67, 0x3F, 0x80, 0x98, 0x35, + 0x06, 0x4F, 0x33, 0x39, 0x72, 0x1C, 0xDF, 0x23 + }; unsigned char hwiv_unique[16] = { 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88, - 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00 + 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00 }; if (pctx == NULL) @@ -715,8 +713,6 @@ int hwcrypto_se_final(UCI_HANDLE oh, unsigned char *input, oper.src_len = len; oper.dst_addr = (char *)output; oper.dst_len = output_len; - - //oper.final = 1; if (ret = ioctl(hndl, IOCTL_CRYPTO_CRYPT, &oper)) { TA_PRINT("error:ioctl(hndl, 1, &oper) returned %d\n", ret); return UCI_ERROR; @@ -737,9 +733,6 @@ int hwcrypto_se_final(UCI_HANDLE oh, unsigned char *input, } padlen = output[input_len - 1]; - - //PrintBYTE("padding",output,input_len); - //PrintBYTE("input",input,input_len); if (padlen < 1 || padlen > 16) { *output_len = 0; TA_PRINT("padding size{%d} is incorretc ", padlen); diff --git a/ssflib/inc/app_debug.h b/ssflib/inc/app_debug.h index f363ba3..266991c 100644 --- a/ssflib/inc/app_debug.h +++ b/ssflib/inc/app_debug.h @@ -67,7 +67,6 @@ unsigned char one_time_print_buffer_test[10240]; #define TURST_APP_WRN(fmt, ...) if (g_app_svc_dbglvl >= TRUSTAPP_DEBUG_LEVEL_WRN) {APP_SVC_WRN(APP_MODULE_NAME, fmt, ##__VA_ARGS__)} #define TURST_APP_DBG(fmt, ...) if (g_app_svc_dbglvl >= TRUSTAPP_DEBUG_LEVEL_DBG) {APP_SVC_DBG(APP_MODULE_NAME, fmt, ##__VA_ARGS__)} #define TURST_APP_LOG(fmt, ...) if (g_app_svc_dbglvl >= TRUSTAPP_DEBUG_LEVEL_LOG) {APP_SVC_LOG(APP_MODULE_NAME, fmt, ##__VA_ARGS__)} -//#define TURST_APP_LOG(fmt, ...) TURST_APP_LOG_TEST(fmt,##__VA_ARGS__) diff --git a/ssflib/src/app_debug.cpp b/ssflib/src/app_debug.cpp index d169936..525accd 100644 --- a/ssflib/src/app_debug.cpp +++ b/ssflib/src/app_debug.cpp @@ -24,7 +24,6 @@ #include #include -//#define PRINT_LOG_TO_CONSOLE #ifdef PRINT_LOG_TO_CONSOLE #include #define portname "/dev/ttyS0" diff --git a/ssflib/src/ssf_client.cpp b/ssflib/src/ssf_client.cpp index 00b07e4..2c89207 100644 --- a/ssflib/src/ssf_client.cpp +++ b/ssflib/src/ssf_client.cpp @@ -36,7 +36,6 @@ *-----------------------------------------------------------------------------*/ #define SOCKPATH "/tmp/simdaemon" //path to be updated -//#define TEST /*----------------------------------------------------------------------------- * local functions diff --git a/ssflib/src/ssf_crypto.cpp b/ssflib/src/ssf_crypto.cpp index 4020cdf..21ddf54 100644 --- a/ssflib/src/ssf_crypto.cpp +++ b/ssflib/src/ssf_crypto.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "CC_API.h" #include "ssf_crypto_openssl.h" @@ -471,12 +473,6 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int key->rsa_exponent2.buffer, &key->rsa_exponent2.size, key->rsa_coefficient.buffer, &key->rsa_coefficient.size); - /*if(rc == (-ETIMEDOUT)) - { - LOGE(SSF_LIB, "Algorithm - %X : TIMEOUT \n", operation->info.algorithm); - rc = TEE_ERROR_TIMEOUT; - }*/ - memcpy(key->rsa_public.buffer, E, ELen); key->rsa_public.size = ELen; } @@ -2250,35 +2246,20 @@ TEE_Result TEE_AEInit(TEE_OperationHandle operation, void* nonce, size_t nonceLe CRYPTO_PANIC; } // tagLen check + std::array values_GCM = {128, 120, 112, 104, 96}; + std::array values_CCM = {128, 112, 96, 64, 48, 32}; switch (op->info.algorithm) { case TEE_ALG_AES_GCM: { - switch (tagLen) { - case 128: - case 120: - case 112: - case 104: - case 96: - break; - default: - LOGE(SSF_LIB, "Incorrect tag length %u", tagLen); - return TEE_ERROR_NOT_SUPPORTED; - }; - break; + if (std::find(values_GCM.begin(), values_GCM.end(), tagLen) == values_GCM.end()) { + LOGE(SSF_LIB, "Incorrect tag length %u", tagLen); + return TEE_ERROR_NOT_SUPPORTED; + } } case TEE_ALG_AES_CCM: { - switch (tagLen) { - case 128: - case 112: - case 96: - case 64: - case 48: - case 32: - break; - default: - LOGE(SSF_LIB, "Incorrect tag length %u", tagLen); - return TEE_ERROR_NOT_SUPPORTED; - }; - break; + if (std::find(values_CCM.begin(), values_CCM.end(), tagLen) == values_CCM.end()) { + LOGE(SSF_LIB, "Incorrect tag length %u", tagLen); + return TEE_ERROR_NOT_SUPPORTED; + } } default: { LOGE(SSF_LIB, "Incorrect algorithm %x", op->info.algorithm); diff --git a/ssflib/src/ssf_storage.cpp b/ssflib/src/ssf_storage.cpp index 1b71c8e..1c92a21 100644 --- a/ssflib/src/ssf_storage.cpp +++ b/ssflib/src/ssf_storage.cpp @@ -151,67 +151,52 @@ TEE_Result allocate_transient_object(TransientObject* tr, uint32_t objectType, //tr->attr.buf_len = (maxObjectSize + 7)>>3; break; case TEE_TYPE_DES: - //if (maxObjectSize != 64) { - // return TEE_ERROR_NOT_SUPPORTED; - //} - //tr->attr.buf_len = (maxObjectSize + 7)>>3; break; case TEE_TYPE_DES3: if (maxObjectSize != 128 && maxObjectSize != 192) return TEE_ERROR_NOT_SUPPORTED; - //tr->attr.buf_len = (maxObjectSize + 7)>>3; break; case TEE_TYPE_HMAC_MD5: if (maxObjectSize < 64 || maxObjectSize > 512 || maxObjectSize % 8) return TEE_ERROR_NOT_SUPPORTED; - //tr->attr.buf_len = (maxObjectSize + 7)>>3; break; case TEE_TYPE_HMAC_SHA1: if (maxObjectSize < 80 || maxObjectSize > 512 || maxObjectSize % 8) return TEE_ERROR_NOT_SUPPORTED; - //tr->attr.buf_len = (maxObjectSize + 7)>>3; break; case TEE_TYPE_HMAC_SHA224: if (maxObjectSize < 112 || maxObjectSize > 512 || maxObjectSize % 8) return TEE_ERROR_NOT_SUPPORTED; - //tr->attr.buf_len = (maxObjectSize + 7)>>3; break; case TEE_TYPE_HMAC_SHA256: if (maxObjectSize < 192 || maxObjectSize > 1024 || maxObjectSize % 8) return TEE_ERROR_NOT_SUPPORTED; - //tr->attr.buf_len = (maxObjectSize + 7)>>3; break; case TEE_TYPE_HMAC_SHA384: if (maxObjectSize < 256 || maxObjectSize > 1024 || maxObjectSize % 8) return TEE_ERROR_NOT_SUPPORTED; - //tr->attr.buf_len = (maxObjectSize + 7)>>3; break; case TEE_TYPE_HMAC_SHA512: if (maxObjectSize < 256 || maxObjectSize > 1024 || maxObjectSize % 8) return TEE_ERROR_NOT_SUPPORTED; - //tr->attr.buf_len = (maxObjectSize + 7)>>3; break; case TEE_TYPE_RSA_PUBLIC_KEY: case TEE_TYPE_RSA_KEYPAIR: if (maxObjectSize < 256 || maxObjectSize > 4096 || maxObjectSize % 64) return TEE_ERROR_NOT_SUPPORTED; - //tr->attr.buf_len = sizeof(rsa_context); break; case TEE_TYPE_DSA_PUBLIC_KEY: case TEE_TYPE_DSA_KEYPAIR: if (maxObjectSize < 512 || maxObjectSize > 1024 || maxObjectSize % 64) return TEE_ERROR_NOT_SUPPORTED; - //tr->attr.buf_len = sizeof(dsa_context); break; case TEE_TYPE_DH_KEYPAIR: if (maxObjectSize < 256 || maxObjectSize > 2048) return TEE_ERROR_NOT_SUPPORTED; - //tr->attr.buf_len = sizeof(dh_context); break; case TEE_TYPE_GENERIC_SECRET: if (maxObjectSize > 4096 || maxObjectSize % 8) return TEE_ERROR_NOT_SUPPORTED; - //tr->attr.buf_len = (maxObjectSize + 7)>>3; break; default: return TEE_ERROR_NOT_SUPPORTED; @@ -221,9 +206,6 @@ TEE_Result allocate_transient_object(TransientObject* tr, uint32_t objectType, tr->info.objectType = objectType; tr->info.objectSize = 0; tr->info.maxObjectSize = maxObjectSize; - //tr->info.dataSize = 0; - //tr->info.dataPosition = 0; - //tr->info.handleFlags = 0; tr->info.objectUsage = 0xffffffff; return TEE_SUCCESS; } @@ -1245,7 +1227,6 @@ void add_to_po_list(persistent_object* po) { g_po_list.next = &po->po_list; } MSG("=====PO %s added=====", po->po_file.file_name); - //debug_list(); } void rem_from_po_list(persistent_object* po) { @@ -1253,7 +1234,6 @@ void rem_from_po_list(persistent_object* po) { return; } MSG("=====To remove PO %s=====", po->po_file.file_name); - //debug_list(); if (po->po_list.prev) { po->po_list.prev->next = po->po_list.next; } @@ -1261,7 +1241,6 @@ void rem_from_po_list(persistent_object* po) { po->po_list.next->prev = po->po_list.prev; } MSG("======PO removed====="); - //debug_list(); } po_user* get_po_user_from_po_list(uint32_t storageID, const void* objectID,