Fix C++ style warnings (CRC) 09/157309/4
authorLeszek Zygo <l.zygo@samsung.com>
Mon, 23 Oct 2017 15:55:49 +0000 (17:55 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Tue, 24 Oct 2017 09:12:18 +0000 (09:12 +0000)
Change-Id: Ief75cb7fb549697ddab8cec0c5ebd41c9c1149d8
Signed-off-by: Leszek Zygo <l.zygo@samsung.com>
68 files changed:
TEEStub/PropertyAccess/PropertyApi.cpp
TEEStub/PropertyAccess/PropertyUtility.cpp
TEEStub/PropertyAccess/TAProperty.cpp
TEEStub/PropertyAccess/TEEProperty.cpp
TEEStub/TACommands/MakeCommand.cpp
TEEStub/TACommands/SharedMemoryMap.cpp
TEEStub/TEEStubServer/ConnectionSession.cpp
TEEStub/TaskStrategy/TaskQueuedStrategy.cpp
TEEStub/teestubmain.cpp
include/include/tee_internal_api.h
include/include/tee_sim_command.h
include/include/teestub_command_data.h
log/log.h
osal/Osal.h
simulatordaemon/inc/ClientCommands/CommandBase.h
simulatordaemon/inc/ClientCommands/CommandInvokeCommand.h
simulatordaemon/inc/ClientCommands/CommandInvokeTACommand.h
simulatordaemon/inc/ClientCommands/CommandPanic.h
simulatordaemon/inc/ClientCommands/CommandRegSharedMem.h
simulatordaemon/inc/ClientCommands/CommandRelSharedMem.h
simulatordaemon/inc/ClientCommands/CommandReqCancellation.h
simulatordaemon/inc/ResponseCommands/ResCommandInvokeCommand.h
simulatordaemon/inc/ResponseCommands/ResCommandReqCancellation.h
simulatordaemon/src/ClientCommands/CommandCloseSession.cpp
simulatordaemon/src/ClientCommands/CommandCloseTASession.cpp
simulatordaemon/src/ClientCommands/CommandInvokeCommand.cpp
simulatordaemon/src/ClientCommands/CommandInvokeTACommand.cpp
simulatordaemon/src/ClientCommands/CommandOpenTASession.cpp
simulatordaemon/src/ClientCommands/MakeCommand.cpp
simulatordaemon/src/ConnectionSession.cpp
simulatordaemon/src/ResponseCommands/ResCommandCloseSession.cpp
simulatordaemon/src/ResponseCommands/ResCommandInvokeCommand.cpp
simulatordaemon/src/ResponseCommands/ResMakeCommand.cpp
simulatordaemon/src/SecurityContext.cpp
simulatordaemon/src/Session.cpp
simulatordaemon/src/TABinaryManager/TABinaryManager.h
simulatordaemon/src/TABinaryManager/TAManifest.cpp
simulatordaemon/src/TABinaryManager/TAManifest.h
simulatordaemon/src/TABinaryManager/TAUnpack.cpp
simulatordaemon/src/TABinaryManager/TestMain.cpp
simulatordaemon/src/TAFactory.cpp
simulatordaemon/src/TAInstance.cpp
simulatordaemon/src/TEEContext.cpp
ssflib/dep/cryptocore/include/CC_API.h
ssflib/dep/cryptocore/include/CC_Context.h
ssflib/dep/cryptocore/include/base/cc_bignum.h
ssflib/dep/cryptocore/include/base/cc_des.h
ssflib/dep/cryptocore/include/base/cc_ecc.h
ssflib/dep/cryptocore/include/base/cc_fast_math.h
ssflib/dep/cryptocore/include/base/cc_md5.h
ssflib/dep/cryptocore/include/base/cc_moo.h
ssflib/dep/cryptocore/include/drm_macro.h
ssflib/dep/swdss/include/file_op.h
ssflib/dep/swdss/include/secure_file.h
ssflib/dep/swdss/include/ss_types.h
ssflib/dep/swdss/source/file_op.cpp
ssflib/dep/swdss/source/ss_crypto.cpp
ssflib/dep/swdss/source/ss_temp_store.cpp
ssflib/dep/time/ssf_time.cpp
ssflib/dep/uci/include/uci_type.h
ssflib/inc/app_debug.h
ssflib/inc/permission.h
ssflib/src/app_debug.cpp
ssflib/src/ssf_arithmetic.cpp
ssflib/src/ssf_crypto.cpp
ssflib/src/ssf_lib.cpp
ssflib/src/ssf_storage.cpp
ssflib/src/ssf_taentrypoint.cpp

index 93c67ba..60f1199 100644 (file)
@@ -142,7 +142,8 @@ TEE_Result TEE_GetPropertyAsString(TEE_PropSetHandle propsetOrEnumerator,
                if (valueBuffer && pv.value.size() < *valueBufferLen)\r
                        strncpy(valueBuffer, pv.value.c_str(), *valueBufferLen);\r
                else returnValue = TEE_ERROR_SHORT_BUFFER;\r
-       } else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
+       }
+       else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
 \r
 // Above is optimized version of below\r
 #if 0\r
@@ -154,16 +155,13 @@ TEE_Result TEE_GetPropertyAsString(TEE_PropSetHandle propsetOrEnumerator,
                strcpy(valueBuffer, pv.value.c_str());\r
                else\r
                returnValue = TEE_ERROR_SHORT_BUFFER;\r
-       }\r
-       else if (NULL == name && targetProperty && targetProperty->getPropertyValue(pv))\r
-       {\r
+       } else if (NULL == name && targetProperty && targetProperty->getPropertyValue(pv)) {\r
                if (pv.value.size() < *valueBufferLen)\r
                strcpy(valueBuffer, pv.value.c_str());\r
                else\r
                returnValue = TEE_ERROR_SHORT_BUFFER;\r
        }\r
-       else\r
-       returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
+       else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
 #endif\r
        return returnValue;\r
 }\r
@@ -184,19 +182,17 @@ TEE_Result TEE_GetPropertyAsBool(TEE_PropSetHandle propsetOrEnumerator,
            && ((NULL != name && targetProperty->getPropertyByName(queryProp, pv))\r
                || (NULL == name && targetProperty->getPropertyValue(pv)))) {\r
                returnValue = PropertyUtility::convertToBool(pv, *value);\r
-       } else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
+       }\r
+       else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
 // Above is optimized version of below\r
 #if 0\r
        if (NULL != name && targetProperty && targetProperty->getPropertyByName(queryProp, pv))\r
        {\r
                returnValue = PropertyUtility::convertToBool(pv, *value);\r
-       }\r
-       else if (NULL == name && targetProperty && targetProperty->getPropertyValue(pv))\r
-       {\r
+       } else if (NULL == name && targetProperty && targetProperty->getPropertyValue(pv)) {\r
                returnValue = PropertyUtility::convertToBool(pv, *value);\r
        }\r
-       else\r
-       returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
+       else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
 #endif\r
        return returnValue;\r
 }\r
@@ -207,7 +203,7 @@ TEE_Result TEE_GetPropertyAsU32(TEE_PropSetHandle propsetOrEnumerator,
        Property* targetProperty = NULL;\r
        PropertyValue pv;\r
        string queryProp = "";\r
-       if (NULL != name) queryProp = getQueryProp(propsetOrEnumerator,name);\r
+       if (NULL != name) queryProp = getQueryProp(propsetOrEnumerator, name);\r
        // 1. Select the enumerator object based on propset or consider given enumerator\r
        // if any\r
        targetProperty = _GetTargetProperty(propsetOrEnumerator);\r
@@ -217,7 +213,8 @@ TEE_Result TEE_GetPropertyAsU32(TEE_PropSetHandle propsetOrEnumerator,
            && ((NULL != name && targetProperty->getPropertyByName(queryProp, pv))\r
                || (NULL == name && targetProperty->getPropertyValue(pv)))) {\r
                returnValue = PropertyUtility::convertToU32(pv, *value);\r
-       } else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
+       }\r
+       else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
        return returnValue;\r
 }\r
 \r
@@ -227,7 +224,7 @@ TEE_Result TEE_GetPropertyAsBinaryBlock(TEE_PropSetHandle propsetOrEnumerator,
        Property* targetProperty = NULL;\r
        PropertyValue pv;\r
        string queryProp = "";\r
-       if (NULL != name) queryProp = getQueryProp(propsetOrEnumerator,name);\r
+       if (NULL != name) queryProp = getQueryProp(propsetOrEnumerator, name);\r
        // Select the enumerator object based on propset or consider given enumerator\r
        // if any\r
        targetProperty = _GetTargetProperty(propsetOrEnumerator);\r
@@ -241,8 +238,10 @@ TEE_Result TEE_GetPropertyAsBinaryBlock(TEE_PropSetHandle propsetOrEnumerator,
                if (valueBuffer && conversionStatus\r
                    && binaryBlockOut.size() < *valueBufferLen) {\r
                        strncpy((char*)valueBuffer, binaryBlockOut.c_str(), *valueBufferLen);\r
-               } else returnValue = TEE_ERROR_SHORT_BUFFER;\r
-       } else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
+               }\r
+               else returnValue = TEE_ERROR_SHORT_BUFFER;\r
+       }\r
+       else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
        return returnValue;\r
 }\r
 \r
@@ -254,7 +253,7 @@ TEE_Result TEE_GetPropertyAsUUID(TEE_PropSetHandle propsetOrEnumerator,
        Property* targetProperty = NULL;\r
        PropertyValue pv;\r
        string queryProp = "";\r
-       if (NULL != name) queryProp = getQueryProp(propsetOrEnumerator,name);\r
+       if (NULL != name) queryProp = getQueryProp(propsetOrEnumerator, name);\r
        // 1. Select the enumerator object based on propset or consider given enumerator\r
        // if any\r
        targetProperty = _GetTargetProperty(propsetOrEnumerator);\r
@@ -264,7 +263,8 @@ TEE_Result TEE_GetPropertyAsUUID(TEE_PropSetHandle propsetOrEnumerator,
            && ((NULL != name && targetProperty->getPropertyByName(queryProp, pv))\r
                || (NULL == name && targetProperty->getPropertyValue(pv)))) {\r
                returnValue = PropertyUtility::convertToUUID(pv, *value);\r
-       } else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
+       }\r
+       else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
        return returnValue;\r
 }\r
 \r
@@ -276,7 +276,7 @@ TEE_Result TEE_GetPropertyAsIdentity(TEE_PropSetHandle propsetOrEnumerator,
        Property* targetProperty = NULL;\r
        PropertyValue pv;\r
        string queryProp = "";\r
-       if (NULL != name) queryProp = getQueryProp(propsetOrEnumerator,name);\r
+       if (NULL != name) queryProp = getQueryProp(propsetOrEnumerator, name);\r
        // 1. Select the enumerator object based on propset or consider given enumerator\r
        // if any\r
        targetProperty = _GetTargetProperty(propsetOrEnumerator);\r
@@ -286,7 +286,8 @@ TEE_Result TEE_GetPropertyAsIdentity(TEE_PropSetHandle propsetOrEnumerator,
            && ((NULL != name && targetProperty->getPropertyByName(queryProp, pv))\r
                || (NULL == name && targetProperty->getPropertyValue(pv)))) {\r
                returnValue = PropertyUtility::convertToIdentity(pv, *value);\r
-       } else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
+       }\r
+       else returnValue = TEE_ERROR_ITEM_NOT_FOUND;\r
        return returnValue;\r
 }\r
 \r
@@ -311,8 +312,7 @@ void TEE_FreePropertyEnumerator(TEE_PropSetHandle enumerator) {
                        propertyEnumHandleSet.erase(it);\r
                        delete enumeratorHandle->property;\r
                        delete enumeratorHandle;\r
-               }\r
-               else {\r
+               } else {\r
                        TEE_Panic(0);\r
                }\r
        }\r
@@ -382,7 +382,8 @@ TEE_Result TEE_GetPropertyName(TEE_PropSetHandle enumerator, void* nameBuffer,
                }\r
                // item not found or enumerator end has reached\r
                else return TEE_ERROR_ITEM_NOT_FOUND;\r
-       } else return TEE_ERROR_ITEM_NOT_FOUND;\r
+       }\r
+       else return TEE_ERROR_ITEM_NOT_FOUND;\r
        return TEE_SUCCESS;\r
 }\r
 \r
@@ -392,7 +393,8 @@ TEE_Result TEE_GetNextProperty(TEE_PropSetHandle enumerator) {
        if (enumeratorHandle && enumeratorHandle->property\r
            && enumeratorHandle->property->getNextProperty()) {\r
                return TEE_SUCCESS;\r
-       } else return TEE_ERROR_ITEM_NOT_FOUND;\r
+       }\r
+       else return TEE_ERROR_ITEM_NOT_FOUND;\r
 }\r
 \r
 uintptr_t _GetTargetPropsetType(TEE_PropSetHandle propsetOrEnumerator) {\r
index 0b776c5..930f5d3 100644 (file)
@@ -90,13 +90,9 @@ TEE_Result PropertyUtility::convertToU32(const PropertyValue& in,
        if (in.type == "integer") {\r
                sstr << in.value;\r
                sstr >> out;\r
-       }\r
-       else if (in.type == "boolean")\r
-       {\r
+       } else if (in.type == "boolean") {\r
                out = (in.value == "true" ? 1 : 0);\r
-       }\r
-       else\r
-       { // As per spec:A pointer to the variable that will contain the value of the property\r
+       } else {// As per spec:A pointer to the variable that will contain the value of the property\r
                 // on success, or zero on error\r
                 // Hence default value is "false"\r
                out = 0;\r
@@ -149,7 +145,8 @@ TEE_Result PropertyUtility::convertToUUID(const PropertyValue& in,
                uuid.clockSeqAndNode[6] = temp[1];\r
                uuid.clockSeqAndNode[7] = temp[0];\r
                out = uuid;\r
-       } else returnValue = TEE_ERROR_BAD_FORMAT;\r
+       }\r
+       else returnValue = TEE_ERROR_BAD_FORMAT;\r
        return returnValue;\r
 }\r
 \r
@@ -165,7 +162,8 @@ TEE_Result PropertyUtility::convertToIdentity(const PropertyValue& in,
     TEE_Identity& out) {\r
        if ("identity" != in.type)\r
                return TEE_ERROR_BAD_FORMAT;\r
-       else {\r
+       else\r
+       {\r
                out.login = atoi(in.value.c_str());\r
                // Set to Nil UUID as per [RFC 4122].\r
                out.uuid.timeLow = 0;\r
index 41a970e..8cefc10 100644 (file)
@@ -80,11 +80,13 @@ bool TAProperty::readPropertyFile() {
                        // TODO: UUID type to be added yet\r
                        if (PropertyUtility::isNumber(newValue.value)) {\r
                                type = "integer";\r
-                       } else if (newValue.value == "true" || newValue.value == "false")\r
+                       } else if (newValue.value == "true" || newValue.value == "false") {\r
                                type = "boolean";\r
-                       else if (typeName == "appID")\r
+                       } else if (typeName == "appID") {\r
                                type = "uuid";\r
-                       else type = "string";\r
+                       } else {\r
+                               type = "string";\r
+                       }\r
 \r
                        //1c. Assign type identified\r
                        newValue.type = type;\r
@@ -199,7 +201,8 @@ bool TAProperty::getPropertyValue(PropertyValue &pv) {
        if (currentItr != propertiesMap.end()) {\r
                pv = currentItr->second;\r
                return true;\r
-       } else return false;\r
+       }\r
+       else return false;\r
 }\r
 \r
 /**\r
@@ -220,6 +223,7 @@ bool TAProperty::getPropertyByName(const string &propName,
        map<string, PropertyValue>::iterator it = propertiesMap.find(propName);\r
        if (it != propertiesMap.end()) {\r
                value = it->second;\r
-       } else returnval = false;\r
+       }\r
+       else returnval = false;\r
        return returnval;\r
 }\r
index 0ce5dc7..de47826 100644 (file)
@@ -50,7 +50,6 @@ TEEProperty::TEEProperty() {
  * @return true if successfully read else false\r
  */\r
 bool TEEProperty::readPropertyFile(string filePath) {\r
-\r
        // Open file\r
        std::ifstream xmlfile(filePath.c_str());\r
        if (xmlfile.fail()) return false;\r
@@ -138,7 +137,9 @@ bool TEEProperty::getPropertyValue(PropertyValue &pv) {
        if (currentItr != propertiesMap.end()) {\r
                pv = currentItr->second;\r
                return true;\r
-       } else return false;\r
+       } else {\r
+               return false;\r
+       }\r
 }\r
 \r
 /**\r
@@ -159,6 +160,8 @@ bool TEEProperty::getPropertyByName(const string &propName,
        map<string, PropertyValue>::iterator it = propertiesMap.find(propName);\r
        if (it != propertiesMap.end()) {\r
                value = it->second;\r
-       } else returnval = false;\r
+       } else {\r
+               returnval = false;\r
+       }\r
        return returnval;\r
 }\r
index 8820936..e36348b 100644 (file)
@@ -35,7 +35,6 @@
  * @param data pointer to structure defining the command in SIM_COMMAND
  */
 CommandBasePtr MakeCommand::getCommand(SIM_COMMAND simcommand, void* simdata) {
-
        CommandBasePtr command;
        switch (simcommand) {
                case CREATE: {
@@ -83,7 +82,6 @@ CommandBasePtr MakeCommand::getCommand(SIM_COMMAND simcommand, void* simdata) {
 }
 
 MakeCommand::~MakeCommand() {
-
 }
 
 /**
@@ -95,7 +93,6 @@ MakeCommand::~MakeCommand() {
  *
  */
 int MakeCommand::getCommandPayloadSize(SIM_COMMAND command) {
-
        int size = -1;
        switch (command) {
                case CREATE:
index 0c299b3..44e5ac4 100644 (file)
@@ -180,8 +180,7 @@ bool SharedMemoryMap::deleteOnceSharedMemory(void* buffer) {
        for (map<uint32_t, registerItem>::iterator it = shmMap.begin(); it != shmMap.end();
            it++) {
                registerItem item = it->second;
-               if(buffer == item.pBuffer) {
-
+               if (buffer == item.pBuffer) {
                        if (!item.internal) {
                                return false;
                        }
@@ -230,9 +229,7 @@ bool SharedMemoryMap::allocateSharedMemory(Operation &op) {
                        {
                                op.params[i].memref.buffer =
                                        (void*)((char*)item.pBuffer + offset);
-                       }
-                       else
-                       {
+                       } else {
                                std::string shm_name(SHM_NAME_PREFIX + std::to_string(op.shmID[i]));
 
                                int fd_shm = shm_open(shm_name.c_str(), O_RDWR, 0);
index c970b8c..821898f 100644 (file)
@@ -78,7 +78,7 @@ void ConnectionSession::handleRead(const boost::system::error_code& error,
                        case READ_PAYLOAD: {
                                // Identify command
                                command = (SIM_COMMAND)clientData.at(0);
-                               LOGD(TEE_STUB, "Command received: %d", (int )command);
+                               LOGD(TEE_STUB, "Command received: %d", (int)command);
 
                                // Calculate pending numbers of bytes pending to be read only for commands
                                // OPENSESSION, INVOKECOMMAND, CLOSESESSION
@@ -92,8 +92,7 @@ void ConnectionSession::handleRead(const boost::system::error_code& error,
                                            boost::bind(&ConnectionSession::handleRead, shared_from_this(),
                                                boost::asio::placeholders::error,
                                                boost::asio::placeholders::bytes_transferred));
-                               }
-                               else if (-1 == payload_size) {
+                               } else if (-1 == payload_size) {
                                        // else case is invalid command
                                        // TODO: Identify the correct behaviour; what to do when invalid command is received?
                                        LOGE(TEE_STUB, "Invalid command received!");
@@ -138,9 +137,8 @@ void ConnectionSession::handleRead(const boost::system::error_code& error,
                                break;
                        } //case
                } //switch
-       }
+       } else {
        // On error
-       else {
                LOGE(TEE_STUB, "error code %s", error.category().name());
                if (boost::asio::error::eof == error.value()) {
                        LOGE(TEE_STUB, "Simulator daemon is down! Exiting this TA instance.");
index b878ce0..11d23bd 100644 (file)
@@ -62,9 +62,8 @@ void TaskQueuedStrategy::handleCommand(CommandBasePtr command) {
                        ss.addTask(command);
                        sessionTaskMap[command->sessionID] = ss;
                        LOGD(TEE_STUB, "New Session ID");
-               }
+               } else {
                // Else, the session ID exists in map, so append to list in session
-               else {
                        LOGD(TEE_STUB, "Session ID Exists, adding tasks");
                        sessionTaskMap[command->sessionID].addTask(command);
                }
@@ -92,12 +91,11 @@ void TaskQueuedStrategy::executeCancellation(CommandBasePtr cancelCommand) {
        if (currentCommand->getCommandUID() == cancelCommand->getCommandUID()) {
                LOGD(TEE_STUB, "Cancel command matched with current task");
                sharedData.thisTaskCancel = true;
-       }
+       } else {
        // If the task to be cancelled is not the current task
        // then the task must be in execution queue, yet to be executed.
        // Just push the request to cancellation vector using
        // cancel commands execute
-       else {
                LOGD(TEE_STUB, "Cancel command queued");
                cancelCommand->execute();
        }
index 0ffdb15..2f1f604 100644 (file)
@@ -74,7 +74,6 @@ void StopServer() {
  * @return
  */
 int main(int argc, char* argv[]) {
-
        if (argc < 2) {
                LOGE(TEE_STUB, "Invalid arguments to TEE Stub");
        }
index b988af0..9456e2e 100644 (file)
@@ -94,7 +94,6 @@ typedef enum {
        TEE_ERROR_CERT_VERIFICATION = 0xFFFF6003,
 
        TEE_RESULT_NOT_READY = 0xFFFF0FFF
-
 } TEE_Error_Codes;
 
 #define TEE_HANDLE_NULL 0
@@ -122,7 +121,7 @@ typedef union {
        } value;
 } TEE_Param;
 
-#define TEE_PARAM_TYPES(t0,t1,t2,t3) \
+#define TEE_PARAM_TYPES(t0, t1, t2, t3) \
                ((t0) | ((t1) << 8) | ((t2) << 16) | ((t3) << 24))
 
 #define TEE_PARAM_TYPE_GET(t, i) (((t) >> (i*8)) & 0x7F)
index d49d1f9..dcb4c24 100644 (file)
@@ -76,7 +76,6 @@ typedef struct {
        uint32_t operationID;
        TEE_Result returnValue;
        uint32_t returnOrigin;
-
 } RequestTACancelData;
 
 #endif /* __TEE_SIM_COMMAND_H__ */
index 12f8b0d..5d361cb 100644 (file)
@@ -55,7 +55,6 @@ typedef struct {
 
 typedef struct {
        uint32_t session;
-
 } IntTACloseSessionData;
 
 typedef struct {
index eea9bd8..11b2fd4 100644 (file)
--- a/log/log.h
+++ b/log/log.h
@@ -104,23 +104,23 @@ typedef enum {
 
 #ifdef _LOGGING
 
-#define _LOG(module_level,debug_level,...) PrintLog(__FUNCTION__,__LINE__,module_level,debug_level,##__VA_ARGS__)
+#define _LOG(module_level, debug_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, debug_level, ##__VA_ARGS__)
 
-#define LOGE(module_level,...) PrintLog(__FUNCTION__,__LINE__,module_level,ERROR_LEVEL_LOG,##__VA_ARGS__)
-#define LOGV(module_level,...) PrintLog(__FUNCTION__,__LINE__,module_level,VERBOSE_LEVEL_LOG,##__VA_ARGS__)
-#define LOGD(module_level,...) PrintLog(__FUNCTION__,__LINE__,module_level,DEBUG_LEVEL_LOG,##__VA_ARGS__)
-#define LOGI(module_level,...) PrintLog(__FUNCTION__,__LINE__,module_level,SECURED_LEVEL_LOG,##__VA_ARGS__)
-#define LOGS(module_level,...) PrintLog(__FUNCTION__,__LINE__,module_level,INFO_LEVEL_LOG,##__VA_ARGS__)
-#define LOGP(module_level,...) PrintLog(__FUNCTION__,__LINE__,module_level,PACKET_LEVEL_LOG,##__VA_ARGS__)
+#define LOGE(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, ERROR_LEVEL_LOG, ##__VA_ARGS__)
+#define LOGV(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, VERBOSE_LEVEL_LOG, ##__VA_ARGS__)
+#define LOGD(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, DEBUG_LEVEL_LOG, ##__VA_ARGS__)
+#define LOGI(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, SECURED_LEVEL_LOG, ##__VA_ARGS__)
+#define LOGS(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, INFO_LEVEL_LOG, ##__VA_ARGS__)
+#define LOGP(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, PACKET_LEVEL_LOG, ##__VA_ARGS__)
 
 #else //ifdef _LOGGING
 
-#define LOGE(module_level,...)
-#define LOGV(module_level,...)
-#define LOGD(module_level,...)
-#define LOGI(module_level,...)
-#define LOGS(module_level,...)
-#define LOGP(module_level,...)
+#define LOGE(module_level, ...)
+#define LOGV(module_level, ...)
+#define LOGD(module_level, ...)
+#define LOGI(module_level, ...)
+#define LOGS(module_level, ...)
+#define LOGP(module_level, ...)
 
 #endif //ifdef _LOGGING
 
index f8fb268..5906d32 100644 (file)
@@ -314,9 +314,9 @@ void OsaIrqResetCount(void);
 #if defined(__KERNEL__)
 void OsaModule_Open(void);
 void OsaModule_Close(void);
-int OsaModule_RegisterDev(const char* devname,int iminor_cnt,struct file_operations *fp_op);
-int OsaModule_UnRegisterDev(unsigned int devId, const char* devname,int iminor_cnt);
-int OsaModule_Remap_page_range(struct vm_area_struct *vma,unsigned int uiaddr);
+int OsaModule_RegisterDev(const char* devname, int iminor_cnt, struct file_operations *fp_op);
+int OsaModule_UnRegisterDev(unsigned int devId, const char* devname, int iminor_cnt);
+int OsaModule_Remap_page_range(struct vm_area_struct *vma, unsigned int uiaddr);
 
 /*added by tukho.kim@samsung.com 080714 */
 /*modified by tukho.kim@samsung.com 090818 */
@@ -344,8 +344,8 @@ int OsaModule_Remap_page_range(struct vm_area_struct *vma,unsigned int uiaddr);
  * OSAL_DCACHE_XXX are not supported. Do not use. */
 static void __attribute__((unused)) staOsaWarnDeprecatedFunction(const char *func, const char *caller)
 {
-       printk (KERN_WARNING "[WARNING]\n");
-       printk (KERN_WARNING "\tcaller=%s. %s is not support. Do not use!\n", caller, func);
+       printk(KERN_WARNING "[WARNING]\n");
+       printk(KERN_WARNING "\tcaller=%s. %s is not support. Do not use!\n", caller, func);
 }
 
 #define OSAL_DCACHE_FLUSH()                            staOsaWarnDeprecatedFunction("OSAL_DCACHE_FLUSH", __FUNCTION__)
index a50a54a..01137d4 100644 (file)
@@ -51,7 +51,6 @@ public:
         */
        CommandBase(TEEContext *TEECtx) :
                        pTEECtx(TEECtx) {
-
        }
        /**
         * Command Base Execute for commands received from TEECLib.
index 6dfcdf7..dd4bf2a 100644 (file)
@@ -39,7 +39,6 @@ public:
        CommandInvokeCommand(InvokeCommandData data, TEEContext *TEECtx);
        void execute();
        virtual ~CommandInvokeCommand();
-
 };
 
 #endif /* COMMANDINVOKECOMMAND_H_ */
index 9c53693..3b296ea 100644 (file)
@@ -39,7 +39,6 @@ public:
        CommandInvokeTACommand(IntTAInvokeCommandData data, TEEContext *TEECtx);
        void execute();
        virtual ~CommandInvokeTACommand();
-
 };
 
 #endif /* COMMANDINVOKETACOMMAND_H_ */
index d25c345..817cc3c 100644 (file)
@@ -39,7 +39,6 @@ public:
        CommandPanic(IntTAPanicData data, TEEContext *TEECtx);
        void execute();
        virtual ~CommandPanic();
-
 };
 
 #endif /* COMMANDPANIC_H_ */
index 93ee941..bf836d3 100644 (file)
@@ -39,7 +39,6 @@ public:
        CommandRegSharedMem(RegSharedMemData data, TEEContext *TEECtx);
        void execute();
        virtual ~CommandRegSharedMem();
-
 };
 
 #endif /* COMMANDREGSHAREDMEM_H_ */
index c9af09d..b79b28f 100644 (file)
@@ -39,7 +39,6 @@ public:
        CommandRelSharedMem(RelSharedMemData data, TEEContext *TEECtx);
        void execute();
        virtual ~CommandRelSharedMem();
-
 };
 
 #endif /* COMMANDRELSHAREDMEM_H_ */
index dffb0d3..c563cd1 100644 (file)
@@ -39,7 +39,6 @@ public:
        CommandReqCancellation(ReqCancellationData data, TEEContext *TEECtx);
        void execute();
        virtual ~CommandReqCancellation();
-
 };
 
 #endif /* COMMANDREQCANCELLATION_H_ */
index 2893b38..2a13c51 100644 (file)
@@ -40,7 +40,6 @@ public:
            std::map<uint32_t, ISession*> *sessionMap);
        void execute();
        virtual ~ResCommandInvokeCommand();
-
 };
 
 #endif /* RESCOMMANDINVOKECOMMAND_H_ */
index a9b85a4..e6f79a0 100644 (file)
@@ -40,7 +40,6 @@ public:
            std::map<uint32_t, ISession*> *sessionMap);
        void execute();
        virtual ~ResCommandReqCancellation();
-
 };
 
 #endif /* RESCOMMANDREQCANCELLATION_H_ */
index 8b2cb5d..5f6f648 100644 (file)
@@ -46,7 +46,6 @@ CommandOpenTASession::CommandOpenTASession(IntTAOpenSessionData data,
  * @param none
  */
 CommandOpenTASession::~CommandOpenTASession() {
-
 }
 
 void CommandOpenTASession::execute() {
index e996d0d..6ea78cb 100644 (file)
@@ -122,7 +122,6 @@ CommandBasePtr MakeCommand::getCommand(TEE_CMD teecmd, void* teedata,
 }
 
 MakeCommand::~MakeCommand() {
-
 }
 
 /**
@@ -134,7 +133,6 @@ MakeCommand::~MakeCommand() {
  *
  */
 uint32_t MakeCommand::getDataSize(TEE_CMD command) {
-
        uint32_t size = -1;
        switch (command) {
                case INITIALIZE_CONTEXT:
index 5b2aa69..31fb181 100644 (file)
@@ -51,7 +51,7 @@ void ConnectionSession::start() {
 #ifdef _CYNARA_INTEGRATION
        /* Check if client has cynara permission */
        const string privilege("http://tizen.org/privilege/tee.client");
-       if (! secContext.clientHasCynaraPermission(privilege)) {
+       if (!secContext.clientHasCynaraPermission(privilege)) {
                LOGE(SIM_DAEMON, "Client has no permission to use TEE");
                return;
        }
@@ -98,7 +98,7 @@ void ConnectionSession::handleRead(const boost::system::error_code& error,
                        case CMD_READ: {
                                // Identify command
                                command = (TEE_CMD)clientData.at(0);
-                               LOGD(SIM_DAEMON, "Command received: %d", (uint32_t )command);
+                               LOGD(SIM_DAEMON, "Command received: %d", (uint32_t)command);
 
                                // Calculate pending numbers of bytes pending to be read only for commands
                                int32_t data_size = MakeCommand::getDataSize(command);
@@ -111,14 +111,11 @@ void ConnectionSession::handleRead(const boost::system::error_code& error,
                                            boost::bind(&ConnectionSession::handleRead, shared_from_this(),
                                                boost::asio::placeholders::error,
                                                boost::asio::placeholders::bytes_transferred));
-                               }
-
-                               else if (-1 == data_size) {
+                               } else if (-1 == data_size) {
                                        // else case is invalid command
                                        // TODO: Identify the correct behavior; what to do when invalid command is received?
                                        LOGE(SIM_DAEMON, "Invalid command received!");
                                } else if (0 == data_size) {
-
                                        // reset state to read new command
                                        currentState = CMD_READ;
                                        // read command and register callback to read data
@@ -187,10 +184,9 @@ void ConnectionSession::handleRead(const boost::system::error_code& error,
  */
 TEEC_Result ConnectionSession::write(TEE_CMD cmd, char* data, size_t size) {
        LOGD(SIM_DAEMON, "Entry");
-
        TEEC_Result result = TEEC_ERROR_COMMUNICATION;
        boost::system::error_code error = boost::asio::error::host_not_found;
-       pthread_mutex_lock (&connLock);
+       pthread_mutex_lock(&connLock);
        // Send command to TEECLib for CA
        boost::asio::write(clientSocket,
            boost::asio::buffer((char*)&cmd, sizeof(char)),
@@ -202,7 +198,8 @@ TEEC_Result ConnectionSession::write(TEE_CMD cmd, char* data, size_t size) {
                    boost::asio::transfer_all(), error);
                if (!error)
                        result = TEEC_SUCCESS;
-               else {
+               else
+               {
                        LOGE(SIM_DAEMON, "Error in writing Data to CA");
                        LOGE(SIM_DAEMON, "Response returned with error code %d", error.value());
                        LOGE(SIM_DAEMON, "Response returned with error code %s",
@@ -225,7 +222,7 @@ SecurityContext ConnectionSession::getSecurityContext(){
 ConnectionSession::~ConnectionSession() {
        LOGD(SIM_DAEMON, "Entry");
        // Destory the lock for write (connLock)
-       pthread_mutex_destroy (&connLock);
+       pthread_mutex_destroy(&connLock);
        // delete Context
        delete TEECtx;
        TEECtx = NULL;
index 0c142ff..896d008 100644 (file)
@@ -78,7 +78,9 @@ void ResCommandCloseSession::execute() {
                                                        LOGE(SIM_DAEMON, "Destroy sendRequestToTA FAILED");
                                                        (session->getTAInstance())->killTA();
                                                }
-                                       } else break;
+                                       } else {
+                                               break;
+                                       }
                                }
                                TAFact->mTAInstanceMap.erase(itTAMap);
                                break;
@@ -118,5 +120,4 @@ void ResCommandCloseSession::execute() {
 }
 
 ResCommandCloseSession::~ResCommandCloseSession() {
-
 }
index 53e61de..f0a7f67 100644 (file)
@@ -74,7 +74,6 @@ ResCommandBasePtr ResMakeCommand::getCommand(SIM_COMMAND tacmd, void* tadata,
 }
 
 ResMakeCommand::~ResMakeCommand() {
-
 }
 
 /**
@@ -86,7 +85,6 @@ ResMakeCommand::~ResMakeCommand() {
  *
  */
 uint32_t ResMakeCommand::getDataSize(SIM_COMMAND command) {
-
        uint32_t size = -1;
        switch (command) {
                case CREATE:
index c7d8946..3cd4e1a 100644 (file)
@@ -55,7 +55,6 @@ pthread_mutex_t cynara_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 
 std::string SecurityContext::getCaFullPathFromPkgId(char* pkgid) {
-
        std::string path;
 
        tzplatform_variable ids[3] = {TZ_USER_APP, TZ_SYS_RW_APP, TZ_SYS_RO_APP};
index 7b6906d..e9b84d3 100644 (file)
@@ -90,7 +90,6 @@ TEEC_Result Session::writeResponse(TEE_CMD command, char* data, size_t size) {
  * @param data OpenSessionData type of data for opening a session
  */
 TEEC_Result Session::createSession(OpenSessionData data) {
-
        uint32_t i, type;
        TEEC_Result result = TEEC_ERROR_GENERIC;
        LOGD(SIM_DAEMON, "Entry");
@@ -288,7 +287,6 @@ void Session::handleCancel(ReqCancellationData data) {
  * Session clean up. Called before Session destructor to clean the session
  */
 TEEC_Result Session::finalize(uint32_t contextID) {
-
        TEEC_Result result = TEEC_ERROR_GENERIC;
        LOGD(SIM_DAEMON, "Entry");
 
@@ -343,7 +341,9 @@ TEEC_Result Session::finalize(uint32_t contextID) {
                                                        LOGE(SIM_DAEMON, "Destroy sendRequestToTA FAILED");
                                                        mTAInstance->killTA();
                                                }
-                                       } else break;
+                                       } else {
+                                               break;
+                                       }
                                }
                                // Erase TA Instance from TA FActory's Instance map
                                TAFact->mTAInstanceMap.erase(itTAMap);
index c1149de..bf7366e 100644 (file)
@@ -58,7 +58,6 @@ typedef struct {
  *  Class definitions
  *-----------------------------------------------------------------------------*/
 class TABinaryManager {
-
 private:
        static TABinaryManager *instance;
        std::string base64_chars;
index dc4fb21..90eb3bb 100644 (file)
@@ -37,11 +37,9 @@ using namespace rapidxml;
  *-----------------------------------------------------------------------------*/
 
 TAManifest::TAManifest() {
-
 }
 
 bool TAManifest::processXML(const string &xmlManifestPath) {
-
        bool ret = false;
        // Open file
        std::ifstream xmlfile(xmlManifestPath.c_str());
@@ -69,7 +67,7 @@ bool TAManifest::processXML(const string &xmlManifestPath) {
                                        .compare("true") == 0 ? true : false;
                                properties.general.multiSession = string(propertiesGeneral->first_attribute("multiSession")->value())
                                        .compare("true") == 0 ? true : false;
-                               properties.general.instanceKeepAlive =string(propertiesGeneral->first_attribute("instanceKeepAlive")->value())
+                               properties.general.instanceKeepAlive = string(propertiesGeneral->first_attribute("instanceKeepAlive")->value())
                                        .compare("true") == 0 ? true : false;
 
                                sstream.clear();
@@ -97,7 +95,6 @@ bool TAManifest::processXML(const string &xmlManifestPath) {
 
                                properties.extension.launchMode = string(propertiesExtension->first_attribute("launchMode")->value());
                        }
-
                }
                // 2. POLICY
                node = doc.first_node("manifest")->first_node("policy");
@@ -131,7 +128,6 @@ bool TAManifest::processXML(const string &xmlManifestPath) {
                                        policy.usesPermission.push_back(string(childnode->first_attribute("name")->value()));
                                }
                        }
-
                }
                // 3. TA ENC
                node = doc.first_node("manifest")->first_node("taEncryption");
@@ -221,10 +217,8 @@ void TAManifest::printProcessedData() const {
        std::cout << "[SIM_DAEMON] information.description: "
            << information.description << endl;
        std::cout << "[SIM_DAEMON] information.terms: " << information.terms << endl;
-
 }
 
 TAManifest::~TAManifest() {
-
 }
 
index b2c5845..045c37a 100644 (file)
@@ -92,7 +92,6 @@ typedef struct {
  *-----------------------------------------------------------------------------*/
 
 class TAManifest {
-
 public:
        StructProperties properties;
        StructPolicy policy;
@@ -104,6 +103,5 @@ public:
        bool processXML(const string &xmlManifest);
        void printProcessedData() const;
        virtual ~TAManifest();
-
 };
 #endif /* TAMANIFEST_H_ */
index f759477..e2aa854 100644 (file)
@@ -44,7 +44,6 @@ TAUnpack *TAUnpack::instance = NULL;
  *  Member functions
  *-----------------------------------------------------------------------------*/
 TAUnpack::TAUnpack() {
-
 }
 
 TAUnpack* TAUnpack::getInstance() {
@@ -134,7 +133,6 @@ int TAUnpack::unpackTA(string path, string uuid) {
 }
 
 void TAUnpack::fixHeaderEndianness(TAPackageHeaderV2* header) {
-
        char* headerptr = (char*)header;
        for (unsigned int i = 0; i < sizeof(TAPackageHeaderV2); i +=
            sizeof(unsigned int)) {
@@ -145,7 +143,6 @@ void TAUnpack::fixHeaderEndianness(TAPackageHeaderV2* header) {
                headerptr[i + 3] = temp1;
                headerptr[i + 2] = temp2;
        }
-
 }
 
 /**
index 2d9e1dc..f66443d 100644 (file)
@@ -63,7 +63,6 @@ int test_main() {
                                }
                                        // Execute image
                                case 3: {
-
                                        break;
                                }
                                        // Test TA Binary Manager
@@ -84,7 +83,6 @@ int test_main() {
 
                                        break;
                                }
-
                        }
                }
        } catch (std::exception& e) {
index cc6b3b2..f55e11d 100644 (file)
@@ -59,7 +59,6 @@ TAFactory::TAFactory() {
  * instance and return the instance else return the already created instance.
  */
 TAFactory* TAFactory::getInstance() {
-
        LOGD(SIM_DAEMON, "Entry");
        pthread_mutex_lock(&instLock);
 
@@ -79,7 +78,6 @@ TAFactory* TAFactory::getInstance() {
  * with it
  */
 TAInstancePtr TAFactory::getTAInstance(TEEC_UUID uuid, ISession* session) {
-
        TAInstancePtr TAInst;
        bool result;
        LOGD(SIM_DAEMON, "Entry");
@@ -91,8 +89,8 @@ TAInstancePtr TAFactory::getTAInstance(TEEC_UUID uuid, ISession* session) {
 
        // Change to upper char. TA list has upper char.
        locale loc;
-       for (size_t i=0; i<TAUUID.length(); ++i)
-               TAUUID[i] = toupper(TAUUID[i],loc);
+       for (size_t i = 0; i < TAUUID.length(); ++i)
+               TAUUID[i] = toupper(TAUUID[i], loc);
 
 
        if ((!checkIfTARunning(TAUUID))
@@ -158,7 +156,6 @@ TAInstancePtr TAFactory::getTAInstance(TEEC_UUID uuid, ISession* session) {
  * @param TAUUID TA UUID in string form
  */
 bool TAFactory::checkIfTARunning(string TAUUID) {
-
        LOGD(SIM_DAEMON, "Entry");
        bool result = false;
 
@@ -177,7 +174,6 @@ bool TAFactory::checkIfTARunning(string TAUUID) {
  */
 TAInstancePtr TAFactory::createUninitalizedTAInstance(string TAUUID,
                ISession* session) {
-
        LOGD(SIM_DAEMON, "Entry");
 
        // Initialize PID to -1
@@ -291,7 +287,6 @@ TAInstancePtr TAFactory::createUninitalizedTAInstance(string TAUUID,
  * @param pid pointer to the PID of the launched TA
  */
 void* TAFactory::waitForChild(void *pid) {
-
        pid_t PID = *(pid_t*)pid;
        int32_t childStatus;
 
@@ -311,7 +306,6 @@ void* TAFactory::waitForChild(void *pid) {
  * @param pid pointer to the PID of the exited TA
  */
 void TAFactory::cleanupTAInstance(pid_t PID) {
-
        LOGD(SIM_DAEMON, "Entry");
        TAInstancePtr Inst;
 
index 7a6f443..be1f6a3 100644 (file)
@@ -35,7 +35,7 @@
  * @param client_io_service IO service to handle the connection with TA
  */
 TAInstance::TAInstance(uint32_t pid, bool alive, bool debug, uint32_t InstID, boost::asio::io_service& client_io_service) :
-mTAConnectionSocket(client_io_service),readData() {
+mTAConnectionSocket(client_io_service), readData() {
        LOGD(SIM_DAEMON, "Entry");
 
        // Initialize the lock for Session map (mSessionMap)
@@ -174,7 +174,6 @@ void TAInstance::cleanup() {
  * @param str Socket name
  */
 TEEC_Result TAInstance::connecttoTA(std::stringstream& str) {
-
        unsigned long int retry_count = 0;
        try {
                boost::system::error_code error = boost::asio::error::host_not_found;
@@ -221,7 +220,7 @@ TEEC_Result TAInstance::sendRequestToTA(SIM_COMMAND cmd, void* data,
        TEEC_Result result = TEEC_ERROR_TARGET_DEAD;
        boost::system::error_code error = boost::asio::error::host_not_found;
 
-       pthread_mutex_lock (&sendLock);
+       pthread_mutex_lock(&sendLock);
        // Send command to TEEStub for TA
        boost::asio::write(mTAConnectionSocket,
            boost::asio::buffer((char*)&cmd, sizeof(char)), error);
@@ -231,7 +230,8 @@ TEEC_Result TAInstance::sendRequestToTA(SIM_COMMAND cmd, void* data,
                    boost::asio::buffer((char*)data, size), error);
                if (!error)
                        result = TEEC_SUCCESS;
-               else {
+               else
+               {
                        LOGE(SIM_DAEMON, "Error in writing Data to TA");
                        LOGE(SIM_DAEMON, "Response returned with error code %d", error.value());
                        LOGE(SIM_DAEMON, "Response returned with error code %s",
@@ -251,7 +251,6 @@ TEEC_Result TAInstance::sendRequestToTA(SIM_COMMAND cmd, void* data,
  * Register an asynchronous callback to continuously receive data from TA
  */
 void TAInstance::receiveResponseFromTA() {
-
        currentState = CMD_READ;
        /* Register an asynchronous callback 'handleRead' to continuously receive
         * data from TA */
@@ -285,7 +284,7 @@ void TAInstance::handleRead(const boost::system::error_code& error,
                        case CMD_READ: {
                                // Identify command
                                command = (SIM_COMMAND)readData.at(0);
-                               LOGD(SIM_DAEMON, "Command received: %d", (uint32_t )command);
+                               LOGD(SIM_DAEMON, "Command received: %d", (uint32_t)command);
 
                                /* Calculate pending numbers of bytes pending to be read only for
                                 * commands
@@ -301,8 +300,7 @@ void TAInstance::handleRead(const boost::system::error_code& error,
                                            boost::bind(&TAInstance::handleRead, shared_from_this(),
                                                boost::asio::placeholders::error,
                                                boost::asio::placeholders::bytes_transferred));
-                               }
-                               else if (-1 == data_size) {
+                               } else if (-1 == data_size) {
                                        // else case is invalid command
                                        /* TODO: Identify the correct behavior;
                                         * what to do when invalid command is received?
@@ -361,7 +359,6 @@ void TAInstance::handleRead(const boost::system::error_code& error,
  * @param timeout Timeout value to be set for the socket receive
  */
 int32_t TAInstance::setSocketOpt(struct timeval timeout) {
-
        int32_t result = 0;
        if (isDebug == false) {
                LOGD(SIM_DAEMON, "Entry");
@@ -379,7 +376,6 @@ int32_t TAInstance::setSocketOpt(struct timeval timeout) {
  * Function call to receive create command response from TA instance
  */
 TEEC_Result TAInstance::receiveCreateResponse() {
-
        TEEC_Result result = TEEC_ERROR_COMMUNICATION;
        boost::system::error_code ec = boost::asio::error::host_not_found;
        struct timeval timeout;
@@ -402,8 +398,9 @@ TEEC_Result TAInstance::receiveCreateResponse() {
                                result = TEEC_SUCCESS;
                        else
                        LOGE(SIM_DAEMON, "read data FAILED");
-               } else
-               LOGE(SIM_DAEMON, "read command FAILED");
+               } else {
+                       LOGE(SIM_DAEMON, "read command FAILED");
+               }
        } else {
                LOGE(SIM_DAEMON, "Setting timeout failed");
                return result;
@@ -440,9 +437,9 @@ TAInstance::~TAInstance() {
        // Close connection with TA
        closeConnectionToTA();
        // Destroy the lock created for Session map (mSessionMap)
-       pthread_rwlock_destroy (&mSessionMapLock);
+       pthread_rwlock_destroy(&mSessionMapLock);
        // Destroy the lock created for Command map (mCommandMap)
-       pthread_rwlock_destroy (&mCommandMapLock);
+       pthread_rwlock_destroy(&mCommandMapLock);
        // Destory the lock for sendRequesttoTA (sendLock)
-       pthread_mutex_destroy (&sendLock);
+       pthread_mutex_destroy(&sendLock);
 }
index be2bf01..f85729c 100644 (file)
@@ -44,7 +44,6 @@ uint32_t sessID = 51;
  */
 TEEContext::TEEContext(uint32_t contextID, IConnectionSession* connSession):
     secContext(connSession->getSecurityContext()) {
-
        LOGD(SIM_DAEMON, "ContextID: %d", contextID);
 
        /* Initialize the locks for shared memory list (mShmList) and Session map
@@ -67,7 +66,6 @@ TEEContext::TEEContext(uint32_t contextID, IConnectionSession* connSession):
  * @param data data sent from TEECLib for InitContext
  */
 TEEC_Result TEEContext::initContext(InitContextData* data) {
-
        TEEC_Result result = TEEC_ERROR_GENERIC;
 
        LOGD(SIM_DAEMON, "Entry");
@@ -111,7 +109,6 @@ TEEC_Result TEEContext::initContext(InitContextData* data) {
  * @param data data sent from TEECLib for FinalizeContext
  */
 void TEEContext::finContext(FinalizeContextData data) {
-
        TEEC_Result result = TEEC_ERROR_GENERIC;
        LOGD(SIM_DAEMON, "Entry");
 
@@ -165,7 +162,6 @@ void TEEContext::finContext(FinalizeContextData data) {
  * @param data data sent from TEECLib for OpenSession
  */
 TEEC_Result TEEContext::openSession(OpenSessionData data) {
-
        TEEC_Result result = TEEC_ERROR_GENERIC;
 
        LOGD(SIM_DAEMON, "Entry");
@@ -221,7 +217,6 @@ TEEC_Result TEEContext::openSession(OpenSessionData data) {
  * @param data data sent from TEECLib for InvokeCommand
  */
 TEEC_Result TEEContext::invokeCommand(InvokeCommandData data) {
-
        TEEC_Result result = TEEC_ERROR_GENERIC;
        LOGD(SIM_DAEMON, "Entry");
        data.returnOrigin = TEEC_ORIGIN_TEE;
@@ -266,7 +261,6 @@ TEEC_Result TEEContext::invokeCommand(InvokeCommandData data) {
  * @param data data sent from TEECLib for RequestCancellation
  */
 void TEEContext::reqCancel(ReqCancellationData data) {
-
        TEEC_Result result = TEEC_ERROR_GENERIC;
        LOGD(SIM_DAEMON, "Entry");
 
@@ -302,7 +296,6 @@ void TEEContext::reqCancel(ReqCancellationData data) {
  * @param data data sent from TEECLib for CloseSession
  */
 TEEC_Result TEEContext::closeSession(CloseSessionData data) {
-
        TEEC_Result result = TEEC_ERROR_GENERIC;
        LOGD(SIM_DAEMON, "Entry");
 
@@ -351,7 +344,6 @@ TEEC_Result TEEContext::closeSession(CloseSessionData data) {
  * @param data data sent from SSFLib for OpenTASession
  */
 TEEC_Result TEEContext::openTASession(IntTAOpenSessionData data) {
-
        TEEC_Result result = TEEC_ERROR_GENERIC;
        LOGD(SIM_DAEMON, "Entry");
 
@@ -432,7 +424,6 @@ TEEC_Result TEEContext::openTASession(IntTAOpenSessionData data) {
  * @param data data sent from SSFLib for CloseTASession
  */
 void TEEContext::closeTASession(IntTACloseSessionData data) {
-
        TEEC_Result result = TEEC_ERROR_GENERIC;
        map<uint32_t, ISession*>::iterator it;
        LOGD(SIM_DAEMON, "Entry");
@@ -470,7 +461,6 @@ void TEEContext::closeTASession(IntTACloseSessionData data) {
  * @param data data sent from SSFLib for InvokeTACommand
  */
 TEEC_Result TEEContext::invokeTACommand(IntTAInvokeCommandData data) {
-
        TEEC_Result result = TEEC_ERROR_GENERIC;
        LOGD(SIM_DAEMON, "Entry");
 
@@ -517,7 +507,6 @@ TEEC_Result TEEContext::invokeTACommand(IntTAInvokeCommandData data) {
  * @param data data sent from TEECLib for RegisterSharedMemory
  */
 TEEC_Result TEEContext::registerSharedMemory(RegSharedMemData data) {
-
        TEEC_Result result = TEEC_ERROR_GENERIC;
        LOGD(SIM_DAEMON, "Entry");
 
index a99bc7d..ab5aafc 100644 (file)
@@ -63,46 +63,46 @@ typedef struct _CryptoCoreContainer
        CryptoCoreCTX *ctx;                                                                                                                                             /**<    Algorithm       */
 
        // Pseudo Random Number Generation (ANSI X9.17)
-       int (*PRNG_seed)  (struct _CryptoCoreContainer *crt, cc_u8 *seed);
-       int (*PRNG_get)   (struct _CryptoCoreContainer *crt, cc_u32 bitlength, cc_u8 *data);
+       int (*PRNG_seed)(struct _CryptoCoreContainer *crt, cc_u8 *seed);
+       int (*PRNG_get)(struct _CryptoCoreContainer *crt, cc_u32 bitlength, cc_u8 *data);
 
        // Message Digest (MD5, SHA-1)
-       int (*MD_init)    (struct _CryptoCoreContainer *crt);
-       int (*MD_update)  (struct _CryptoCoreContainer *crt, cc_u8 *msg, cc_u32 msglen);
-       int (*MD_final)   (struct _CryptoCoreContainer *crt, cc_u8 *output);
-       int (*MD_getHASH) (struct _CryptoCoreContainer *crt, cc_u8 *msg, cc_u32 msglen, cc_u8 *output);
+       int (*MD_init)(struct _CryptoCoreContainer *crt);
+       int (*MD_update)(struct _CryptoCoreContainer *crt, cc_u8 *msg, cc_u32 msglen);
+       int (*MD_final)(struct _CryptoCoreContainer *crt, cc_u8 *output);
+       int (*MD_getHASH)(struct _CryptoCoreContainer *crt, cc_u8 *msg, cc_u32 msglen, cc_u8 *output);
 
        // Message Authentication Code (CMAC, HMAC MD5, HMAC SHA-1)
-       int (*MAC_init)   (struct _CryptoCoreContainer *crt, cc_u8 *Key, cc_u32 KeyLen);
-       int (*MAC_update) (struct _CryptoCoreContainer *crt, cc_u8 *msg, cc_u32 msgLen);
-       int (*MAC_final)  (struct _CryptoCoreContainer *crt, cc_u8 *output, cc_u32 *outputLen);
-       int (*MAC_getMAC) (struct _CryptoCoreContainer *crt, cc_u8 *Key, cc_u32 KeyLen, cc_u8 *msg, cc_u32 msgLen, cc_u8 *output, cc_u32 *outputLen);
+       int (*MAC_init)(struct _CryptoCoreContainer *crt, cc_u8 *Key, cc_u32 KeyLen);
+       int (*MAC_update)(struct _CryptoCoreContainer *crt, cc_u8 *msg, cc_u32 msgLen);
+       int (*MAC_final)(struct _CryptoCoreContainer *crt, cc_u8 *output, cc_u32 *outputLen);
+       int (*MAC_getMAC)(struct _CryptoCoreContainer *crt, cc_u8 *Key, cc_u32 KeyLen, cc_u8 *msg, cc_u32 msgLen, cc_u8 *output, cc_u32 *outputLen);
 
        // Key Exchange (DH, ECDH)
-       int (*DH_GenerateParam)         (struct _CryptoCoreContainer *crt, cc_u8* pPrime, cc_u32 nPrimeLen, cc_u8* pGenerator);
-       int (*DH_SetParam)                      (struct _CryptoCoreContainer *crt, cc_u8* pPrime, cc_u32 nPrimeLen, cc_u8* nGenerator, cc_u32 nGeneratorLen);
-       int (*DH_Gen1stPhaseKey)        (struct _CryptoCoreContainer *crt, cc_u8* pPriv, cc_u8* pPub);
-       int (*DH_GenAuthKey)            (struct _CryptoCoreContainer *crt, cc_u8* pPriv, cc_u8* pPub, cc_u8* pSharedSecret);
-       int (*ECDH_Gen1stPhaseKey)      (struct _CryptoCoreContainer *crt, cc_u8* pDH_Xk, cc_u8* pDH1stPhaseKey);
-       int (*ECDH_GenAuthKey)          (struct _CryptoCoreContainer *crt, cc_u8* pchXk, cc_u8* pchYv, cc_u8* pchKauth);
+       int (*DH_GenerateParam)(struct _CryptoCoreContainer *crt, cc_u8* pPrime, cc_u32 nPrimeLen, cc_u8* pGenerator);
+       int (*DH_SetParam)(struct _CryptoCoreContainer *crt, cc_u8* pPrime, cc_u32 nPrimeLen, cc_u8* nGenerator, cc_u32 nGeneratorLen);
+       int (*DH_Gen1stPhaseKey)(struct _CryptoCoreContainer *crt, cc_u8* pPriv, cc_u8* pPub);
+       int (*DH_GenAuthKey)(struct _CryptoCoreContainer *crt, cc_u8* pPriv, cc_u8* pPub, cc_u8* pSharedSecret);
+       int (*ECDH_Gen1stPhaseKey)(struct _CryptoCoreContainer *crt, cc_u8* pDH_Xk, cc_u8* pDH1stPhaseKey);
+       int (*ECDH_GenAuthKey)(struct _CryptoCoreContainer *crt, cc_u8* pchXk, cc_u8* pchYv, cc_u8* pchKauth);
 
        // Symmetric Encryption (DES, 3DES, AES, RC4, SNOW)
        // mode example : ENC_ECB, DEC_ECB, ENC_CBC, DEC_CBC, ...
-       int (*SE_init)    (struct _CryptoCoreContainer *crt, cc_u32 mode, cc_u32 PADDING, cc_u8 *key, cc_u32 keysize, cc_u8 *IV);
-       int (*SE_process) (struct _CryptoCoreContainer *crt, cc_u8 *in, cc_u32 inLen, cc_u8 *out, cc_u32 *outLen);
-       int (*SE_final)   (struct _CryptoCoreContainer *crt, cc_u8 *input, cc_u32 inputLen, cc_u8 *output, cc_u32 *outputLen);
+       int (*SE_init)(struct _CryptoCoreContainer *crt, cc_u32 mode, cc_u32 PADDING, cc_u8 *key, cc_u32 keysize, cc_u8 *IV);
+       int (*SE_process)(struct _CryptoCoreContainer *crt, cc_u8 *in, cc_u32 inLen, cc_u8 *out, cc_u32 *outLen);
+       int (*SE_final)(struct _CryptoCoreContainer *crt, cc_u8 *input, cc_u32 inputLen, cc_u8 *output, cc_u32 *outputLen);
        // Simple AES Function
-       int (*SE_EncryptOneBlock)  (cc_u8 *cipherText, cc_u8 *plainText,        cc_u8 *UserKey);
-       int (*SE_DecryptOneBlock)  (cc_u8 *plainText, cc_u8 *cipherText,        cc_u8 *UserKey);
+       int (*SE_EncryptOneBlock)(cc_u8 *cipherText, cc_u8 *plainText,  cc_u8 *UserKey);
+       int (*SE_DecryptOneBlock)(cc_u8 *plainText, cc_u8 *cipherText,  cc_u8 *UserKey);
 
        // Asymmetric Encryption (RSA, Elgamal, EC-Elgamal)
-       int (*AE_encrypt) (struct _CryptoCoreContainer *crt, cc_u8 *in, cc_u32 inLen, cc_u8 *out, cc_u32 *outLen);
-       int (*AE_decrypt) (struct _CryptoCoreContainer *crt, cc_u8 *in, cc_u32 inLen, cc_u8 *out, cc_u32 *outLen);
-       int (*AE_decryptByCRT) (struct _CryptoCoreContainer *crt, cc_u8 *in, cc_u32 inLen, cc_u8 *out, cc_u32 *outLen);
+       int (*AE_encrypt)(struct _CryptoCoreContainer *crt, cc_u8 *in, cc_u32 inLen, cc_u8 *out, cc_u32 *outLen);
+       int (*AE_decrypt)(struct _CryptoCoreContainer *crt, cc_u8 *in, cc_u32 inLen, cc_u8 *out, cc_u32 *outLen);
+       int (*AE_decryptByCRT)(struct _CryptoCoreContainer *crt, cc_u8 *in, cc_u32 inLen, cc_u8 *out, cc_u32 *outLen);
 
        // Digital Signature (DSA, EC-DSA)
-       int (*DS_sign)    (struct _CryptoCoreContainer *crt, cc_u8 *hash, cc_u32 hashLen, cc_u8 *signature, cc_u32 *signLen);
-       int (*DS_verify)  (struct _CryptoCoreContainer *crt, cc_u8 *hash, cc_u32 hashLen, cc_u8 *signature, cc_u32 signLen, int *result);
+       int (*DS_sign)(struct _CryptoCoreContainer *crt, cc_u8 *hash, cc_u32 hashLen, cc_u8 *signature, cc_u32 *signLen);
+       int (*DS_verify)(struct _CryptoCoreContainer *crt, cc_u8 *hash, cc_u32 hashLen, cc_u8 *signature, cc_u32 signLen, int *result);
        int (*DSA_genParam)(
                struct _CryptoCoreContainer *crt, cc_u32 T_Siz,
                cc_u8 *DSA_P_Data, cc_u32 *DSA_P_Len,
@@ -210,7 +210,6 @@ typedef struct _CryptoCoreContainer
                cc_u8* PUB_X_Data, cc_u32 PUB_X_Len,
                cc_u8* PUB_Y_Data, cc_u32 PUB_Y_Len
        );
-
 } CryptoCoreContainer;
 
 #ifdef __cplusplus
@@ -251,4 +250,4 @@ void ECRYPTO_API *CCMalloc(int siz);
 
 #endif
 
-/***************************** End of File *****************************/
\ No newline at end of file
+/***************************** End of File *****************************/
index 04741ab..2de9c59 100644 (file)
@@ -334,7 +334,6 @@ typedef struct {
 
        cc_u32  t;
        cc_u32  endian;                                 //0 if little endian, 1 if bigendian
-
 } SDRM_SNOW2Context;
 
 ////////////////////////////////////////////////////////////////////////////
@@ -395,4 +394,4 @@ typedef struct {
 
 #endif
 
-/***************************** End of File *****************************/
\ No newline at end of file
+/***************************** End of File *****************************/
index 7aff057..c18b4c8 100644 (file)
@@ -43,7 +43,7 @@
 #define SDRM_CheckBitUINT32(A, k)      (0x01 & ((A)[(k) >> 5] >> ((k) & 31)))
 
 /*!    @brief  get k-th byte from cc_u32 array A       */
-#define SDRM_CheckByteUINT32(A, k)     (cc_u8)(0xff & (A[(k) >> 2] >> (((k) & 3 ) << 3)))
+#define SDRM_CheckByteUINT32(A, k)     (cc_u8)(0xff & (A[(k) >> 2] >> (((k) & 3) << 3)))
 #define SDRM_isEven0(X)                                (((X)[0] & 0x01) == 0)
 #define SDRM_isOdd0(X)                         (((X)[0] & 0x01) == 1)
 
@@ -52,7 +52,7 @@
                                                                                for (i = 0; i < (B); i++) {                                     \
                                                                                        if (++A[i] != 0) break;                                 \
                                                                                }                                                                                       \
-                                                                       } while(0)                                                                              \
+                                                                       } while (0)                                                                             \
 
 ////////////////////////////////////////////////////////////////////////////
 // MACROs for cc_u32 Evaluation
@@ -70,7 +70,7 @@
 #define SDRM_DIGIT_Mul(Dest, Src1, Src2)       do {                                                                                                                                            \
                                                                                                (Dest)[0] = (cc_u32) ((cc_u64)(Src1) * (Src2));                                                 \
                                                                                                (Dest)[1] = (cc_u32)(((cc_u64)(Src1) * (Src2)) >> SDRM_BitsInDWORD);    \
-                                                                                       } while(0)
+                                                                                       } while (0)
 #else
 void SDRM_DIGIT_Mul(cc_u32 *Dest, cc_u32 Src1, cc_u32 Src2);
 #endif
@@ -113,7 +113,7 @@ cc_u32 SDRM_DIGIT_Mod(cc_u32 Src1, cc_u32 Src2, cc_u32 Div);
  */
 #define SDRM_DWD_Copy(Dest, Src, Size) do {                                                                                            \
                                                                                        memcpy(Dest, Src, SDRM_SIZE_OF_DWORD * Size);   \
-                                                                               } while(0)
+                                                                               } while (0)
 
 ////////////////////////////////////////////////////////////////////////////
 // MACROs for Big Number
@@ -128,7 +128,7 @@ cc_u32 SDRM_DIGIT_Mod(cc_u32 Src1, cc_u32 Src2, cc_u32 Div);
  * @fn         SDRM_BN_FREE(X)
  * @brief      free allocated memory
  */
-#define SDRM_BN_FREE(X)                                do {if (X) free(X);} while(0)
+#define SDRM_BN_FREE(X)                                do {if (X) free(X);} while (0)
 
 /*
  * @fn         SDRM_BN_OPTIMIZE_LENGTH(BN
@@ -140,7 +140,7 @@ cc_u32 SDRM_DIGIT_Mod(cc_u32 Src1, cc_u32 Src2, cc_u32 Div);
                                                                                                break;                                                                                          \
                                                                                        else                                                                                                    \
                                                                                                (BN)->Length--;                                                                         \
-                                                                       } while(0)
+                                                                       } while (0)
 /*
  * @fn         SDRM_IS_BN_NEGATIVE(X)
  * @brief      check big number's sign
@@ -153,20 +153,22 @@ cc_u32 SDRM_DIGIT_Mod(cc_u32 Src1, cc_u32 Src2, cc_u32 Div);
 /*!    @brief  count byte-length of big number */
 #define        SDRM_BN_GETBYTELEN(X, A)        do {                                                                                                                                            \
                                                                                if (!((X)->Length)) (A) = 0;                                                                                    \
-                                                                               else {                                                                                                                                  \
+                                                                               else                                                                                                                                    \
+                                                                               {                                                                                                                                               \
                                                                                        (A) = (X)->Length * 4;                                                                                          \
                                                                                        while(SDRM_CheckByteUINT32((X)->pData, (A) - 1) == 0) {(A) -= 1;}       \
                                                                                }                                                                                                                                               \
-                                                                       } while(0)
+                                                                       } while (0)
 
 /*!    @brief  count bit-length of big number  */
 #define        SDRM_BN_GETBITLEN(X, A) do {                                                                                                                                                    \
                                                                                if (!((X)->Length)) (A) = 0;                                                                                    \
-                                                                               else {                                                                                                                                  \
+                                                                               else                                                                                                                                    \
+                                                                               {                                                                                                                                               \
                                                                                        (A) = (X)->Length * SDRM_BitsInDWORD;                                                           \
                                                                                        while(SDRM_CheckBitUINT32((X)->pData, (A) - 1) == 0) {(A) -= 1;}        \
                                                                                }                                                                                                                                               \
-                                                                       } while(0)
+                                                                       } while (0)
 
 ////////////////////////////////////////////////////////////////////////////
 // Global Variables
index 9f35e53..f3180f5 100644 (file)
 #endif
 
 /*!    @brief  permutation operation                                           */
-#define SDRM_PERM_OP(a,b,t,n,m) {                              \
-       (t) = ((((a)>>(n))^(b))&(m));                           \
+#define SDRM_PERM_OP(a, b, t, n, m) {                          \
+       (t) = ((((a) >> (n))^(b))&(m));                         \
        (b) ^= (t);                                                                     \
-       (a) ^= ((t)<<(n));                                                      \
+       (a) ^= ((t) << (n));                                                    \
 }
 
 /*!    @brief  initial permutation                                                     */
-#define SDRM_IP(l,r) {                                                 \
+#define SDRM_IP(l, r) {                                                        \
        cc_u32 tt;                                                                      \
-       SDRM_PERM_OP(r,l,tt, 4,0x0f0f0f0f);                     \
-       SDRM_PERM_OP(l,r,tt,16,0x0000ffff);                     \
-       SDRM_PERM_OP(r,l,tt, 2,0x33333333);                     \
-       SDRM_PERM_OP(l,r,tt, 8,0x00ff00ff);                     \
-       SDRM_PERM_OP(r,l,tt, 1,0x55555555);                     \
+       SDRM_PERM_OP(r, l, tt, 4, 0x0f0f0f0f);                  \
+       SDRM_PERM_OP(l, r, tt, 16, 0x0000ffff);                 \
+       SDRM_PERM_OP(r, l, tt, 2, 0x33333333);                  \
+       SDRM_PERM_OP(l, r, tt, 8, 0x00ff00ff);                  \
+       SDRM_PERM_OP(r, l, tt, 1, 0x55555555);                  \
 }
 
 /*!    @brief  inverse of initial permutation                          */
-#define SDRM_INV_IP(l,r) {                                             \
+#define SDRM_INV_IP(l, r) {                                            \
        cc_u32 tt;                                                                      \
-       SDRM_PERM_OP(l,r,tt, 1,0x55555555);                     \
-       SDRM_PERM_OP(r,l,tt, 8,0x00ff00ff);                     \
-       SDRM_PERM_OP(l,r,tt, 2,0x33333333);                     \
-       SDRM_PERM_OP(r,l,tt,16,0x0000ffff);                     \
-       SDRM_PERM_OP(l,r,tt, 4,0x0f0f0f0f);                     \
+       SDRM_PERM_OP(l, r, tt, 1, 0x55555555);                  \
+       SDRM_PERM_OP(r, l, tt, 8, 0x00ff00ff);                  \
+       SDRM_PERM_OP(l, r, tt, 2, 0x33333333);                  \
+       SDRM_PERM_OP(r, l, tt, 16, 0x0000ffff);                 \
+       SDRM_PERM_OP(l, r, tt, 4, 0x0f0f0f0f);                  \
 }
 
 /*!    @brief  encrypt one round                                                       */
-#define SDRM_D_ENCRYPT(L,R) {                                  \
+#define SDRM_D_ENCRYPT(L, R) {                                 \
        u = R ^ RoundKey[i][0];                                         \
        t = R ^ RoundKey[i][1];                                         \
        t = SDRM_rotr32(t, 4);                                          \
@@ -112,155 +112,155 @@ static const cc_u8 SDRM_DES_KS_PC1[] = {
 static const cc_u32 SDRM_des_skb[8][64]={
        {
                /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
-               0x00000000L,0x00000010L,0x20000000L,0x20000010L,
-               0x00010000L,0x00010010L,0x20010000L,0x20010010L,
-               0x00000800L,0x00000810L,0x20000800L,0x20000810L,
-               0x00010800L,0x00010810L,0x20010800L,0x20010810L,
-               0x00000020L,0x00000030L,0x20000020L,0x20000030L,
-               0x00010020L,0x00010030L,0x20010020L,0x20010030L,
-               0x00000820L,0x00000830L,0x20000820L,0x20000830L,
-               0x00010820L,0x00010830L,0x20010820L,0x20010830L,
-               0x00080000L,0x00080010L,0x20080000L,0x20080010L,
-               0x00090000L,0x00090010L,0x20090000L,0x20090010L,
-               0x00080800L,0x00080810L,0x20080800L,0x20080810L,
-               0x00090800L,0x00090810L,0x20090800L,0x20090810L,
-               0x00080020L,0x00080030L,0x20080020L,0x20080030L,
-               0x00090020L,0x00090030L,0x20090020L,0x20090030L,
-               0x00080820L,0x00080830L,0x20080820L,0x20080830L,
-               0x00090820L,0x00090830L,0x20090820L,0x20090830L,
+               0x00000000L, 0x00000010L, 0x20000000L, 0x20000010L,
+               0x00010000L, 0x00010010L, 0x20010000L, 0x20010010L,
+               0x00000800L, 0x00000810L, 0x20000800L, 0x20000810L,
+               0x00010800L, 0x00010810L, 0x20010800L, 0x20010810L,
+               0x00000020L, 0x00000030L, 0x20000020L, 0x20000030L,
+               0x00010020L, 0x00010030L, 0x20010020L, 0x20010030L,
+               0x00000820L, 0x00000830L, 0x20000820L, 0x20000830L,
+               0x00010820L, 0x00010830L, 0x20010820L, 0x20010830L,
+               0x00080000L, 0x00080010L, 0x20080000L, 0x20080010L,
+               0x00090000L, 0x00090010L, 0x20090000L, 0x20090010L,
+               0x00080800L, 0x00080810L, 0x20080800L, 0x20080810L,
+               0x00090800L, 0x00090810L, 0x20090800L, 0x20090810L,
+               0x00080020L, 0x00080030L, 0x20080020L, 0x20080030L,
+               0x00090020L, 0x00090030L, 0x20090020L, 0x20090030L,
+               0x00080820L, 0x00080830L, 0x20080820L, 0x20080830L,
+               0x00090820L, 0x00090830L, 0x20090820L, 0x20090830L,
        },
        {
                /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
-               0x00000000L,0x02000000L,0x00002000L,0x02002000L,
-               0x00200000L,0x02200000L,0x00202000L,0x02202000L,
-               0x00000004L,0x02000004L,0x00002004L,0x02002004L,
-               0x00200004L,0x02200004L,0x00202004L,0x02202004L,
-               0x00000400L,0x02000400L,0x00002400L,0x02002400L,
-               0x00200400L,0x02200400L,0x00202400L,0x02202400L,
-               0x00000404L,0x02000404L,0x00002404L,0x02002404L,
-               0x00200404L,0x02200404L,0x00202404L,0x02202404L,
-               0x10000000L,0x12000000L,0x10002000L,0x12002000L,
-               0x10200000L,0x12200000L,0x10202000L,0x12202000L,
-               0x10000004L,0x12000004L,0x10002004L,0x12002004L,
-               0x10200004L,0x12200004L,0x10202004L,0x12202004L,
-               0x10000400L,0x12000400L,0x10002400L,0x12002400L,
-               0x10200400L,0x12200400L,0x10202400L,0x12202400L,
-               0x10000404L,0x12000404L,0x10002404L,0x12002404L,
-               0x10200404L,0x12200404L,0x10202404L,0x12202404L,
+               0x00000000L, 0x02000000L, 0x00002000L, 0x02002000L,
+               0x00200000L, 0x02200000L, 0x00202000L, 0x02202000L,
+               0x00000004L, 0x02000004L, 0x00002004L, 0x02002004L,
+               0x00200004L, 0x02200004L, 0x00202004L, 0x02202004L,
+               0x00000400L, 0x02000400L, 0x00002400L, 0x02002400L,
+               0x00200400L, 0x02200400L, 0x00202400L, 0x02202400L,
+               0x00000404L, 0x02000404L, 0x00002404L, 0x02002404L,
+               0x00200404L, 0x02200404L, 0x00202404L, 0x02202404L,
+               0x10000000L, 0x12000000L, 0x10002000L, 0x12002000L,
+               0x10200000L, 0x12200000L, 0x10202000L, 0x12202000L,
+               0x10000004L, 0x12000004L, 0x10002004L, 0x12002004L,
+               0x10200004L, 0x12200004L, 0x10202004L, 0x12202004L,
+               0x10000400L, 0x12000400L, 0x10002400L, 0x12002400L,
+               0x10200400L, 0x12200400L, 0x10202400L, 0x12202400L,
+               0x10000404L, 0x12000404L, 0x10002404L, 0x12002404L,
+               0x10200404L, 0x12200404L, 0x10202404L, 0x12202404L,
        },
        {
                /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
-               0x00000000L,0x00000001L,0x00040000L,0x00040001L,
-               0x01000000L,0x01000001L,0x01040000L,0x01040001L,
-               0x00000002L,0x00000003L,0x00040002L,0x00040003L,
-               0x01000002L,0x01000003L,0x01040002L,0x01040003L,
-               0x00000200L,0x00000201L,0x00040200L,0x00040201L,
-               0x01000200L,0x01000201L,0x01040200L,0x01040201L,
-               0x00000202L,0x00000203L,0x00040202L,0x00040203L,
-               0x01000202L,0x01000203L,0x01040202L,0x01040203L,
-               0x08000000L,0x08000001L,0x08040000L,0x08040001L,
-               0x09000000L,0x09000001L,0x09040000L,0x09040001L,
-               0x08000002L,0x08000003L,0x08040002L,0x08040003L,
-               0x09000002L,0x09000003L,0x09040002L,0x09040003L,
-               0x08000200L,0x08000201L,0x08040200L,0x08040201L,
-               0x09000200L,0x09000201L,0x09040200L,0x09040201L,
-               0x08000202L,0x08000203L,0x08040202L,0x08040203L,
-               0x09000202L,0x09000203L,0x09040202L,0x09040203L,
+               0x00000000L, 0x00000001L, 0x00040000L, 0x00040001L,
+               0x01000000L, 0x01000001L, 0x01040000L, 0x01040001L,
+               0x00000002L, 0x00000003L, 0x00040002L, 0x00040003L,
+               0x01000002L, 0x01000003L, 0x01040002L, 0x01040003L,
+               0x00000200L, 0x00000201L, 0x00040200L, 0x00040201L,
+               0x01000200L, 0x01000201L, 0x01040200L, 0x01040201L,
+               0x00000202L, 0x00000203L, 0x00040202L, 0x00040203L,
+               0x01000202L, 0x01000203L, 0x01040202L, 0x01040203L,
+               0x08000000L, 0x08000001L, 0x08040000L, 0x08040001L,
+               0x09000000L, 0x09000001L, 0x09040000L, 0x09040001L,
+               0x08000002L, 0x08000003L, 0x08040002L, 0x08040003L,
+               0x09000002L, 0x09000003L, 0x09040002L, 0x09040003L,
+               0x08000200L, 0x08000201L, 0x08040200L, 0x08040201L,
+               0x09000200L, 0x09000201L, 0x09040200L, 0x09040201L,
+               0x08000202L, 0x08000203L, 0x08040202L, 0x08040203L,
+               0x09000202L, 0x09000203L, 0x09040202L, 0x09040203L,
        },
        {
                /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
-               0x00000000L,0x00100000L,0x00000100L,0x00100100L,
-               0x00000008L,0x00100008L,0x00000108L,0x00100108L,
-               0x00001000L,0x00101000L,0x00001100L,0x00101100L,
-               0x00001008L,0x00101008L,0x00001108L,0x00101108L,
-               0x04000000L,0x04100000L,0x04000100L,0x04100100L,
-               0x04000008L,0x04100008L,0x04000108L,0x04100108L,
-               0x04001000L,0x04101000L,0x04001100L,0x04101100L,
-               0x04001008L,0x04101008L,0x04001108L,0x04101108L,
-               0x00020000L,0x00120000L,0x00020100L,0x00120100L,
-               0x00020008L,0x00120008L,0x00020108L,0x00120108L,
-               0x00021000L,0x00121000L,0x00021100L,0x00121100L,
-               0x00021008L,0x00121008L,0x00021108L,0x00121108L,
-               0x04020000L,0x04120000L,0x04020100L,0x04120100L,
-               0x04020008L,0x04120008L,0x04020108L,0x04120108L,
-               0x04021000L,0x04121000L,0x04021100L,0x04121100L,
-               0x04021008L,0x04121008L,0x04021108L,0x04121108L,
+               0x00000000L, 0x00100000L, 0x00000100L, 0x00100100L,
+               0x00000008L, 0x00100008L, 0x00000108L, 0x00100108L,
+               0x00001000L, 0x00101000L, 0x00001100L, 0x00101100L,
+               0x00001008L, 0x00101008L, 0x00001108L, 0x00101108L,
+               0x04000000L, 0x04100000L, 0x04000100L, 0x04100100L,
+               0x04000008L, 0x04100008L, 0x04000108L, 0x04100108L,
+               0x04001000L, 0x04101000L, 0x04001100L, 0x04101100L,
+               0x04001008L, 0x04101008L, 0x04001108L, 0x04101108L,
+               0x00020000L, 0x00120000L, 0x00020100L, 0x00120100L,
+               0x00020008L, 0x00120008L, 0x00020108L, 0x00120108L,
+               0x00021000L, 0x00121000L, 0x00021100L, 0x00121100L,
+               0x00021008L, 0x00121008L, 0x00021108L, 0x00121108L,
+               0x04020000L, 0x04120000L, 0x04020100L, 0x04120100L,
+               0x04020008L, 0x04120008L, 0x04020108L, 0x04120108L,
+               0x04021000L, 0x04121000L, 0x04021100L, 0x04121100L,
+               0x04021008L, 0x04121008L, 0x04021108L, 0x04121108L,
        },
        {
                /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
-               0x00000000L,0x10000000L,0x00010000L,0x10010000L,
-               0x00000004L,0x10000004L,0x00010004L,0x10010004L,
-               0x20000000L,0x30000000L,0x20010000L,0x30010000L,
-               0x20000004L,0x30000004L,0x20010004L,0x30010004L,
-               0x00100000L,0x10100000L,0x00110000L,0x10110000L,
-               0x00100004L,0x10100004L,0x00110004L,0x10110004L,
-               0x20100000L,0x30100000L,0x20110000L,0x30110000L,
-               0x20100004L,0x30100004L,0x20110004L,0x30110004L,
-               0x00001000L,0x10001000L,0x00011000L,0x10011000L,
-               0x00001004L,0x10001004L,0x00011004L,0x10011004L,
-               0x20001000L,0x30001000L,0x20011000L,0x30011000L,
-               0x20001004L,0x30001004L,0x20011004L,0x30011004L,
-               0x00101000L,0x10101000L,0x00111000L,0x10111000L,
-               0x00101004L,0x10101004L,0x00111004L,0x10111004L,
-               0x20101000L,0x30101000L,0x20111000L,0x30111000L,
-               0x20101004L,0x30101004L,0x20111004L,0x30111004L,
+               0x00000000L, 0x10000000L, 0x00010000L, 0x10010000L,
+               0x00000004L, 0x10000004L, 0x00010004L, 0x10010004L,
+               0x20000000L, 0x30000000L, 0x20010000L, 0x30010000L,
+               0x20000004L, 0x30000004L, 0x20010004L, 0x30010004L,
+               0x00100000L, 0x10100000L, 0x00110000L, 0x10110000L,
+               0x00100004L, 0x10100004L, 0x00110004L, 0x10110004L,
+               0x20100000L, 0x30100000L, 0x20110000L, 0x30110000L,
+               0x20100004L, 0x30100004L, 0x20110004L, 0x30110004L,
+               0x00001000L, 0x10001000L, 0x00011000L, 0x10011000L,
+               0x00001004L, 0x10001004L, 0x00011004L, 0x10011004L,
+               0x20001000L, 0x30001000L, 0x20011000L, 0x30011000L,
+               0x20001004L, 0x30001004L, 0x20011004L, 0x30011004L,
+               0x00101000L, 0x10101000L, 0x00111000L, 0x10111000L,
+               0x00101004L, 0x10101004L, 0x00111004L, 0x10111004L,
+               0x20101000L, 0x30101000L, 0x20111000L, 0x30111000L,
+               0x20101004L, 0x30101004L, 0x20111004L, 0x30111004L,
        },
        {
                /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
-               0x00000000L,0x08000000L,0x00000008L,0x08000008L,
-               0x00000400L,0x08000400L,0x00000408L,0x08000408L,
-               0x00020000L,0x08020000L,0x00020008L,0x08020008L,
-               0x00020400L,0x08020400L,0x00020408L,0x08020408L,
-               0x00000001L,0x08000001L,0x00000009L,0x08000009L,
-               0x00000401L,0x08000401L,0x00000409L,0x08000409L,
-               0x00020001L,0x08020001L,0x00020009L,0x08020009L,
-               0x00020401L,0x08020401L,0x00020409L,0x08020409L,
-               0x02000000L,0x0A000000L,0x02000008L,0x0A000008L,
-               0x02000400L,0x0A000400L,0x02000408L,0x0A000408L,
-               0x02020000L,0x0A020000L,0x02020008L,0x0A020008L,
-               0x02020400L,0x0A020400L,0x02020408L,0x0A020408L,
-               0x02000001L,0x0A000001L,0x02000009L,0x0A000009L,
-               0x02000401L,0x0A000401L,0x02000409L,0x0A000409L,
-               0x02020001L,0x0A020001L,0x02020009L,0x0A020009L,
-               0x02020401L,0x0A020401L,0x02020409L,0x0A020409L,
+               0x00000000L, 0x08000000L, 0x00000008L, 0x08000008L,
+               0x00000400L, 0x08000400L, 0x00000408L, 0x08000408L,
+               0x00020000L, 0x08020000L, 0x00020008L, 0x08020008L,
+               0x00020400L, 0x08020400L, 0x00020408L, 0x08020408L,
+               0x00000001L, 0x08000001L, 0x00000009L, 0x08000009L,
+               0x00000401L, 0x08000401L, 0x00000409L, 0x08000409L,
+               0x00020001L, 0x08020001L, 0x00020009L, 0x08020009L,
+               0x00020401L, 0x08020401L, 0x00020409L, 0x08020409L,
+               0x02000000L, 0x0A000000L, 0x02000008L, 0x0A000008L,
+               0x02000400L, 0x0A000400L, 0x02000408L, 0x0A000408L,
+               0x02020000L, 0x0A020000L, 0x02020008L, 0x0A020008L,
+               0x02020400L, 0x0A020400L, 0x02020408L, 0x0A020408L,
+               0x02000001L, 0x0A000001L, 0x02000009L, 0x0A000009L,
+               0x02000401L, 0x0A000401L, 0x02000409L, 0x0A000409L,
+               0x02020001L, 0x0A020001L, 0x02020009L, 0x0A020009L,
+               0x02020401L, 0x0A020401L, 0x02020409L, 0x0A020409L,
        },
        {
                /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
-               0x00000000L,0x00000100L,0x00080000L,0x00080100L,
-               0x01000000L,0x01000100L,0x01080000L,0x01080100L,
-               0x00000010L,0x00000110L,0x00080010L,0x00080110L,
-               0x01000010L,0x01000110L,0x01080010L,0x01080110L,
-               0x00200000L,0x00200100L,0x00280000L,0x00280100L,
-               0x01200000L,0x01200100L,0x01280000L,0x01280100L,
-               0x00200010L,0x00200110L,0x00280010L,0x00280110L,
-               0x01200010L,0x01200110L,0x01280010L,0x01280110L,
-               0x00000200L,0x00000300L,0x00080200L,0x00080300L,
-               0x01000200L,0x01000300L,0x01080200L,0x01080300L,
-               0x00000210L,0x00000310L,0x00080210L,0x00080310L,
-               0x01000210L,0x01000310L,0x01080210L,0x01080310L,
-               0x00200200L,0x00200300L,0x00280200L,0x00280300L,
-               0x01200200L,0x01200300L,0x01280200L,0x01280300L,
-               0x00200210L,0x00200310L,0x00280210L,0x00280310L,
-               0x01200210L,0x01200310L,0x01280210L,0x01280310L,
+               0x00000000L, 0x00000100L, 0x00080000L, 0x00080100L,
+               0x01000000L, 0x01000100L, 0x01080000L, 0x01080100L,
+               0x00000010L, 0x00000110L, 0x00080010L, 0x00080110L,
+               0x01000010L, 0x01000110L, 0x01080010L, 0x01080110L,
+               0x00200000L, 0x00200100L, 0x00280000L, 0x00280100L,
+               0x01200000L, 0x01200100L, 0x01280000L, 0x01280100L,
+               0x00200010L, 0x00200110L, 0x00280010L, 0x00280110L,
+               0x01200010L, 0x01200110L, 0x01280010L, 0x01280110L,
+               0x00000200L, 0x00000300L, 0x00080200L, 0x00080300L,
+               0x01000200L, 0x01000300L, 0x01080200L, 0x01080300L,
+               0x00000210L, 0x00000310L, 0x00080210L, 0x00080310L,
+               0x01000210L, 0x01000310L, 0x01080210L, 0x01080310L,
+               0x00200200L, 0x00200300L, 0x00280200L, 0x00280300L,
+               0x01200200L, 0x01200300L, 0x01280200L, 0x01280300L,
+               0x00200210L, 0x00200310L, 0x00280210L, 0x00280310L,
+               0x01200210L, 0x01200310L, 0x01280210L, 0x01280310L,
        },
        {
                /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
-               0x00000000L,0x04000000L,0x00040000L,0x04040000L,
-               0x00000002L,0x04000002L,0x00040002L,0x04040002L,
-               0x00002000L,0x04002000L,0x00042000L,0x04042000L,
-               0x00002002L,0x04002002L,0x00042002L,0x04042002L,
-               0x00000020L,0x04000020L,0x00040020L,0x04040020L,
-               0x00000022L,0x04000022L,0x00040022L,0x04040022L,
-               0x00002020L,0x04002020L,0x00042020L,0x04042020L,
-               0x00002022L,0x04002022L,0x00042022L,0x04042022L,
-               0x00000800L,0x04000800L,0x00040800L,0x04040800L,
-               0x00000802L,0x04000802L,0x00040802L,0x04040802L,
-               0x00002800L,0x04002800L,0x00042800L,0x04042800L,
-               0x00002802L,0x04002802L,0x00042802L,0x04042802L,
-               0x00000820L,0x04000820L,0x00040820L,0x04040820L,
-               0x00000822L,0x04000822L,0x00040822L,0x04040822L,
-               0x00002820L,0x04002820L,0x00042820L,0x04042820L,
-               0x00002822L,0x04002822L,0x00042822L,0x04042822L,
+               0x00000000L, 0x04000000L, 0x00040000L, 0x04040000L,
+               0x00000002L, 0x04000002L, 0x00040002L, 0x04040002L,
+               0x00002000L, 0x04002000L, 0x00042000L, 0x04042000L,
+               0x00002002L, 0x04002002L, 0x00042002L, 0x04042002L,
+               0x00000020L, 0x04000020L, 0x00040020L, 0x04040020L,
+               0x00000022L, 0x04000022L, 0x00040022L, 0x04040022L,
+               0x00002020L, 0x04002020L, 0x00042020L, 0x04042020L,
+               0x00002022L, 0x04002022L, 0x00042022L, 0x04042022L,
+               0x00000800L, 0x04000800L, 0x00040800L, 0x04040800L,
+               0x00000802L, 0x04000802L, 0x00040802L, 0x04040802L,
+               0x00002800L, 0x04002800L, 0x00042800L, 0x04042800L,
+               0x00002802L, 0x04002802L, 0x00042802L, 0x04042802L,
+               0x00000820L, 0x04000820L, 0x00040820L, 0x04040820L,
+               0x00000822L, 0x04000822L, 0x00040822L, 0x04040822L,
+               0x00002820L, 0x04002820L, 0x00042820L, 0x04042820L,
+               0x00002822L, 0x04002822L, 0x00042822L, 0x04042822L,
        }
 };
 
@@ -419,4 +419,4 @@ int SDRM_DES64_Decryption(cc_u8 *plainText, cc_u8 *cipherText, cc_u8 *UserKey);
 
 #endif
 
-/***************************** End of File *****************************/
\ No newline at end of file
+/***************************** End of File *****************************/
index 5cb9683..c09bd34 100644 (file)
@@ -50,7 +50,7 @@
                                                                        A->z  = SDRM_BN_Alloc((cc_u8*)A->y  + SDRM_ECC_ALLOC_SIZE,   SDRM_ECC_BN_BUFSIZE);              \
                                                                        A->z2 = SDRM_BN_Alloc((cc_u8*)A->z  + SDRM_ECC_ALLOC_SIZE,   SDRM_ECC_BN_BUFSIZE);              \
                                                                        A->z3 = SDRM_BN_Alloc((cc_u8*)A->z2 + SDRM_ECC_ALLOC_SIZE,   SDRM_ECC_BN_BUFSIZE);              \
-                                                               } while(0)
+                                                               } while (0)
 
 #define SDRM_EC_CLR(A)                 SDRM_EC_SET_ZERO(A)
 
@@ -62,7 +62,7 @@
                                                                        SDRM_BN_Clr((A)->PRIV_KEY);                                             \
                                                                        EC_Clr((A)->ECC_G);                                                             \
                                                                        EC_Clr((A)->PUBLIC_KEY);                                                \
-                                                               } while(0)
+                                                               } while (0)
 
 #define SDRM_ECC_FREE(X)               do {                                                                                                                            \
                                                                        if ((X)) {                                                                                                              \
@@ -71,7 +71,7 @@
                                                                                SDRM_EC_FREE(X->PUBLIC_KEY);                                                            \
                                                                                SDRM_EC_FREE(X);                                                                                        \
                                                                        }                                                                                                                               \
-                                                               } while(0)
+                                                               } while (0)
 
 #define SDRM_EC_COPY(A, B)             do {                                                                                                                            \
                                                                        (A)->IsInfinity = (B)->IsInfinity;                                                              \
@@ -80,7 +80,7 @@
                                                                        SDRM_BN_Copy((A)->z, (B)->z);                                                                   \
                                                                        SDRM_BN_Copy((A)->z2, (B)->z2);                                                                 \
                                                                        SDRM_BN_Copy((A)->z3, (B)->z3);                                                                 \
-                                                               } while(0)
+                                                               } while (0)
 
 
 ////////////////////////////////////////////////////////////////////////////
index 7654f11..cc6e74c 100644 (file)
@@ -69,13 +69,13 @@ typedef cc_u64 BasicDWord;
 /* If for some reasons it isn't so, then we just need to redefine rhe following two macros in appropriate way
  * and functions will work properly.
  */
-#define _add_add_(aw1,aw2,aw3,rwl,rwh) {                                                                                                       \
+#define _add_add_(aw1, aw2, aw3, rwl, rwh) {                                                                                                   \
                                                                                        BasicDWord dw = (BasicDWord)(aw1)+(aw2)+(aw3);  \
                                                                                        rwl = LOW_WORD(dw);                                                             \
                                                                                        rwh = HIGH_WORD(dw);                                                    \
                                                                                }
 
-#define _mul_add_add(wm1,wm2,aw1,aw2,rwl,rwh) {                                                                                                                                \
+#define _mul_add_add(wm1, wm2, aw1, aw2, rwl, rwh) {                                                                                                                           \
                                                                                                        BasicDWord dw = (BasicDWord)(wm1)*(wm2)+(aw1)+(aw2);    \
                                                                                                        rwl = LOW_WORD(dw);                                                                             \
                                                                                                        rwh = HIGH_WORD(dw);                                                                    \
@@ -284,7 +284,7 @@ int SDRM_ll_mont_Mul(IN BasicWord *pFirstOperand,
   * @warning   [Optional] constraints or notices
   * @see               [Optional] related information
   */
-int SDRM_ll_ExpMod( IN BasicWord *pBase, IN BasicWord uBaseLengthInBytes,
+int SDRM_ll_ExpMod(IN BasicWord *pBase, IN BasicWord uBaseLengthInBytes,
                                        IN BasicWord *pExponent, IN BasicWord uExponentLengthInBytes,
                                        IN BasicWord *pModule, IN BasicWord uModuleLengthInBytes,
                                        OUT BasicWord *pResult);
index d4ef63d..73015ab 100644 (file)
@@ -40,7 +40,7 @@ void SDRM_MD5_Init(SDRM_MD5Context *ctx);
 
 void SDRM_MD5_Update(SDRM_MD5Context *ctx, cc_u8* buffer, cc_u32 cc_u8Count);
 
-void SDRM_MD5_Final(SDRM_MD5Context *ctx, cc_u8* output );
+void SDRM_MD5_Final(SDRM_MD5Context *ctx, cc_u8* output);
 
 #ifdef __cplusplus
 }
@@ -48,4 +48,4 @@ void SDRM_MD5_Final(SDRM_MD5Context *ctx, cc_u8* output );
 
 #endif // _MD5_H
 
-/***************************** End of File *****************************/
\ No newline at end of file
+/***************************** End of File *****************************/
index 9bbecd5..ae2559a 100644 (file)
@@ -39,7 +39,7 @@
 ////////////////////////////////////////////////////////////////////////////
 #ifndef SDRM_CheckByteUINT32
 /*!    @brief  get k-th byte from cc_u32 array A       */
-#define SDRM_CheckByteUINT32(A, k)             (cc_u8)(0xff & (A[(k) >> 2] >> (((k) & 3 ) << 3)))
+#define SDRM_CheckByteUINT32(A, k)             (cc_u8)(0xff & (A[(k) >> 2] >> (((k) & 3) << 3)))
 #endif
 
 
index 89629dd..8cdf1a5 100644 (file)
@@ -43,8 +43,8 @@
 #define PrintBYTE(msg, Data, DataLen) {                                        \
        int idx;                                                                                        \
        printf("%10s =", msg);                                                          \
-       for( idx=0; idx<(int)DataLen; idx++) {                          \
-               if( (idx!=0) && ((idx%16)==0) ) printf("\n");   \
+       for( idx = 0; idx < (int)DataLen; idx++) {                      \
+               if( (idx != 0) && ((idx%16) == 0) ) printf("\n");       \
                if((idx % 4) == 0)      printf(" 0x");                          \
                printf("%.2x", Data[idx]);                                              \
        }                                                                                                       \
@@ -56,8 +56,8 @@
 #define PrintBYTE_HEX(msg, Data, DataLen) {                            \
        int idx;                                                                                        \
        printf("%10s =", msg);                                                          \
-       for( idx=0; idx<(int)DataLen; idx++) {                          \
-               if( (idx!=0) && ((idx%8)==0) ) printf("\n");    \
+       for( idx = 0; idx < (int)DataLen; idx++) {                      \
+               if( (idx != 0) && ((idx%8) == 0) ) printf("\n");        \
                printf("0x%.2x, ", Data[idx]);                                  \
        }                                                                                                       \
        printf("\n");                                                                           \
@@ -67,8 +67,8 @@
 #undef PrintBYTE_FILE_RAW                                                                      // raw data ï¿½ï¿½ï¿½Â·ï¿½ ï¿½ï¿½ï¿½ï¿½ï¿½ ï¿½ï¿½ ï¿½Öµï¿½ï¿½ï¿½ Hex ï¿½ï¿½ï¿½Â·ï¿½ ï¿½ï¿½ï¿½
 #define PrintBYTE_FILE_RAW(pfile, Data, DataLen) {             \
        int idx;                                                                                        \
-       for( idx=0; idx<(int)DataLen; idx++) {                          \
-               if( (idx==0) || ((idx%8)!=0) )                                  \
+       for( idx = 0; idx < (int)DataLen; idx++) {                      \
+               if( (idx == 0) || ((idx%8) != 0) )                              \
                        fprintf(pfile, "0x%.2x, ", Data[idx]);          \
                else                                                                                    \
                        fprintf(pfile, " \n0x%.2x, ", Data[idx]);       \
@@ -99,7 +99,7 @@
 
 /*!    @brief  convert 32-bit unit to 4 byte   */
 #undef GET_UINT32
-#define GET_UINT32(n,b,i)                                                              \
+#define GET_UINT32(n, b, i)                                                            \
 {                                                                                                              \
     (n) = ((unsigned int)((b)[(i)    ]) << 24 )                        \
         | ((unsigned int)((b)[(i) + 1]) << 16 )                        \
 
 /*!    @brief  4 byte to 32-bit unit   */
 #undef PUT_UINT32
-#define PUT_UINT32(n,b,i)                                                              \
+#define PUT_UINT32(n, b, i)                                                            \
 {                                                                                                              \
     (b)[(i)    ] = (unsigned char) ( (n) >> 24 );                              \
     (b)[(i) + 1] = (unsigned char) ( (n) >> 16 );                              \
 
 /*!    @brief  convert 24-bit unit to 3 byte   */
 #undef GET_UINT24
-#define GET_UINT24(n,b,i)                                                              \
+#define GET_UINT24(n, b, i)                                                            \
 {                                                                                                              \
     (n) = ( (b)[(i)    ] << 16 )                                               \
         | ( (b)[(i) + 1] << 8  )                                               \
 
 /*!    @brief  convert 3 byte to 24-bit unit   */
 #undef PUT_UINT24
-#define PUT_UINT24(n,b,i)                                                              \
+#define PUT_UINT24(n, b, i)                                                            \
 {                                                                                                              \
     (b)[(i)    ] = (unsigned char) ( (n) >> 16 );                              \
     (b)[(i) + 1] = (unsigned char) ( (n) >>  8 );                              \
 
 /*!    @brief  convert 16-bit unit to 2 byte   */
 #undef GET_UINT16
-#define GET_UINT16(n,b,i)                                                              \
+#define GET_UINT16(n, b, i)                                                            \
 {                                                                                                              \
     (n) = ( (b)[(i)    ] << 8 )                                                        \
         | ( (b)[(i) + 1]       );                                                      \
 
 /*!    @brief  convert 2 byte to 16-bit unit   */
 #undef PUT_UINT16
-#define PUT_UINT16(n,b,i)                                                              \
+#define PUT_UINT16(n, b, i)                                                            \
 {                                                                                                              \
     (b)[(i)    ] = (unsigned char) ( (n) >> 8 );                               \
     (b)[(i) + 1] = (unsigned char) ( (n)      );                               \
 
 /*!    @brief  read 1 byte of s form o & increase o    */
 #undef READ_8
-#define READ_8(t,s,o) {                                                                        \
+#define READ_8(t, s, o) {                                                              \
        t = (unsigned char) s[o];                                                                       \
        o+=1;                                                                                           \
 }
 
 /*!    @brief  read 2 byte of sfrom o & increase o     */
 #undef READ_16
-#define READ_16(t,s,o) {                                                               \
-       GET_UINT16(t,s,o);                                                                      \
+#define READ_16(t, s, o) {                                                             \
+       GET_UINT16(t, s, o);                                                            \
        o+=2;                                                                                           \
 }
 
 /*!    @brief  read 3 byte of s from o & increase o    */
 #undef READ_24
-#define READ_24(t,s,o) {                                                               \
-       GET_UINT24(t,s,o);                                                                      \
+#define READ_24(t, s, o) {                                                             \
+       GET_UINT24(t, s, o);                                                            \
        o+=3;                                                                                           \
 }
 
 /*!    @brief  read 4 byte of s from o & increase o    */
 #undef READ_32
-#define READ_32(t,s,o) {                                                               \
-       GET_UINT32(t,s,o);                                                                      \
+#define READ_32(t, s, o) {                                                             \
+       GET_UINT32(t, s, o);                                                            \
        o+=4;                                                                                           \
 }
 
 /*!    @brief  write 4 byte to s from o & increase o   */
 #undef WRITE_32
-#define WRITE_32(t,s,o) {                                                              \
-       PUT_UINT32(s,t,o);                                                                      \
+#define WRITE_32(t, s, o) {                                                            \
+       PUT_UINT32(s, t, o);                                                            \
        o+=4;                                                                                           \
 }
 
 /*!    @brief  write 3 byte to s from o & increase o   */
 #undef WRITE_24
-#define WRITE_24(t,s,o) {                                                              \
-       PUT_UINT24(s,t,o);                                                                      \
+#define WRITE_24(t, s, o) {                                                            \
+       PUT_UINT24(s, t, o);                                                            \
        o+=3;                                                                                           \
 }
 
 /*!    @brief  write 2 byte to s from o & increase o   */
 #undef WRITE_16
-#define WRITE_16(t,s,o) {                                                              \
-       PUT_UINT16(s,t,o);                                                                      \
+#define WRITE_16(t, s, o) {                                                            \
+       PUT_UINT16(s, t, o);                                                            \
        o+=2;                                                                                           \
 }
 
 /*!    @brief  write 1 byte to s from o & increase o   */
 #undef WRITE_8
-#define WRITE_8(t,s,o) {                                                               \
+#define WRITE_8(t, s, o) {                                                             \
        t[o] = (unsigned char)s;                                                                        \
        o+=1;                                                                                           \
 }
 
 #endif
 
-/***************************** End of File *****************************/
\ No newline at end of file
+/***************************** End of File *****************************/
index ad5db6e..0e45b69 100644 (file)
@@ -111,7 +111,6 @@ public:
         * @return base path
         */
        static void get_base_path(const char* filename, char* base_path);
-
 };
 
 #endif
index 1e57a1e..183a1c4 100644 (file)
@@ -295,7 +295,6 @@ private:
        unsigned int m_read_data_size;
 
        bool m_file_path_ready;
-
 };
 
 #endif
index 3200df7..4295bcb 100644 (file)
@@ -84,7 +84,6 @@ typedef struct credential {
                unsigned long major;
                unsigned long minor;
        } version; /**< module version.*/
-
 } ss_credential_s;
 
 typedef uint8_t CBT_OCTET;
index eafe680..c731bd0 100644 (file)
@@ -111,7 +111,7 @@ int file_op::read_file(const char* filename, unsigned char** buffer,
        if (fLen > 0) {
                size = fLen;
        }
-    if(        fseek(file, 0, SEEK_SET) != 0){
+    if (fseek(file, 0, SEEK_SET) != 0){
         fclose(file);
         return SS_RET_FAIL;
     }
index ba7b0f7..d4c5e99 100644 (file)
@@ -112,7 +112,7 @@ int CCryptoEngine::HWEncrypt(unsigned char* dest, unsigned long* dest_len,
 #else
 
        UCI_HANDLE uh = UCI_ERROR;
-       uh = uci_context_alloc(ID_UCI_AES128,(uci_engine_config_e)key_type);
+       uh = uci_context_alloc(ID_UCI_AES128, (uci_engine_config_e)key_type);
        if ((UCI_ERROR == uh) || (UCI_MEM_ALLOR_ERROR == uh))
        {
                SLOGE("Failed to alloc uci context handle.\n");
@@ -125,17 +125,17 @@ int CCryptoEngine::HWEncrypt(unsigned char* dest, unsigned long* dest_len,
        {
                case ID_UCI_ENC_CTR:
                {
-                       ret = uci_se_init(uh,ID_UCI_ENC_CTR,ID_UCI_NO_PADDING,(unsigned char*)key,16,NULL);
+                       ret = uci_se_init(uh, ID_UCI_ENC_CTR, ID_UCI_NO_PADDING, (unsigned char*)key, 16, NULL);
                        break;
                }
                case ID_UCI_ENC_ECB:
                {
-                       ret = uci_se_init(uh,ID_UCI_ENC_ECB,ID_UCI_PKCS5,(unsigned char*)key,16,NULL);
+                       ret = uci_se_init(uh, ID_UCI_ENC_ECB, ID_UCI_PKCS5, (unsigned char*)key, 16, NULL);
                        break;
                }
                default:
                {
-                       SLOGE("Mode %d not supported.",mode);
+                       SLOGE("Mode %d not supported.", mode);
                        uci_context_free(uh);
                        return SS_RET_INVALID_PARAM;
                }
@@ -143,24 +143,24 @@ int CCryptoEngine::HWEncrypt(unsigned char* dest, unsigned long* dest_len,
 
        if (UCI_SUCCESS != ret)
        {
-               SLOGE("Failed to init context, retcode = %d.\n",ret);
+               SLOGE("Failed to init context, retcode = %d.\n", ret);
                uci_context_free(uh);
                return SS_RET_FAIL;
        }
 
-       ret = uci_se_process(uh,src,data_len,dest,(unsigned int*)dest_len);
+       ret = uci_se_process(uh, src, data_len, dest, (unsigned int*)dest_len);
        if (UCI_SUCCESS != ret)
        {
-               SLOGE("Failed to encrypt data, retcode = %d.\n",ret);
+               SLOGE("Failed to encrypt data, retcode = %d.\n", ret);
                uci_context_free(uh);
                return SS_RET_FAIL;
        }
 
        unsigned int t;
-       ret = uci_se_final(uh,NULL,0,dest+(*dest_len),&t);
+       ret = uci_se_final(uh, NULL, 0, dest+(*dest_len), &t);
        if (UCI_SUCCESS != ret)
        {
-               SLOGE("Failed to call uci_se_final, retcode = %d.\n",ret);
+               SLOGE("Failed to call uci_se_final, retcode = %d.\n", ret);
                uci_context_free(uh);
                return SS_RET_FAIL;
        }
@@ -170,7 +170,7 @@ int CCryptoEngine::HWEncrypt(unsigned char* dest, unsigned long* dest_len,
        ret = uci_context_free(uh);
        if (UCI_SUCCESS != ret)
        {
-               SLOGE("Failed to free context, retcode = %d.\n",ret);
+               SLOGE("Failed to free context, retcode = %d.\n", ret);
        }
 
        return SS_RET_SUCCESS;
@@ -185,7 +185,7 @@ int CCryptoEngine::HWDecrypt(unsigned char* dest, unsigned long* dest_len,
     unsigned long key_type, unsigned long mode) {
 #if !defined(_SECOS_SIM_)
        UCI_HANDLE uh = UCI_ERROR;
-       uh = uci_context_alloc(ID_UCI_AES128,(uci_engine_config_e)key_type);
+       uh = uci_context_alloc(ID_UCI_AES128, (uci_engine_config_e)key_type);
        if ((UCI_ERROR == uh) || (UCI_MEM_ALLOR_ERROR == uh))
        {
                SLOGE("Failed to alloc uci context handle.");
@@ -198,41 +198,41 @@ int CCryptoEngine::HWDecrypt(unsigned char* dest, unsigned long* dest_len,
        {
                case ID_UCI_ENC_CTR:
                {
-                       ret = uci_se_init(uh,ID_UCI_DEC_CTR,ID_UCI_NO_PADDING,(unsigned char*)key,16,NULL);
+                       ret = uci_se_init(uh, ID_UCI_DEC_CTR, ID_UCI_NO_PADDING, (unsigned char*)key, 16, NULL);
                        break;
                }
                case ID_UCI_ENC_ECB:
                {
-                       ret = uci_se_init(uh,ID_UCI_DEC_ECB,ID_UCI_PKCS5,(unsigned char*)key,16,NULL);
+                       ret = uci_se_init(uh, ID_UCI_DEC_ECB, ID_UCI_PKCS5, (unsigned char*)key, 16, NULL);
                        break;
                }
                default:
                {
-                       SLOGE("Mode %d not supported.",mode);
+                       SLOGE("Mode %d not supported.", mode);
                        return SS_RET_INVALID_PARAM;
                }
        }
 
        if (UCI_SUCCESS != ret)
        {
-               SLOGE("Failed to init context, retcode = %d.",ret);
+               SLOGE("Failed to init context, retcode = %d.", ret);
                uci_context_free(uh);
                return SS_RET_FAIL;
        }
 
-       ret = uci_se_process(uh,src,data_len-16,dest,(unsigned int*)dest_len);
+       ret = uci_se_process(uh, src, data_len-16, dest, (unsigned int*)dest_len);
        if (UCI_SUCCESS != ret)
        {
-               SLOGE("Failed to decrypt data, retcode = %d.",ret);
+               SLOGE("Failed to decrypt data, retcode = %d.", ret);
                uci_context_free(uh);
                return SS_RET_FAIL;
        }
 
        unsigned int t;
-       ret = uci_se_final(uh,src+data_len-16,16,dest+(*dest_len),&t);
+       ret = uci_se_final(uh, src+data_len-16, 16, dest+(*dest_len), &t);
        if (UCI_SUCCESS != ret)
        {
-               SLOGE("Failed to call uci_se_final, retcode = %d.",ret);
+               SLOGE("Failed to call uci_se_final, retcode = %d.", ret);
                uci_context_free(uh);
                return SS_RET_FAIL;
        }
@@ -242,7 +242,7 @@ int CCryptoEngine::HWDecrypt(unsigned char* dest, unsigned long* dest_len,
        ret = uci_context_free(uh);
        if (UCI_SUCCESS != ret)
        {
-               SLOGE("Failed to free context, retcode = %d.",ret);
+               SLOGE("Failed to free context, retcode = %d.", ret);
        }
 
        return SS_RET_SUCCESS;
index a2d1fde..da48174 100644 (file)
@@ -19,8 +19,8 @@
 #include "slog.h"
 #include <new>
 
-#define SS_NODE_ID_CMP(id1, id2) memcmp(static_cast<void*>(id1),static_cast<void*>(id2),SS_NODE_ID_LEN)
-#define SS_NODE_ID_CPY(dest,src) memcpy(static_cast<void*>(dest),static_cast<void*>(src),SS_NODE_ID_LEN)
+#define SS_NODE_ID_CMP(id1, id2) memcmp(static_cast<void*>(id1), static_cast<void*>(id2), SS_NODE_ID_LEN)
+#define SS_NODE_ID_CPY(dest, src) memcpy(static_cast<void*>(dest), static_cast<void*>(src), SS_NODE_ID_LEN)
 
 pthread_mutex_t auto_lock::m_mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -148,7 +148,6 @@ int ss_temp_store::batch_remove(char* dir) {
        }
 
        return (data_find ? SS_RET_SUCCESS : SS_RET_CANT_FIND_REQUESTED_DATA);
-
 }
 
 temp_ss_node* ss_temp_store::find_node(char* data_name) {
index 833fccf..119c511 100644 (file)
@@ -67,7 +67,8 @@ void TEE_GetSystemTime(TEE_Time* time) {
                clock_gettime(CLOCK_REALTIME, &tspec);
                time->seconds = tspec.tv_sec;
                time->millis = tspec.tv_nsec / 1000000ULL;
-       } else TEE_GetREETime(time);
+       }
+       else TEE_GetREETime(time);
 }
 
 /**
index 74962e7..6ec71a7 100644 (file)
@@ -198,13 +198,11 @@ enum UCICryptoAlgorithm {
        /*!\brief Authenticated Encryption Functions  */
        ID_UCI_AE_GCM = 1091,
        ID_UCI_AE_CCM = 1092
-
 };
 
 /** @HW engine key type    */
 
 typedef enum {
-
        UCI_USER_KEY = 1, UCI_SECRET_KEY = 2, UCI_MASTER_KEY = 3
 } hw_keytype_e;
 
@@ -269,7 +267,6 @@ typedef struct dh_key {
        unsigned int privatekey_len;
        unsigned char* publickey;
        unsigned int publickey_len;
-
 } dh_key_s;
 /**
  * @brief  imp  key union.
@@ -318,7 +315,6 @@ typedef struct uci_key {
 #define ucik_dh_prikey_len   imp.dhkey.privatekey_len
 #define ucik_dh_pubkey       imp.dhkey.publickey
 #define ucik_dh_pubkey_len   imp.dhkey.publickey_len
-
 } uci_key_s;
 
 typedef enum rsa_kparam_flag {
@@ -452,7 +448,6 @@ typedef struct uci_param {
 #define ucip_dh_prime                        uparam.udhp.prime
 #define ucip_dh_generator                    uparam.udhp.generator
 #define ucip_dh_len                          uparam.udhp.len
-
 } uci_param_s;
 /** @}*/
 
index d7fed74..f363ba3 100644 (file)
@@ -45,36 +45,36 @@ unsigned char one_time_print_buffer_test[10240];
 #define TRUSTAPP_DEBUG_LEVEL_ALL     5\r
 \r
 \r
-#define APP_SVC_ERR(title, format,...) do{sprintf(one_time_print_buffer,"[%s][ERR]" format, title,##__VA_ARGS__);\\r
+#define APP_SVC_ERR(title, format, ...) do{sprintf(one_time_print_buffer, "[%s][ERR]" format, title, ##__VA_ARGS__);\\r
                                                                                }while(0);\r
-#define APP_SVC_WRN(title, format,...) do{sprintf(one_time_print_buffer,"[%s][WRN]" format, title,##__VA_ARGS__);\\r
+#define APP_SVC_WRN(title, format, ...) do{sprintf(one_time_print_buffer, "[%s][WRN]" format, title, ##__VA_ARGS__);\\r
                                                app_print_log(one_time_print_buffer);\\r
                                                                                }while(0);\r
-#define APP_SVC_DBG(title, format,...) do{sprintf(one_time_print_buffer,"[%s][DBG]" format, title,##__VA_ARGS__);\\r
+#define APP_SVC_DBG(title, format, ...) do{sprintf(one_time_print_buffer, "[%s][DBG]" format, title, ##__VA_ARGS__);\\r
                                                app_print_log(one_time_print_buffer);\\r
                                                                                }while(0);\r
-#define APP_SVC_LOG(title, format,...) do{sprintf((char *)one_time_print_buffer,"[%s][LOG]" format, title,##__VA_ARGS__);\\r
+#define APP_SVC_LOG(title, format, ...) do{sprintf((char *)one_time_print_buffer, "[%s][LOG]" format, title, ##__VA_ARGS__);\\r
                                                app_print_log(one_time_print_buffer);\\r
                                                                                }while(0);\r
 \r
-#define APP_SVC_LOG_test(title, format,...) do{sprintf(()one_time_print_buffer_test,"[%s][LOG]" format, title,##__VA_ARGS__);\\r
+#define APP_SVC_LOG_test(title, format, ...) do{sprintf(()one_time_print_buffer_test, "[%s][LOG]" format, title, ##__VA_ARGS__);\\r
                                                app_print_log_test(one_time_print_buffer_test);\\r
                                                                                }while(0);\r
 \r
-#define TURST_APP_LOG_TEST(fmt,...)  {APP_SVC_LOG_test("test", fmt, ##__VA_ARGS__)}\r
+#define TURST_APP_LOG_TEST(fmt, ...) {APP_SVC_LOG_test("test", fmt, ##__VA_ARGS__)}\r
 \r
-#define TURST_APP_ERR(fmt, ...) if(g_app_svc_dbglvl >= TRUSTAPP_DEBUG_LEVEL_ERR) {APP_SVC_ERR(APP_MODULE_NAME, fmt, ##__VA_ARGS__)}\r
-#define TURST_APP_WRN(fmt, ...) if(g_app_svc_dbglvl >= TRUSTAPP_DEBUG_LEVEL_WRN) {APP_SVC_WRN(APP_MODULE_NAME, fmt, ##__VA_ARGS__)}\r
-#define TURST_APP_DBG(fmt, ...) if(g_app_svc_dbglvl >= TRUSTAPP_DEBUG_LEVEL_DBG) {APP_SVC_DBG(APP_MODULE_NAME, fmt, ##__VA_ARGS__)}\r
-#define TURST_APP_LOG(fmt, ...) if(g_app_svc_dbglvl >= TRUSTAPP_DEBUG_LEVEL_LOG) {APP_SVC_LOG(APP_MODULE_NAME, fmt, ##__VA_ARGS__)}\r
+#define TURST_APP_ERR(fmt, ...) if (g_app_svc_dbglvl >= TRUSTAPP_DEBUG_LEVEL_ERR) {APP_SVC_ERR(APP_MODULE_NAME, fmt, ##__VA_ARGS__)}\r
+#define TURST_APP_WRN(fmt, ...) if (g_app_svc_dbglvl >= TRUSTAPP_DEBUG_LEVEL_WRN) {APP_SVC_WRN(APP_MODULE_NAME, fmt, ##__VA_ARGS__)}\r
+#define TURST_APP_DBG(fmt, ...) if (g_app_svc_dbglvl >= TRUSTAPP_DEBUG_LEVEL_DBG) {APP_SVC_DBG(APP_MODULE_NAME, fmt, ##__VA_ARGS__)}\r
+#define TURST_APP_LOG(fmt, ...) if (g_app_svc_dbglvl >= TRUSTAPP_DEBUG_LEVEL_LOG) {APP_SVC_LOG(APP_MODULE_NAME, fmt, ##__VA_ARGS__)}\r
 //#define TURST_APP_LOG(fmt, ...) TURST_APP_LOG_TEST(fmt,##__VA_ARGS__)\r
 \r
 \r
 \r
-#define TRACE_FUNCTION_IN TURST_APP_LOG("[%s][%d] In ... \n",__FUNCTION__,__LINE__);\r
-#define TRACE_FUNCTION_OUT  TURST_APP_LOG("[%s][%d] Out ... \n",__FUNCTION__,__LINE__);\r
+#define TRACE_FUNCTION_IN TURST_APP_LOG("[%s][%d] In ... \n", __FUNCTION__, __LINE__);\r
+#define TRACE_FUNCTION_OUT TURST_APP_LOG("[%s][%d] Out ... \n", __FUNCTION__, __LINE__);\r
 \r
-int app_open_log_file( char *processName);\r
+int app_open_log_file(char *processName);\r
 void app_print_log(unsigned char logBuffer[]);\r
 void app_close_log_file(void);\r
 \r
index 4957b18..46c5524 100644 (file)
 #include <tee_internal_api.h>
 
 #define PERMISSION_CHECK(variable)      \
-        if(CheckPermission(variable)) { \
-               LOGE(SSF_LIB, "Permission Denied - Function %s() is not permitted." , __FUNCTION__ );  \
+        if (CheckPermission(variable)) { \
+               LOGE(SSF_LIB, "Permission Denied - Function %s() is not permitted." , __FUNCTION__);  \
                 return TEE_ERROR_ACCESS_DENIED; }
 
 #define PERMISSION_CHECK_RETURN_VOID(variable)  \
-        if(CheckPermission(variable)) { \
-                LOGE(SSF_LIB, "Permission Denied - Function %s() is not permitted." , __FUNCTION__ );  \
+        if (CheckPermission(variable)) { \
+                LOGE(SSF_LIB, "Permission Denied - Function %s() is not permitted." , __FUNCTION__);  \
                 return; }
 
 typedef enum {
@@ -45,7 +45,7 @@ typedef enum {
 } ACCESS_PERMISSION;
 
 typedef enum {
-        TA_PRIVILEGE_PUBLIC=1,
+        TA_PRIVILEGE_PUBLIC = 1,
         TA_PRIVILEGE_PARTNER,
         TA_PRIVILEGE_PLATFORM,
 } TA_PRIVILEGE;
index 441733d..d169936 100644 (file)
 static int m_fd = -1;\r
 int g_app_svc_dbglvl = TRUSTAPP_DEBUG_LEVEL_NON;\r
 \r
-int app_open_log_file( char *processName)\r
+int app_open_log_file(char *processName)\r
 {\r
-\r
        /* save log to LOGFILE */\r
 \r
-       m_fd = open( portname,O_RDWR | O_NOCTTY | O_NONBLOCK);\r
+       m_fd = open(portname, O_RDWR | O_NOCTTY | O_NONBLOCK);\r
        if(m_fd < 0)\r
        {\r
                return -1;\r
        }\r
 \r
-       write(m_fd,processName,strlen(processName));\r
+       write(m_fd, processName, strlen(processName));\r
 \r
-       memset(one_time_print_buffer,0,sizeof(one_time_print_buffer));\r
+       memset(one_time_print_buffer, 0, sizeof(one_time_print_buffer));\r
        return 0;\r
-\r
 }\r
 \r
 void app_close_log_file(void)\r
 {\r
-\r
        close(m_fd);\r
        m_fd = -1;\r
 }\r
 void app_print_log(unsigned char logBuffer[])\r
 {\r
-\r
-       write(m_fd,logBuffer,strlen(logBuffer));\r
+       write(m_fd, logBuffer, strlen(logBuffer));\r
 }\r
 \r
 #else\r
@@ -74,7 +70,6 @@ int g_app_svc_dbglvl = TRUSTAPP_DEBUG_LEVEL_NON;
 \r
 int app_open_log_file(char *processName)\r
 {\r
-\r
        /* save log to LOGFILE */\r
        fp = fopen(SVC1_LOGFILE, "a+");\r
        if(!fp)\r
@@ -82,31 +77,27 @@ int app_open_log_file(char *processName)
                return -1;\r
        }\r
 \r
-       fprintf(fp,"Trust App name : %s.\n",processName);\r
+       fprintf(fp, "Trust App name : %s.\n", processName);\r
        fflush(fp);\r
 \r
-       memset(one_time_print_buffer,0,sizeof(one_time_print_buffer));\r
+       memset(one_time_print_buffer, 0, sizeof(one_time_print_buffer));\r
        return 0;\r
-\r
 }\r
 \r
 void app_close_log_file(void)\r
 {\r
-\r
        fclose(fp);\r
        fp = NULL;\r
 }\r
 void app_print_log(unsigned char logBuffer[])\r
 {\r
-\r
-       fprintf(fp,"%s",logBuffer);\r
+       fprintf(fp, "%s", logBuffer);\r
        fflush(fp);\r
 }\r
 \r
 void app_print_log_test(unsigned char logBuffer[])\r
 {\r
-\r
-       fprintf(fp,"%s",logBuffer);\r
+       fprintf(fp, "%s", logBuffer);\r
        fflush(fp);\r
 }\r
 \r
index 97fc47b..fd4899d 100644 (file)
@@ -49,7 +49,6 @@
  * @param length The size in uint32_t of the memory pointed to by bigInt
  */
 void TEE_BigIntInit(TEE_BigInt* value, const size_t length) {
-
        PERMISSION_CHECK_RETURN_VOID(PERM_ARITHMETIC);
        LOGD(TAG, "TEE_BigIntInit - length : %d", length);
        uint32_t teeMaxBigIntSize;
@@ -270,7 +269,6 @@ bool TEE_BigIntGetBit(const TEE_BigInt* object_raw, const uint32_t index) {
        bool bitValue = (bool)SDRM_BN_num_bits_index(objBn, index);
        LOGD(TAG, "Success");
        return bitValue;
-
 }
 
 /**
@@ -342,7 +340,8 @@ void TEE_BigIntNeg(TEE_BigInt* dest, const TEE_BigInt* op) {
        SDRM_BIG_NUM *bnOp = (SDRM_BIG_NUM*)op;
        if (dest == op)
                bnOp->sign = ((bnOp->sign == 1) ? 0 : 1);
-       else {
+       else
+       {
                SDRM_BIG_NUM *dst = (SDRM_BIG_NUM*)dest;
                SDRM_BN_Copy(dst, bnOp);
                dst->sign = ((dst->sign == 1) ? 0 : 1);
index 4780887..7e4dda3 100644 (file)
        int idx;                                                                                        \
        printf("%10s =", msg);                                                          \
        printf("\n");                                                                           \
-       for( idx=0; idx<(int)DataLen; idx++) {                          \
-               if( (idx!=0) && ((idx%16)==0) ) printf("\n");           \
+       for( idx = 0; idx < (int)DataLen; idx++) {                              \
+               if( (idx != 0) && ((idx%16) == 0) ) printf("\n");               \
                if((idx % 16) == 0)     printf("\t\"");                 \
                printf("%.2X", Data[idx]);                                              \
-               if( (idx!=0) && ((idx%16)==15) ) printf("\"");  \
+               if( (idx != 0) && ((idx%16) == 15) ) printf("\"");      \
        }                                                                                               \
        printf("\n");                                                                           \
 }
@@ -86,66 +86,66 @@ struct __TEE_OperationHandle
 static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_internal_keystruct *key, unsigned char *ivec, unsigned int ivec_len)
 {
        (void)ivec_len; /* actually always==16 */
-       int rc=0;
+       int rc = 0;
        int mode;
-       unsigned int padding=ID_NO_PADDING;
-       CryptoCoreContainer *handle=(CryptoCoreContainer *)operation->crypto;
+       unsigned int padding = ID_NO_PADDING;
+       CryptoCoreContainer *handle = (CryptoCoreContainer *)operation->crypto;
 
        switch(operation->info.algorithm)
        {
                /* TEE_OPERATION_CIPHER */
                case TEE_ALG_AES_ECB_NOPAD:
-                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode=ID_ENC_ECB;
-                       else mode=ID_DEC_ECB;
+                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode = ID_ENC_ECB;
+                       else mode = ID_DEC_ECB;
                        padding = ID_NO_PADDING;
-                       rc=handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
+                       rc = handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
                        break;
 
                case TEE_ALG_AES_ECB_PKCS5:
                case TEE_ALG_AES_ECB_PKCS7:
-                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode=ID_ENC_ECB;
-                       else mode=ID_DEC_ECB;
+                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode = ID_ENC_ECB;
+                       else mode = ID_DEC_ECB;
                        padding = ID_NO_PADDING /* ID_PKCS5 */;
-                       rc=handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
+                       rc = handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
                        break;
 
                case TEE_ALG_AES_ECB_ISO9797_M1:
                case TEE_ALG_AES_ECB_ISO9797_M2:
-                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode=ID_ENC_ECB;
-                       else mode=ID_DEC_ECB;
+                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode = ID_ENC_ECB;
+                       else mode = ID_DEC_ECB;
                        padding = ID_NO_PADDING /* ID_PKCS5 */;
-                       rc=handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
+                       rc = handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
                        break;
 
                case TEE_ALG_AES_CBC_NOPAD:
-                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode=ID_ENC_CBC;
-                       else mode=ID_DEC_CBC;
+                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode = ID_ENC_CBC;
+                       else mode = ID_DEC_CBC;
                        padding = ID_NO_PADDING;
-                       rc=handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
+                       rc = handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
                        break;
 
                case TEE_ALG_AES_CBC_PKCS5:
                case TEE_ALG_AES_CBC_PKCS7:
-                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode=ID_ENC_CBC;
-                       else mode=ID_DEC_CBC;
+                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode = ID_ENC_CBC;
+                       else mode = ID_DEC_CBC;
                        padding = ID_NO_PADDING/* ID_PKCS5 */;
-                       rc=handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
+                       rc = handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
                        break;
 
                case TEE_ALG_AES_CBC_ISO9797_M1:
                case TEE_ALG_AES_CBC_ISO9797_M2:
-                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode=ID_ENC_CBC;
-                       else mode=ID_DEC_CBC;
+                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode = ID_ENC_CBC;
+                       else mode = ID_DEC_CBC;
                        padding = ID_NO_PADDING /* ID_PKCS5 */;
-                       rc=handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
+                       rc = handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
                        break;
 
                case TEE_ALG_AES_CTR:
                case TEE_ALG_AES_CTR_NOPAD:
-                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode=ID_ENC_CTR;
-                       else mode=ID_DEC_CTR;
+                       if(operation->info.mode == TEE_MODE_ENCRYPT) mode = ID_ENC_CTR;
+                       else mode = ID_DEC_CTR;
                        padding = ID_NO_PADDING;
-                       rc=handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
+                       rc = handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
                        break;
 
                case TEE_ALG_AES_CTS:
@@ -155,25 +155,23 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
                case TEE_ALG_DES_ECB_NOPAD:
                case TEE_ALG_DES3_ECB_NOPAD:
                if(operation->info.mode == TEE_MODE_ENCRYPT) {
-                       mode=ID_ENC_ECB;
-               }
-               else {
-                       mode=ID_DEC_ECB;
+                       mode = ID_ENC_ECB;
+               } else {
+                       mode = ID_DEC_ECB;
                }
                        padding = ID_NO_PADDING;
-                       rc=handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
+                       rc = handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
                        break;
 
                case TEE_ALG_DES_CBC_NOPAD:
                case TEE_ALG_DES3_CBC_NOPAD:
                if(operation->info.mode == TEE_MODE_ENCRYPT) {
-                       mode=ID_ENC_CBC;
-               }
-               else {
-                       mode=ID_DEC_CBC;
+                       mode = ID_ENC_CBC;
+               } else {
+                       mode = ID_DEC_CBC;
                }
                        padding = ID_NO_PADDING;
-                       rc=handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
+                       rc = handle->SE_init(handle, mode, padding, key->secret.buffer, key->secret.size, ivec);
                        break;
 
                case TEE_ALG_HMAC_MD5:
@@ -189,7 +187,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
                case TEE_ALG_AES_CMAC:
                case TEE_ALG_DES3_CBC_MAC_NOPAD:
                case TEE_ALG_DES3_CBC_MAC_PKCS5:
-                       rc=handle->MAC_init(handle, key->secret.buffer, key->secret.size);
+                       rc = handle->MAC_init(handle, key->secret.buffer, key->secret.size);
                        break;
 
                case TEE_ALG_AES_CCM:
@@ -202,12 +200,12 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
                case TEE_ALG_SHA256:
                case TEE_ALG_SHA384:
                case TEE_ALG_SHA512:
-                       rc=handle->MD_init(handle);
+                       rc = handle->MD_init(handle);
                        break;
 
                case TEE_ALG_RSA_NOPAD:
                        padding = ID_NO_PADDING;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -220,7 +218,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSAES_PKCS1_V1_5:
                        padding = ID_RSAES_PKCS15;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -233,7 +231,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA1:
                        padding = ID_RSAES_OAEP_SHA1;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -246,7 +244,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224:
                        padding = ID_RSAES_OAEP_SHA224;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -259,7 +257,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256:
                        padding = ID_RSAES_OAEP_SHA256;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -272,7 +270,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384:
                        padding = ID_RSAES_OAEP_SHA384;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -285,7 +283,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512:
                        padding = ID_RSAES_OAEP_SHA512;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -298,7 +296,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSASSA_PKCS1_V1_5_MD5:
                        padding = ID_RSASSA_PKCS15_MD5;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -311,7 +309,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSASSA_PKCS1_V1_5_SHA1:
                        padding = ID_RSASSA_PKCS15_SHA1;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -324,7 +322,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSASSA_PKCS1_V1_5_SHA224:
                        padding = ID_RSASSA_PKCS15_SHA224;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -337,7 +335,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSASSA_PKCS1_V1_5_SHA256:
                        padding = ID_RSASSA_PKCS15_SHA256;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -350,7 +348,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSASSA_PKCS1_V1_5_SHA384:
                        padding = ID_RSASSA_PKCS15_SHA384;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -363,7 +361,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSASSA_PKCS1_V1_5_SHA512:
                        padding = ID_RSASSA_PKCS15_SHA512;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -376,7 +374,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA1:
                        padding = ID_RSASSA_PSS_SHA1;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -389,7 +387,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA224:
                        padding = ID_RSASSA_PSS_SHA224;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -402,7 +400,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256:
                        padding = ID_RSASSA_PSS_SHA256;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -415,7 +413,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384:
                        padding = ID_RSASSA_PSS_SHA384;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -428,7 +426,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512:
                        padding = ID_RSASSA_PSS_SHA512;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -441,7 +439,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
 
                case TEE_ALG_DSA_SHA1:
                        padding = 0;
-                       rc=handle->RSA_setKeypairForCRT(handle, padding,
+                       rc = handle->RSA_setKeypairForCRT(handle, padding,
                                                key->rsa_modulus.buffer, key->rsa_modulus.size,
                                                key->rsa_public.buffer, key->rsa_public.size,
                                                key->rsa_private.buffer, key->rsa_private.size,
@@ -453,7 +451,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
                        break;
 
                case TEE_ALG_GENERATE_SECRET_KEY:
-                       rc=handle->PRNG_get(handle, key->secret.size, key->secret.buffer);
+                       rc = handle->PRNG_get(handle, key->secret.size, key->secret.buffer);
                        /* Ignore return value to avoid CRYPTO_PANIC. Only SDRM_X931_ConditionalTest() can return TEE_ERROR.*/
                        rc = TEE_SUCCESS;
                        break;
@@ -463,7 +461,7 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
                        unsigned char E[3] = {0x01, 0x00, 0x01};
                        unsigned int ELen = 3;
 
-                       rc=handle->RSA_genKeypairWithEforCRT(handle, padding,
+                       rc = handle->RSA_genKeypairWithEforCRT(handle, padding,
                                                E, ELen,
                                key->rsa_modulus.buffer, &key->rsa_modulus.size,
                                                key->rsa_private.buffer, &key->rsa_private.size,
@@ -493,10 +491,10 @@ static int sw_crypto_ioctl_init(crypto_internal_operation *operation, crypto_int
        return rc;
 }
 
-static int sw_crypto_ioctl_update (crypto_internal_operation *operation, unsigned char* src_addr, unsigned int src_size, unsigned char* dst_addr, unsigned int* dst_size)
+static int sw_crypto_ioctl_update(crypto_internal_operation *operation, unsigned char* src_addr, unsigned int src_size, unsigned char* dst_addr, unsigned int* dst_size)
 {
        int rc;
-       CryptoCoreContainer *handle=(CryptoCoreContainer *)operation->crypto;
+       CryptoCoreContainer *handle = (CryptoCoreContainer *)operation->crypto;
 
        switch(operation->info.algorithm)
        {
@@ -517,7 +515,7 @@ static int sw_crypto_ioctl_update (crypto_internal_operation *operation, unsigne
                case TEE_ALG_DES3_ECB_NOPAD:
                case TEE_ALG_DES_CBC_NOPAD:
                case TEE_ALG_DES3_CBC_NOPAD:
-                       rc=handle->SE_process(handle, src_addr, src_size, dst_addr, dst_size);
+                       rc = handle->SE_process(handle, src_addr, src_size, dst_addr, dst_size);
                        break;
 
                case TEE_ALG_HMAC_MD5:
@@ -533,7 +531,7 @@ static int sw_crypto_ioctl_update (crypto_internal_operation *operation, unsigne
                case TEE_ALG_AES_CMAC:
                case TEE_ALG_DES3_CBC_MAC_NOPAD:
                case TEE_ALG_DES3_CBC_MAC_PKCS5:
-                       rc=handle->MAC_update(handle, src_addr, src_size);
+                       rc = handle->MAC_update(handle, src_addr, src_size);
                        break;
 
                case TEE_ALG_MD5:
@@ -542,25 +540,28 @@ static int sw_crypto_ioctl_update (crypto_internal_operation *operation, unsigne
                case TEE_ALG_SHA256:
                case TEE_ALG_SHA384:
                case TEE_ALG_SHA512:
-                       rc=handle->MD_update(handle, src_addr, src_size);
+                       rc = handle->MD_update(handle, src_addr, src_size);
                        break;
 
                default:
                        LOGE(SSF_LIB, "Not Support Algorithm : %X", operation->info.algorithm);
-                       rc=-1;
+                       rc = -1;
                        break;
        }
 
-       if(src_size && dst_size) {CRYPTO_INTERNAL_LOG("rc=%d src_size=%d dst_size=%d", rc, src_size, *dst_size);}
-       else {CRYPTO_INTERNAL_LOG("rc=%d", rc);}
+       if(src_size && dst_size) {
+               CRYPTO_INTERNAL_LOG("rc=%d src_size=%d dst_size=%d", rc, src_size, *dst_size);
+       } else {
+               CRYPTO_INTERNAL_LOG("rc=%d", rc);
+       }
        return rc;
 }
 
-static int sw_crypto_ioctl_final (crypto_internal_operation *operation, unsigned char* src_addr, unsigned int src_size, unsigned char* dst_addr, unsigned int* dst_size)
+static int sw_crypto_ioctl_final(crypto_internal_operation *operation, unsigned char* src_addr, unsigned int src_size, unsigned char* dst_addr, unsigned int* dst_size)
 {
-       int rc=-1;
-       int result=0;
-       CryptoCoreContainer *handle=(CryptoCoreContainer *)operation->crypto;
+       int rc = -1;
+       int result = 0;
+       CryptoCoreContainer *handle = (CryptoCoreContainer *)operation->crypto;
 
        switch(operation->info.algorithm)
        {
@@ -577,7 +578,7 @@ static int sw_crypto_ioctl_final (crypto_internal_operation *operation, unsigned
                case TEE_ALG_AES_CBC_ISO9797_M2:
                case TEE_ALG_AES_CTR_NOPAD:
                case TEE_ALG_AES_CTR:
-                       rc=handle->SE_final(handle, src_addr, src_size, dst_addr, dst_size);
+                       rc = handle->SE_final(handle, src_addr, src_size, dst_addr, dst_size);
                        break;
 
                case TEE_ALG_AES_CTS:
@@ -588,7 +589,7 @@ static int sw_crypto_ioctl_final (crypto_internal_operation *operation, unsigned
                case TEE_ALG_DES3_ECB_NOPAD:
                case TEE_ALG_DES_CBC_NOPAD:
                case TEE_ALG_DES3_CBC_NOPAD:
-                       rc=handle->SE_final(handle, src_addr, src_size, dst_addr, dst_size);
+                       rc = handle->SE_final(handle, src_addr, src_size, dst_addr, dst_size);
                        break;
 
                /* TEE_OPERATION_MAC */
@@ -605,10 +606,10 @@ static int sw_crypto_ioctl_final (crypto_internal_operation *operation, unsigned
                case TEE_ALG_AES_CMAC:
                case TEE_ALG_DES3_CBC_MAC_NOPAD:
                case TEE_ALG_DES3_CBC_MAC_PKCS5:
-               if(src_addr && src_size!=0) {
+               if(src_addr && src_size != 0) {
                        handle->MAC_update(handle, src_addr, src_size);
                }
-                       rc=handle->MAC_final(handle, dst_addr, dst_size);
+                       rc = handle->MAC_final(handle, dst_addr, dst_size);
                        break;
 
                /* TEE_OPERATION_AE */
@@ -623,10 +624,10 @@ static int sw_crypto_ioctl_final (crypto_internal_operation *operation, unsigned
                case TEE_ALG_SHA256:
                case TEE_ALG_SHA384:
                case TEE_ALG_SHA512:
-               if(src_addr && src_size!=0) {
+               if(src_addr && src_size != 0) {
                        handle->MD_update(handle, src_addr, src_size);
                }
-                       rc=handle->MD_final(handle, dst_addr);
+                       rc = handle->MD_final(handle, dst_addr);
                        *dst_size = operation->info.digestLength;
                        break;
 
@@ -639,10 +640,9 @@ static int sw_crypto_ioctl_final (crypto_internal_operation *operation, unsigned
                case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384:
                case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512:
                        if (operation->info.mode == TEE_MODE_ENCRYPT ) {
-                               rc=handle->AE_encrypt(handle, src_addr, src_size, dst_addr, dst_size);
-                       }
-                       else{
-                               rc=handle->AE_decrypt(handle, src_addr, src_size, dst_addr, dst_size);
+                               rc = handle->AE_encrypt(handle, src_addr, src_size, dst_addr, dst_size);
+                       } else {
+                               rc = handle->AE_decrypt(handle, src_addr, src_size, dst_addr, dst_size);
                        }
                        break;
 
@@ -659,22 +659,21 @@ static int sw_crypto_ioctl_final (crypto_internal_operation *operation, unsigned
                case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384:
                case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512:
                if (operation->info.mode == TEE_MODE_SIGN ) {
-                       rc=handle->DS_sign(handle, src_addr, src_size, dst_addr, dst_size);
-               }
-               else {
-                       rc=handle->DS_verify(handle, src_addr, src_size, dst_addr, *dst_size, &result);
+                       rc = handle->DS_sign(handle, src_addr, src_size, dst_addr, dst_size);
+               } else {
+                       rc = handle->DS_verify(handle, src_addr, src_size, dst_addr, *dst_size, &result);
                        if(result != rc) {
-                               rc=result;
+                               rc = result;
                        }
                }
                        break;
 
                case TEE_ALG_GENERATE_SECRET_KEY:
-                       rc=0;
+                       rc = 0;
                        break;
 
                case TEE_ALG_GENERATE_RSA_KEY:
-                       rc=0;
+                       rc = 0;
                        break;
 
                default:
@@ -682,8 +681,11 @@ static int sw_crypto_ioctl_final (crypto_internal_operation *operation, unsigned
                        break;
        }
 
-       if(src_size && dst_size) {CRYPTO_INTERNAL_LOG("rc=%d src_size=%d dst_size=%d", rc, src_size, *dst_size);}
-       else {CRYPTO_INTERNAL_LOG("rc=%d", rc);}
+       if(src_size && dst_size) {
+               CRYPTO_INTERNAL_LOG("rc=%d src_size=%d dst_size=%d", rc, src_size, *dst_size);
+       } else {
+               CRYPTO_INTERNAL_LOG("rc=%d", rc);
+       }
        return rc;
 }
 
@@ -706,16 +708,13 @@ static int sw_crypto_open(crypto_internal_operation *operation)
                case TEE_ALG_AES_CBC_PKCS7:
                case TEE_ALG_AES_CBC_ISO9797_M1:
                case TEE_ALG_AES_CBC_ISO9797_M2:
-               if (operation->info.keySize== 128) {
-                       alg=ID_AES128;
-               }
-               else if (operation->info.keySize== 192) {
-                       alg=ID_AES192;
-               }
-               else if (operation->info.keySize== 256) {
-                       alg=ID_AES256;
-               }
-               else {
+               if (operation->info.keySize == 128) {
+                       alg = ID_AES128;
+               } else if (operation->info.keySize == 192) {
+                       alg = ID_AES192;
+               } else if (operation->info.keySize == 256) {
+                       alg = ID_AES256;
+               } else {
                        goto error;
                }
                        break;
@@ -725,11 +724,11 @@ static int sw_crypto_open(crypto_internal_operation *operation)
                        break;
                case TEE_ALG_DES_ECB_NOPAD:
                case TEE_ALG_DES_CBC_NOPAD:
-                       alg=ID_DES;
+                       alg = ID_DES;
                        break;
                case TEE_ALG_DES3_ECB_NOPAD:
                case TEE_ALG_DES3_CBC_NOPAD:
-                       alg=ID_TDES;
+                       alg = ID_TDES;
                        break;
 
                /* TEE_OPERATION_MAC */
@@ -795,22 +794,17 @@ static int sw_crypto_open(crypto_internal_operation *operation)
                case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256:
                case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384:
                case TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512:
-                       if (operation->info.keySize== 512) {
-                               alg=ID_RSA512;
-                       }
-                       else if (operation->info.keySize== 1024) {
-                               alg=ID_RSA1024;
-                       }
-                       else if (operation->info.keySize== 2048) {
-                               alg=ID_RSA2048;
-                       }
-                       else if (operation->info.keySize== 3072) {
-                               alg=ID_RSA3072;
-                       }
-                       else if (operation->info.keySize== 4096) {
-                               alg=ID_RSA4096;
-                       }
-                       else {
+                       if (operation->info.keySize == 512) {
+                               alg = ID_RSA512;
+                       } else if (operation->info.keySize == 1024) {
+                               alg = ID_RSA1024;
+                       } else if (operation->info.keySize == 2048) {
+                               alg = ID_RSA2048;
+                       } else if (operation->info.keySize == 3072) {
+                               alg = ID_RSA3072;
+                       } else if (operation->info.keySize == 4096) {
+                               alg = ID_RSA4096;
+                       } else {
                                goto error;
                        }
                        break;
@@ -827,22 +821,17 @@ static int sw_crypto_open(crypto_internal_operation *operation)
                case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256:
                case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384:
                case TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512:
-                       if (operation->info.keySize== 512) {
-                               alg=ID_RSA512;
-                       }
-                       else if (operation->info.keySize== 1024) {
-                               alg=ID_RSA1024;
-                       }
-                       else if (operation->info.keySize== 2048) {
-                               alg=ID_RSA2048;
-                       }
-                       else if (operation->info.keySize== 3072) {
-                               alg=ID_RSA3072;
-                       }
-                       else if (operation->info.keySize== 4096) {
-                               alg=ID_RSA4096;
-                       }
-                       else {
+                       if (operation->info.keySize == 512) {
+                               alg = ID_RSA512;
+                       } else if (operation->info.keySize == 1024) {
+                               alg = ID_RSA1024;
+                       } else if (operation->info.keySize == 2048) {
+                               alg = ID_RSA2048;
+                       } else if (operation->info.keySize == 3072) {
+                               alg = ID_RSA3072;
+                       } else if (operation->info.keySize == 4096) {
+                               alg = ID_RSA4096;
+                       } else {
                                goto error;
                        }
                        break;
@@ -874,26 +863,21 @@ static int sw_crypto_open(crypto_internal_operation *operation)
                        break;
 
                case TEE_ALG_GENERATE_SECRET_KEY:
-                       alg=ID_X931;
+                       alg = ID_X931;
                        break;
 
                case TEE_ALG_GENERATE_RSA_KEY:
-                       if (operation->info.keySize== 512) {
-                               alg=ID_RSA512;
-                       }
-                       else if (operation->info.keySize== 1024) {
-                               alg=ID_RSA1024;
-                       }
-                       else if (operation->info.keySize== 2048) {
-                               alg=ID_RSA2048;
-                       }
-                       else if (operation->info.keySize== 3072) {
-                               alg=ID_RSA3072;
-                       }
-                       else if (operation->info.keySize== 4096) {
-                               alg=ID_RSA4096;
-                       }
-                       else {
+                       if (operation->info.keySize == 512) {
+                               alg = ID_RSA512;
+                       } else if (operation->info.keySize == 1024) {
+                               alg = ID_RSA1024;
+                       } else if (operation->info.keySize == 2048) {
+                               alg = ID_RSA2048;
+                       } else if (operation->info.keySize == 3072) {
+                               alg = ID_RSA3072;
+                       } else if (operation->info.keySize == 4096) {
+                               alg = ID_RSA4096;
+                       } else {
                                goto error;
                        }
                        break;
@@ -951,28 +935,28 @@ int crypto_internal_init(crypto_internal_operation *operation, crypto_internal_k
 
 int crypto_internal_update(crypto_internal_operation *operation, unsigned char *src_data, size_t src_len, unsigned char *dst_data, size_t *dst_len)
 {
-       unsigned char* in_data=NULL;
-       unsigned char* out_data=NULL;
-       unsigned int in_size=0;
-       unsigned int out_size=0;
-       unsigned int num=0;
-       unsigned int processing_len=0;
-       unsigned int total_processing_len=0;
+       unsigned char* in_data = NULL;
+       unsigned char* out_data = NULL;
+       unsigned int in_size = 0;
+       unsigned int out_size = 0;
+       unsigned int num = 0;
+       unsigned int processing_len = 0;
+       unsigned int total_processing_len = 0;
        int (*crypto_update_engine)(crypto_internal_operation *, unsigned char *, unsigned int, unsigned char *, unsigned int*);
 
-       crypto_update_engine=sw_crypto_ioctl_update;
+       crypto_update_engine = sw_crypto_ioctl_update;
 
        if(src_data) {
-               in_data=(unsigned char*)src_data;
+               in_data = (unsigned char*)src_data;
        }
        if(dst_data) {
-               out_data=(unsigned char*)dst_data;
+               out_data = (unsigned char*)dst_data;
        }
        if(src_len) {
-               in_size=(unsigned int)src_len;
+               in_size = (unsigned int)src_len;
        }
        if(dst_len) {
-               out_size=(unsigned int)*dst_len;
+               out_size = (unsigned int)*dst_len;
        }
 
        CRYPTO_INTERNAL_LOG("--------------------------------------------------------------");
@@ -984,8 +968,7 @@ int crypto_internal_update(crypto_internal_operation *operation, unsigned char *
                {
                        if (in_size < (size_t)(operation->block_len - operation->data_len)) {
                                num = in_size;
-                       }
-                       else {
+                       } else {
                                num = (size_t)(operation->block_len - operation->data_len);
                        }
 
@@ -1035,15 +1018,12 @@ int crypto_internal_update(crypto_internal_operation *operation, unsigned char *
                                operation->data_len = remaining_number_of_bytes;
                        }
                }
-       }
-       else if(operation->info.operationClass == TEE_OPERATION_MAC || operation->info.operationClass == TEE_OPERATION_DIGEST)
-       {
+       } else if (operation->info.operationClass == TEE_OPERATION_MAC || operation->info.operationClass == TEE_OPERATION_DIGEST) {
                if (operation->data_len != 0)
                {
                        if (in_size < (size_t)(operation->block_len - operation->data_len)) {
                                num = in_size;
-                       }
-                       else {
+                       } else {
                                num = (size_t)(operation->block_len - operation->data_len);
                        }
 
@@ -1092,9 +1072,7 @@ int crypto_internal_update(crypto_internal_operation *operation, unsigned char *
                                in_size -= remaining_number_of_bytes;
                        }
                }
-       }
-       else
-       {
+       } else {
                if(crypto_update_engine(operation, in_data, in_size, out_data, &out_size)) {
                        goto error;
                }
@@ -1112,30 +1090,30 @@ error:
 
 int crypto_internal_final(crypto_internal_operation *operation, unsigned char *src_data, size_t src_len, unsigned char *dst_data, size_t *dst_len)
 {
-       unsigned char* in_data=NULL;
-       unsigned char* out_data=NULL;
-       unsigned int in_size=0;
-       unsigned int out_size=0;
-       unsigned int num=0;
-       unsigned int processing_len=0;
-       unsigned int total_processing_len=0;
+       unsigned char* in_data = NULL;
+       unsigned char* out_data = NULL;
+       unsigned int in_size = 0;
+       unsigned int out_size = 0;
+       unsigned int num = 0;
+       unsigned int processing_len = 0;
+       unsigned int total_processing_len = 0;
        int (*crypto_update_engine)(crypto_internal_operation *, unsigned char *, unsigned int, unsigned char *, unsigned int*);
        int (*crypto_final_engine)(crypto_internal_operation *, unsigned char *, unsigned int, unsigned char *, unsigned int*);
 
-       crypto_update_engine=sw_crypto_ioctl_update;
-       crypto_final_engine=sw_crypto_ioctl_final;
+       crypto_update_engine = sw_crypto_ioctl_update;
+       crypto_final_engine = sw_crypto_ioctl_final;
 
        if(src_data) {
-               in_data=(unsigned char*)src_data;
+               in_data = (unsigned char*)src_data;
        }
        if(dst_data) {
-               out_data=(unsigned char*)dst_data;
+               out_data = (unsigned char*)dst_data;
        }
        if(src_len) {
-               in_size=(unsigned int)src_len;
+               in_size = (unsigned int)src_len;
        }
        if(dst_len) {
-               out_size=(unsigned int)*dst_len;
+               out_size = (unsigned int)*dst_len;
        }
 
        CRYPTO_INTERNAL_LOG("--------------------------------------------------------------");
@@ -1147,8 +1125,7 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
                {
                        if (in_size < (size_t)(operation->block_len - operation->data_len)) {
                                num = in_size;
-                       }
-                       else {
+                       } else {
                                num = (size_t)(operation->block_len - operation->data_len);
                        }
 
@@ -1200,15 +1177,15 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
                                out_data = (unsigned char*)((unsigned long) out_data + processing_len);
                        }
 
-                       if(operation->info.mode==TEE_MODE_ENCRYPT)
+                       if (operation->info.mode == TEE_MODE_ENCRYPT)
                        {
                                unsigned int pad_byte;
                                size_t should_be_processed_of_pad_bytes = 0;
 
                                /* NOPAD */
-                               if (operation->info.algorithm==TEE_ALG_AES_ECB_NOPAD ||operation->info.algorithm==TEE_ALG_AES_CBC_NOPAD||
-                                       operation->info.algorithm==TEE_ALG_DES_ECB_NOPAD ||operation->info.algorithm==TEE_ALG_DES_CBC_NOPAD||
-                                       operation->info.algorithm==TEE_ALG_DES3_ECB_NOPAD || operation->info.algorithm==TEE_ALG_DES3_CBC_NOPAD)
+                               if (operation->info.algorithm == TEE_ALG_AES_ECB_NOPAD || operation->info.algorithm == TEE_ALG_AES_CBC_NOPAD ||
+                                       operation->info.algorithm == TEE_ALG_DES_ECB_NOPAD || operation->info.algorithm == TEE_ALG_DES_CBC_NOPAD ||
+                                       operation->info.algorithm == TEE_ALG_DES3_ECB_NOPAD || operation->info.algorithm == TEE_ALG_DES3_CBC_NOPAD)
                                {
                                        CRYPTO_INTERNAL_LOG("ENC NOPAD : Ignore remaining_number_of_bytes=%zd !!", remaining_number_of_bytes);
                                        goto exit;
@@ -1223,32 +1200,24 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
 
                                pad_byte = operation->block_len - remaining_number_of_bytes;
 
-                               if (operation->info.algorithm==TEE_ALG_AES_ECB_PKCS5 ||operation->info.algorithm==TEE_ALG_AES_ECB_PKCS7 ||
-                                       operation->info.algorithm==TEE_ALG_AES_CBC_PKCS5 ||operation->info.algorithm==TEE_ALG_AES_CBC_PKCS7)
-                               {
+                               if (operation->info.algorithm == TEE_ALG_AES_ECB_PKCS5 || operation->info.algorithm == TEE_ALG_AES_ECB_PKCS7 ||
+                                       operation->info.algorithm == TEE_ALG_AES_CBC_PKCS5 || operation->info.algorithm == TEE_ALG_AES_CBC_PKCS7) {
                                        should_be_processed_of_pad_bytes = operation->block_len;
 
                                        memset(operation->data + operation->data_len, pad_byte, pad_byte);
                                        CRYPTO_INTERNAL_LOG("ENC PKCS : op->data=%2X%2X%2X%2X%2X%2X%2X%2X", operation->data[0], operation->data[1], operation->data[2], operation->data[3], operation->data[4], operation->data[5], operation->data[6], operation->data[7]);
                                        CRYPTO_INTERNAL_LOG("ENC PKCS : op->data=%2X%2X%2X%2X%2X%2X%2X%2X", operation->data[8], operation->data[9], operation->data[10], operation->data[11], operation->data[12], operation->data[13], operation->data[14], operation->data[15]);
-                               }
-                               else if(operation->info.algorithm==TEE_ALG_AES_ECB_ISO9797_M1 ||operation->info.algorithm==TEE_ALG_AES_CBC_ISO9797_M1)
-                               {
-                                       if(pad_byte != 0 && (operation->block_len != pad_byte))
-                                       {
+                               } else if (operation->info.algorithm == TEE_ALG_AES_ECB_ISO9797_M1 || operation->info.algorithm == TEE_ALG_AES_CBC_ISO9797_M1) {
+                                       if (pad_byte != 0 && (operation->block_len != pad_byte)) {
                                                should_be_processed_of_pad_bytes = operation->block_len;
 
                                                memset(operation->data + operation->data_len, 0x00, pad_byte);
                                                CRYPTO_INTERNAL_LOG("ENC ZERO : op->data=%2X%2X%2X%2X%2X%2X%2X%2X", operation->data[0], operation->data[1], operation->data[2], operation->data[3], operation->data[4], operation->data[5], operation->data[6], operation->data[7]);
                                                CRYPTO_INTERNAL_LOG("ENC ZERO : op->data=%2X%2X%2X%2X%2X%2X%2X%2X", operation->data[8], operation->data[9], operation->data[10], operation->data[11], operation->data[12], operation->data[13], operation->data[14], operation->data[15]);
-                                       }
-                                       else
-                                       {
+                                       } else {
                                                should_be_processed_of_pad_bytes = 0;
                                        }
-                               }
-                               else if (operation->info.algorithm==TEE_ALG_AES_ECB_ISO9797_M2 || operation->info.algorithm==TEE_ALG_AES_CBC_ISO9797_M2)
-                               {
+                               } else if (operation->info.algorithm == TEE_ALG_AES_ECB_ISO9797_M2 || operation->info.algorithm == TEE_ALG_AES_CBC_ISO9797_M2) {
                                        should_be_processed_of_pad_bytes = operation->block_len;
 
                                        memset(operation->data + operation->data_len, 0x00, pad_byte);
@@ -1258,9 +1227,7 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
                                        operation->data[operation->data_len] = 0x80;
                                        CRYPTO_INTERNAL_LOG("ENC ISO9797 : op->data=%2X%2X%2X%2X%2X%2X%2X%2X", operation->data[0], operation->data[1], operation->data[2], operation->data[3], operation->data[4], operation->data[5], operation->data[6], operation->data[7]);
                                        CRYPTO_INTERNAL_LOG("ENC ISO9797 : op->data=%2X%2X%2X%2X%2X%2X%2X%2X", operation->data[8], operation->data[9], operation->data[10], operation->data[11], operation->data[12], operation->data[13], operation->data[14], operation->data[15]);
-                               }
-                               else if(operation->info.algorithm==TEE_ALG_AES_CTR || operation->info.algorithm==TEE_ALG_AES_CTR_NOPAD)
-                               {
+                               } else if (operation->info.algorithm == TEE_ALG_AES_CTR || operation->info.algorithm == TEE_ALG_AES_CTR_NOPAD) {
                                        should_be_processed_of_pad_bytes = remaining_number_of_bytes;
                                }
 
@@ -1269,23 +1236,18 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
                                }
 
                                total_processing_len += processing_len;
-                       }
-                       else if(operation->info.mode==TEE_MODE_DECRYPT) {
+                       } else if (operation->info.mode == TEE_MODE_DECRYPT) {
                                unsigned char * pad = out_data;
-                               unsigned int npad=0;
+                               unsigned int npad = 0;
 
-                               if (operation->info.algorithm==TEE_ALG_AES_ECB_NOPAD || operation->info.algorithm==TEE_ALG_AES_CBC_NOPAD||
-                                       operation->info.algorithm==TEE_ALG_DES_ECB_NOPAD || operation->info.algorithm==TEE_ALG_DES_CBC_NOPAD||
-                                       operation->info.algorithm==TEE_ALG_DES3_ECB_NOPAD || operation->info.algorithm==TEE_ALG_DES3_CBC_NOPAD)
-                               {
+                               if (operation->info.algorithm == TEE_ALG_AES_ECB_NOPAD || operation->info.algorithm == TEE_ALG_AES_CBC_NOPAD ||
+                                       operation->info.algorithm == TEE_ALG_DES_ECB_NOPAD || operation->info.algorithm == TEE_ALG_DES_CBC_NOPAD ||
+                                       operation->info.algorithm == TEE_ALG_DES3_ECB_NOPAD || operation->info.algorithm == TEE_ALG_DES3_CBC_NOPAD) {
                                        CRYPTO_INTERNAL_LOG("DEC NOPAD : Ignore remaining_number_of_bytes=%zd !!", remaining_number_of_bytes);
                                        goto exit;
-                               }
                                /* PAD */
-                               else if (
-                                       operation->info.algorithm==TEE_ALG_AES_ECB_PKCS5 ||operation->info.algorithm==TEE_ALG_AES_ECB_PKCS7 ||
-                                       operation->info.algorithm==TEE_ALG_AES_CBC_PKCS5 ||operation->info.algorithm==TEE_ALG_AES_CBC_PKCS7)
-                               {
+                               } else if (operation->info.algorithm == TEE_ALG_AES_ECB_PKCS5 || operation->info.algorithm == TEE_ALG_AES_ECB_PKCS7 ||
+                                                  operation->info.algorithm == TEE_ALG_AES_CBC_PKCS5 || operation->info.algorithm == TEE_ALG_AES_CBC_PKCS7) {
                                        memcpy(operation->data, pad-operation->block_len, operation->block_len);
                                        CRYPTO_INTERNAL_LOG("DEC PKCS : op->data=%2X%2X%2X%2X%2X%2X%2X%2X", operation->data[0], operation->data[1], operation->data[2], operation->data[3], operation->data[4], operation->data[5], operation->data[6], operation->data[7]);
                                        CRYPTO_INTERNAL_LOG("DEC PKCS : op->data=%2X%2X%2X%2X%2X%2X%2X%2X", operation->data[8], operation->data[9], operation->data[10], operation->data[11], operation->data[12], operation->data[13], operation->data[14], operation->data[15]);
@@ -1293,8 +1255,7 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
                                        pad--; //last byte
                                        npad = *pad;
 
-                                       if (npad <= operation->block_len) // can't be more than block length
-                                       {
+                                       if (npad <= operation->block_len) { // can't be more than block length
                                                unsigned int i;
                                                int ok = 1;
                                                for(i = 0; i < npad; i++, pad--) {
@@ -1308,14 +1269,10 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
                                                        total_processing_len -= npad;        // padding OK. Othewise padding will not be removed
                                                }
                                        }
-                               }
-                               else if(operation->info.algorithm==TEE_ALG_AES_ECB_ISO9797_M1 ||operation->info.algorithm==TEE_ALG_AES_CBC_ISO9797_M1)
-                               {
+                               } else if (operation->info.algorithm == TEE_ALG_AES_ECB_ISO9797_M1 ||operation->info.algorithm == TEE_ALG_AES_CBC_ISO9797_M1) {
                                        CRYPTO_INTERNAL_LOG("DEC ISO9797 M1 : Ignore remaining_number_of_bytes=%zd !!", remaining_number_of_bytes);
                                        goto exit;
-                               }
-                               else if (operation->info.algorithm==TEE_ALG_AES_ECB_ISO9797_M2 || operation->info.algorithm==TEE_ALG_AES_CBC_ISO9797_M2)
-                               {
+                               } else if (operation->info.algorithm == TEE_ALG_AES_ECB_ISO9797_M2 || operation->info.algorithm == TEE_ALG_AES_CBC_ISO9797_M2) {
                                        memcpy(operation->data, pad-operation->block_len, operation->block_len);
                                        CRYPTO_INTERNAL_LOG("DEC ISO9797 M2 : op->data=%2X%2X%2X%2X%2X%2X%2X%2X", operation->data[0], operation->data[1], operation->data[2], operation->data[3], operation->data[4], operation->data[5], operation->data[6], operation->data[7]);
                                        CRYPTO_INTERNAL_LOG("DEC ISO9797 M2 : op->data=%2X%2X%2X%2X%2X%2X%2X%2X", operation->data[8], operation->data[9], operation->data[10], operation->data[11], operation->data[12], operation->data[13], operation->data[14], operation->data[15]);
@@ -1323,20 +1280,17 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
                                        pad--; //last byte
                                        npad = 0;
 
-                                       if (*pad==0x00) // remove 0s
-                                               for(; npad < operation->block_len-1 && *pad==0x00; npad++,pad--);
+                                       if (*pad == 0x00) // remove 0s
+                                               for (; npad < operation->block_len-1 && *pad == 0x00; npad++, pad--);
 
-                                       if (*pad==0x80) { // correct M2 padding
+                                       if (*pad == 0x80) { // correct M2 padding
                                                npad++;        // remove 1st PAD byte 0x80
-                                       }
-                                       else { // M2 padding error
+                                       } else { // M2 padding error
                                                npad = 0;        // don't remove any padding
                                        }
 
                                        total_processing_len -= npad;
-                               }
-                               else if(operation->info.algorithm==TEE_ALG_AES_CTR || operation->info.algorithm==TEE_ALG_AES_CTR_NOPAD)
-                               {
+                               } else if (operation->info.algorithm == TEE_ALG_AES_CTR || operation->info.algorithm == TEE_ALG_AES_CTR_NOPAD) {
                                        memcpy(operation->data, in_data, remaining_number_of_bytes);
                                        operation->data_len += remaining_number_of_bytes;
 
@@ -1345,26 +1299,20 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
                                        }
                                        total_processing_len += remaining_number_of_bytes;
                                }
-                       }
-                       else
-                       {
+                       } else {
                                goto error;
                        }
                }
-       }
-       else if(operation->info.operationClass == TEE_OPERATION_MAC || operation->info.operationClass == TEE_OPERATION_DIGEST)
-       {
-               if (operation->data_len != 0)
-               {
+       } else if (operation->info.operationClass == TEE_OPERATION_MAC || operation->info.operationClass == TEE_OPERATION_DIGEST) {
+               if (operation->data_len != 0) {
                        if (in_size < (size_t)(operation->block_len - operation->data_len)) {
                                num = in_size;
-                       }
-                       else {
+                       } else {
                                num = (size_t)(operation->block_len - operation->data_len);
                        }
 
                        CRYPTO_INTERNAL_LOG("num=%d in_size=%d processed=%d", num, in_size, total_processing_len);
-                       if(num != 0) {
+                       if (num != 0) {
                                memcpy(operation->data + operation->data_len, in_data, num);
 
                                operation->data_len += num;
@@ -1372,8 +1320,7 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
                                in_data = (unsigned char*)((unsigned long)in_data + num);
 
                                /* accumulated data is full */
-                               if (operation->data_len == operation->block_len)
-                               {
+                               if (operation->data_len == operation->block_len) {
                                        if (crypto_update_engine(operation, operation->data, operation->data_len, NULL, NULL)) {
                                                goto error;
                                        }
@@ -1389,17 +1336,14 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
                        CRYPTO_INTERNAL_LOG("num=%d in_size=%d op->data_len=%d", num, in_size, operation->data_len);
                }
 
-               if (in_size != 0)
-               {
-                       if(crypto_final_engine(operation, in_data, in_size, out_data, &out_size)) {
+               if (in_size != 0) {
+                       if (crypto_final_engine(operation, in_data, in_size, out_data, &out_size)) {
                                goto error;
                        }
                        total_processing_len += in_size;
                }
-       }
-       else
-       {
-               if(crypto_final_engine(operation, in_data, in_size, out_data, &out_size)) {
+       } else {
+               if (crypto_final_engine(operation, in_data, in_size, out_data, &out_size)) {
                        goto error;
                }
                total_processing_len += in_size;
@@ -1407,22 +1351,17 @@ int crypto_internal_final(crypto_internal_operation *operation, unsigned char *s
 exit:
        CRYPTO_INTERNAL_LOG("in_size=%d out_size=%d processed=%d", in_size, out_size, total_processing_len);
        CRYPTO_INTERNAL_LOG("--------------------------------------------------------------");
-       if(operation->info.operationClass == TEE_OPERATION_CIPHER && dst_len) {
+       if (operation->info.operationClass == TEE_OPERATION_CIPHER && dst_len) {
                *dst_len = total_processing_len;
-       }
-       else if(operation->info.operationClass == TEE_OPERATION_MAC && dst_len) {
+       } else if (operation->info.operationClass == TEE_OPERATION_MAC && dst_len) {
                *dst_len = out_size;
-       }
-       else if(operation->info.operationClass == TEE_OPERATION_AE && dst_len) {
+       } else if (operation->info.operationClass == TEE_OPERATION_AE && dst_len) {
                *dst_len = total_processing_len;
-       }
-       else if(operation->info.operationClass == TEE_OPERATION_DIGEST && dst_len) {
+       } else if (operation->info.operationClass == TEE_OPERATION_DIGEST && dst_len) {
                *dst_len = out_size;
-       }
-       else if(operation->info.operationClass == TEE_OPERATION_ASYMMETRIC_CIPHER && dst_len) {
+       } else if (operation->info.operationClass == TEE_OPERATION_ASYMMETRIC_CIPHER && dst_len) {
                *dst_len = out_size;
-       }
-       else if(operation->info.operationClass == TEE_OPERATION_ASYMMETRIC_SIGNATURE && dst_len) {
+       } else if (operation->info.operationClass == TEE_OPERATION_ASYMMETRIC_SIGNATURE && dst_len) {
                *dst_len = out_size;
        }
        return 0;
@@ -1439,7 +1378,7 @@ TEE_Result TEE_AllocateOperation(TEE_OperationHandle *operation, uint32_t algori
 {
        PERMISSION_CHECK(PERM_CRYPTO);
        crypto_internal_operation * op;
-       TEE_Result rc=TEE_SUCCESS;
+       TEE_Result rc = TEE_SUCCESS;
        uint32_t alg_class = 0;
        uint32_t key_object_type = 0;
        uint32_t digest_len = 0;
@@ -1834,8 +1773,7 @@ TEE_Result TEE_AllocateOperation(TEE_OperationHandle *operation, uint32_t algori
        {
                if (mode == TEE_MODE_ENCRYPT) {
                        op->info.requiredKeyUsage |= TEE_USAGE_VERIFY;
-               }
-               else if (mode == TEE_MODE_DECRYPT) {
+               } else if (mode == TEE_MODE_DECRYPT) {
                        op->info.requiredKeyUsage |= TEE_USAGE_SIGN;
                }
        }
@@ -1845,7 +1783,7 @@ TEE_Result TEE_AllocateOperation(TEE_OperationHandle *operation, uint32_t algori
        }
 
        /* get handle */
-       if (crypto_internal_open(op)!=0) {
+       if (crypto_internal_open(op) != 0) {
                rc = TEE_ERROR_NOT_SUPPORTED;
                goto error;
        }
@@ -1917,7 +1855,7 @@ void TEE_FreeOperation(TEE_OperationHandle operation)
        return;
 }
 
-void TEE_GetOperationInfo( TEE_OperationHandle operation, TEE_OperationInfo* operationInfo)
+void TEE_GetOperationInfo(TEE_OperationHandle operation, TEE_OperationInfo* operationInfo)
 {
        PERMISSION_CHECK_RETURN_VOID(PERM_CRYPTO);
 
@@ -1933,7 +1871,7 @@ void TEE_GetOperationInfo( TEE_OperationHandle operation, TEE_OperationInfo* ope
        operationInfo->requiredKeyUsage = op->info.requiredKeyUsage;
 }
 
-void TEE_ResetOperation( TEE_OperationHandle operation)
+void TEE_ResetOperation(TEE_OperationHandle operation)
 {
        PERMISSION_CHECK_RETURN_VOID(PERM_CRYPTO);
 
@@ -1942,7 +1880,7 @@ void TEE_ResetOperation( TEE_OperationHandle operation)
        return;
 }
 
-TEE_Result TEE_SetOperationKey( TEE_OperationHandle operation, TEE_ObjectHandle key)
+TEE_Result TEE_SetOperationKey(TEE_OperationHandle operation, TEE_ObjectHandle key)
 {
        PERMISSION_CHECK(PERM_CRYPTO);
 
@@ -1951,7 +1889,6 @@ TEE_Result TEE_SetOperationKey( TEE_OperationHandle operation, TEE_ObjectHandle
     {
         LOGE(SSF_LIB, "op->info.operationClass == TEE_OPERATION_DIGEST\n");
         return TEE_ERROR_BAD_PARAMETERS;
-
     };
 
        if (key == TEE_HANDLE_NULL)
@@ -1965,7 +1902,6 @@ TEE_Result TEE_SetOperationKey( TEE_OperationHandle operation, TEE_ObjectHandle
     {
         LOGE(SSF_LIB, "(key->tr.info.objectUsage | ~(op->info.requiredKeyUsage)) != 0xffffffff\n");
         return TEE_ERROR_BAD_PARAMETERS;
-
     };
 
        TEE_CopyObjectAttributes(op->key1, key);
@@ -1974,7 +1910,7 @@ TEE_Result TEE_SetOperationKey( TEE_OperationHandle operation, TEE_ObjectHandle
        return TEE_SUCCESS;
 }
 
-TEE_Result TEE_SetOperationKey2( TEE_OperationHandle operation, TEE_ObjectHandle key1, TEE_ObjectHandle key2)
+TEE_Result TEE_SetOperationKey2(TEE_OperationHandle operation, TEE_ObjectHandle key1, TEE_ObjectHandle key2)
 {
        PERMISSION_CHECK(PERM_CRYPTO);
 
@@ -2016,7 +1952,7 @@ TEE_Result TEE_SetOperationKey2( TEE_OperationHandle operation, TEE_ObjectHandle
 }
 
 
-void TEE_CopyOperation( TEE_OperationHandle dstOperation, TEE_OperationHandle srcOperation)
+void TEE_CopyOperation(TEE_OperationHandle dstOperation, TEE_OperationHandle srcOperation)
 {
        PERMISSION_CHECK_RETURN_VOID(PERM_CRYPTO);
 
@@ -2049,8 +1985,7 @@ void TEE_CopyOperation( TEE_OperationHandle dstOperation, TEE_OperationHandle sr
                if (crypto_internal_open(dstOp) != 0) {
                        CRYPTO_PANIC;
                }
-       }
-       else {
+       } else {
                dstOp->crypto = NULL;
        }
        return;
@@ -2072,7 +2007,7 @@ void TEE_DigestInit(TEE_OperationHandle operation)
        return;
 }
 
-void TEE_DigestUpdate( TEE_OperationHandle operation, const void* chunk, size_t chunkSize)
+void TEE_DigestUpdate(TEE_OperationHandle operation, const void* chunk, size_t chunkSize)
 {
        PERMISSION_CHECK_RETURN_VOID(PERM_CRYPTO);
        crypto_internal_operation * op = (crypto_internal_operation*) operation;
@@ -2092,7 +2027,7 @@ void TEE_DigestUpdate( TEE_OperationHandle operation, const void* chunk, size_t
        return;
 }
 
-TEE_Result TEE_DigestDoFinal( TEE_OperationHandle operation, const void* chunk, size_t chunkLen, void* hash, size_t *hashLen)
+TEE_Result TEE_DigestDoFinal(TEE_OperationHandle operation, const void* chunk, size_t chunkLen, void* hash, size_t *hashLen)
 {
        PERMISSION_CHECK(PERM_CRYPTO);
        crypto_internal_operation * op = (crypto_internal_operation*) operation;
@@ -2113,7 +2048,7 @@ TEE_Result TEE_DigestDoFinal( TEE_OperationHandle operation, const void* chunk,
 }
 
 // Symmetric Cipher Functions
-void TEE_CipherInit( TEE_OperationHandle operation, const void* IV, size_t IVLen)
+void TEE_CipherInit(TEE_OperationHandle operation, const void* IV, size_t IVLen)
 {
        PERMISSION_CHECK_RETURN_VOID(PERM_CRYPTO);
        crypto_internal_operation * op = (crypto_internal_operation*) operation;
@@ -2144,7 +2079,7 @@ void TEE_CipherInit( TEE_OperationHandle operation, const void* IV, size_t IVLen
        return;
 }
 
-TEE_Result TEE_CipherUpdate( TEE_OperationHandle operation, const void* srcData, size_t srcLen, void* destData, size_t *destLen)
+TEE_Result TEE_CipherUpdate(TEE_OperationHandle operation, const void* srcData, size_t srcLen, void* destData, size_t *destLen)
 {
        PERMISSION_CHECK(PERM_CRYPTO);
        crypto_internal_operation * op = (crypto_internal_operation*) operation;
@@ -2164,7 +2099,7 @@ TEE_Result TEE_CipherUpdate( TEE_OperationHandle operation, const void* srcData,
        return TEE_SUCCESS;
 }
 
-TEE_Result TEE_CipherDoFinal( TEE_OperationHandle operation, const void* srcData, size_t srcLen, void* destData, size_t *destLen)
+TEE_Result TEE_CipherDoFinal(TEE_OperationHandle operation, const void* srcData, size_t srcLen, void* destData, size_t *destLen)
 {
        PERMISSION_CHECK(PERM_CRYPTO);
        crypto_internal_operation * op = (crypto_internal_operation*) operation;
@@ -2185,7 +2120,7 @@ TEE_Result TEE_CipherDoFinal( TEE_OperationHandle operation, const void* srcData
 }
 
 // MAC Functions
-void TEE_MACInit( TEE_OperationHandle operation, const void* IV, size_t IVLen)
+void TEE_MACInit(TEE_OperationHandle operation, const void* IV, size_t IVLen)
 {
        PERMISSION_CHECK_RETURN_VOID(PERM_CRYPTO);
        crypto_internal_operation * op = (crypto_internal_operation*) operation;
@@ -2216,7 +2151,7 @@ void TEE_MACInit( TEE_OperationHandle operation, const void* IV, size_t IVLen)
        return;
 }
 
-void TEE_MACUpdate( TEE_OperationHandle operation, const void* chunk, size_t chunkSize)
+void TEE_MACUpdate(TEE_OperationHandle operation, const void* chunk, size_t chunkSize)
 {
        PERMISSION_CHECK_RETURN_VOID(PERM_CRYPTO);
        crypto_internal_operation * op = (crypto_internal_operation*) operation;
@@ -2236,7 +2171,7 @@ void TEE_MACUpdate( TEE_OperationHandle operation, const void* chunk, size_t chu
        return;
 }
 
-TEE_Result TEE_MACComputeFinal( TEE_OperationHandle operation, const void* message, size_t messageLen, void* mac, size_t *macLen)
+TEE_Result TEE_MACComputeFinal(TEE_OperationHandle operation, const void* message, size_t messageLen, void* mac, size_t *macLen)
 {
        PERMISSION_CHECK(PERM_CRYPTO);
        crypto_internal_operation * op = (crypto_internal_operation*) operation;
@@ -2256,7 +2191,7 @@ TEE_Result TEE_MACComputeFinal( TEE_OperationHandle operation, const void* messa
        return TEE_SUCCESS;
 }
 
-TEE_Result TEE_MACCompareFinal( TEE_OperationHandle operation, void* message, size_t messageLen, void* mac, size_t *macLen)
+TEE_Result TEE_MACCompareFinal(TEE_OperationHandle operation, void* message, size_t messageLen, void* mac, size_t *macLen)
 {
        PERMISSION_CHECK(PERM_CRYPTO);
        crypto_internal_operation * op = (crypto_internal_operation*) operation;
@@ -2476,7 +2411,7 @@ TEE_Result TEE_AEDecryptFinal(TEE_OperationHandle operation, void* srcData, size
        return ret;
 }
 
-TEE_Result TEE_AsymmetricEncrypt( TEE_OperationHandle operation,const TEE_Attribute* params, uint32_t paramCount, const void* srcData, size_t srcLen, void* destData, size_t *destLen)
+TEE_Result TEE_AsymmetricEncrypt(TEE_OperationHandle operation, const TEE_Attribute* params, uint32_t paramCount, const void* srcData, size_t srcLen, void* destData, size_t *destLen)
 {
        PERMISSION_CHECK(PERM_CRYPTO);
        (void)params;
@@ -2521,7 +2456,7 @@ TEE_Result TEE_AsymmetricEncrypt( TEE_OperationHandle operation,const TEE_Attrib
        return TEE_SUCCESS;
 }
 
-TEE_Result TEE_AsymmetricDecrypt( TEE_OperationHandle operation, const TEE_Attribute* params, uint32_t paramCount, const void* srcData, size_t srcLen, void* destData, size_t *destLen)
+TEE_Result TEE_AsymmetricDecrypt(TEE_OperationHandle operation, const TEE_Attribute* params, uint32_t paramCount, const void* srcData, size_t srcLen, void* destData, size_t *destLen)
 {
        PERMISSION_CHECK(PERM_CRYPTO);
 
@@ -2753,7 +2688,7 @@ void TEE_GenerateRandom(void* randomBuffer, size_t randomBufferLen)
        key.secret.buffer = random;
        key.secret.size = random_len*8;
 
-       if (crypto_internal_open(&op)!=0) {
+       if (crypto_internal_open(&op) != 0) {
                CRYPTO_PANIC;
        }
        if (crypto_internal_init(&op, &key, NULL, 0)) {
index b9d2905..d9b17f7 100644 (file)
@@ -47,7 +47,6 @@ extern "C"{
  * Initializes SSF for use by TA
  */
 __attribute__((constructor)) void initializeSSF() {
-
        socketSimulatorDaemonFD = connecttoServer();
        assert(socketSimulatorDaemonFD != -1);
        LOGD(SIM_DAEMON, "Done");}
index cfe01da..1b71c8e 100644 (file)
@@ -33,8 +33,8 @@
 /*-----------------------------------------------------------------------------
  *  MACROS
  *-----------------------------------------------------------------------------*/
-#define __FREE(buf) if(buf) {OsaFree(buf); buf = NULL;}
-#define FREE_PO(po) if(po) {clean_po_file(po);OsaFree(po); po = NULL;}
+#define __FREE(buf) if (buf) {OsaFree(buf); buf = NULL;}
+#define FREE_PO(po) if (po) {clean_po_file(po);OsaFree(po); po = NULL;}
 
 #define PO_INTERNAL_MODULE_NAME "po_file"
 #define PO_STAT_INTERNAL_MODULE_NAME "po_stat"
@@ -407,7 +407,7 @@ TEE_Result create_po(persistent_object* po, TransientObject* attr,
                return TEE_ERROR_GENERIC;
        }
        // update po share info
-       if (0 != update_share_info(&po->share_info, po->attr.info.handleFlags,0, 1, po)) {
+       if (0 != update_share_info(&po->share_info, po->attr.info.handleFlags, 0, 1, po)) {
                return TEE_ERROR_GENERIC;
        }
        // add to po list
@@ -1178,7 +1178,7 @@ void convert_TA_UUID(char* uuid, TEE_UUID TA_UUID) {
        tmp += 5;
        uint32_t i = 0;
        for (; i < 2; ++i) {
-               snprintf(tmp, 3,"%02x", TA_UUID.clockSeqAndNode[i]);
+               snprintf(tmp, 3, "%02x", TA_UUID.clockSeqAndNode[i]);
                tmp += 2;
        }
        tmp[0] = '-';
index cfb3396..5b66369 100644 (file)
@@ -48,11 +48,11 @@ extern TEE_UUID ssf_sharedthisTAUUID;
         } else if (type == TEEC_NONE) { \
         } else { \
             int getOffset = 0; \
-            if(params[i].memref.memid == 0) { \
+            if (params[i].memref.memid == 0) { \
                        params[i].memref.memid = getSharedMemoryShmID(params[i].memref.buffer); \
             } else { \
                 char* getAdd = getSharedMemoryAddress(params[i].memref.memid); \
-                if(getAdd != 0) \
+                if (getAdd != 0) \
                            getOffset = (char*)params[i].memref.buffer - getAdd; \
             } \
             data.operation.params[i].mem.offset = getOffset; \
@@ -132,7 +132,6 @@ TEE_Result TEE_OpenTASession(const TEE_UUID* destination,
 }
 
 void TEE_CloseTASession(TEE_TASessionHandle session) {
-
        IntTACloseSessionData data;
        data.session = *(uint32_t*)session;
        pthread_mutex_lock(&socketLock);