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
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
&& ((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
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
&& ((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
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
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
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
&& ((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
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
&& ((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
propertyEnumHandleSet.erase(it);\r
delete enumeratorHandle->property;\r
delete enumeratorHandle;\r
- }\r
- else {\r
+ } else {\r
TEE_Panic(0);\r
}\r
}\r
}\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
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
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
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
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
// 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
if (currentItr != propertiesMap.end()) {\r
pv = currentItr->second;\r
return true;\r
- } else return false;\r
+ }\r
+ else return false;\r
}\r
\r
/**\r
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
* @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
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
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
* @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: {
}
MakeCommand::~MakeCommand() {
-
}
/**
*
*/
int MakeCommand::getCommandPayloadSize(SIM_COMMAND command) {
-
int size = -1;
switch (command) {
case CREATE:
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;
}
{
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);
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
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!");
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.");
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);
}
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();
}
* @return
*/
int main(int argc, char* argv[]) {
-
if (argc < 2) {
LOGE(TEE_STUB, "Invalid arguments to TEE Stub");
}
TEE_ERROR_CERT_VERIFICATION = 0xFFFF6003,
TEE_RESULT_NOT_READY = 0xFFFF0FFF
-
} TEE_Error_Codes;
#define TEE_HANDLE_NULL 0
} 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)
uint32_t operationID;
TEE_Result returnValue;
uint32_t returnOrigin;
-
} RequestTACancelData;
#endif /* __TEE_SIM_COMMAND_H__ */
typedef struct {
uint32_t session;
-
} IntTACloseSessionData;
typedef struct {
#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
#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 */
* 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__)
*/
CommandBase(TEEContext *TEECtx) :
pTEECtx(TEECtx) {
-
}
/**
* Command Base Execute for commands received from TEECLib.
CommandInvokeCommand(InvokeCommandData data, TEEContext *TEECtx);
void execute();
virtual ~CommandInvokeCommand();
-
};
#endif /* COMMANDINVOKECOMMAND_H_ */
CommandInvokeTACommand(IntTAInvokeCommandData data, TEEContext *TEECtx);
void execute();
virtual ~CommandInvokeTACommand();
-
};
#endif /* COMMANDINVOKETACOMMAND_H_ */
CommandPanic(IntTAPanicData data, TEEContext *TEECtx);
void execute();
virtual ~CommandPanic();
-
};
#endif /* COMMANDPANIC_H_ */
CommandRegSharedMem(RegSharedMemData data, TEEContext *TEECtx);
void execute();
virtual ~CommandRegSharedMem();
-
};
#endif /* COMMANDREGSHAREDMEM_H_ */
CommandRelSharedMem(RelSharedMemData data, TEEContext *TEECtx);
void execute();
virtual ~CommandRelSharedMem();
-
};
#endif /* COMMANDRELSHAREDMEM_H_ */
CommandReqCancellation(ReqCancellationData data, TEEContext *TEECtx);
void execute();
virtual ~CommandReqCancellation();
-
};
#endif /* COMMANDREQCANCELLATION_H_ */
std::map<uint32_t, ISession*> *sessionMap);
void execute();
virtual ~ResCommandInvokeCommand();
-
};
#endif /* RESCOMMANDINVOKECOMMAND_H_ */
std::map<uint32_t, ISession*> *sessionMap);
void execute();
virtual ~ResCommandReqCancellation();
-
};
#endif /* RESCOMMANDREQCANCELLATION_H_ */
}
CommandCloseSession::~CommandCloseSession() {
-
}
}
CommandCloseTASession::~CommandCloseTASession() {
-
}
}
CommandInvokeCommand::~CommandInvokeCommand() {
-
}
}
CommandInvokeTACommand::~CommandInvokeTACommand() {
-
}
* @param none
*/
CommandOpenTASession::~CommandOpenTASession() {
-
}
void CommandOpenTASession::execute() {
}
MakeCommand::~MakeCommand() {
-
}
/**
*
*/
uint32_t MakeCommand::getDataSize(TEE_CMD command) {
-
uint32_t size = -1;
switch (command) {
case INITIALIZE_CONTEXT:
#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;
}
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);
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
*/
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)),
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",
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;
LOGE(SIM_DAEMON, "Destroy sendRequestToTA FAILED");
(session->getTAInstance())->killTA();
}
- } else break;
+ } else {
+ break;
+ }
}
TAFact->mTAInstanceMap.erase(itTAMap);
break;
}
ResCommandCloseSession::~ResCommandCloseSession() {
-
}
}
ResCommandInvokeCommand::~ResCommandInvokeCommand() {
-
}
}
ResMakeCommand::~ResMakeCommand() {
-
}
/**
*
*/
uint32_t ResMakeCommand::getDataSize(SIM_COMMAND command) {
-
uint32_t size = -1;
switch (command) {
case CREATE:
std::string SecurityContext::getCaFullPathFromPkgId(char* pkgid) {
-
std::string path;
tzplatform_variable ids[3] = {TZ_USER_APP, TZ_SYS_RW_APP, TZ_SYS_RO_APP};
* @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");
* 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");
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);
* Class definitions
*-----------------------------------------------------------------------------*/
class TABinaryManager {
-
private:
static TABinaryManager *instance;
std::string base64_chars;
*-----------------------------------------------------------------------------*/
TAManifest::TAManifest() {
-
}
bool TAManifest::processXML(const string &xmlManifestPath) {
-
bool ret = false;
// Open file
std::ifstream xmlfile(xmlManifestPath.c_str());
.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();
properties.extension.launchMode = string(propertiesExtension->first_attribute("launchMode")->value());
}
-
}
// 2. POLICY
node = doc.first_node("manifest")->first_node("policy");
policy.usesPermission.push_back(string(childnode->first_attribute("name")->value()));
}
}
-
}
// 3. TA ENC
node = doc.first_node("manifest")->first_node("taEncryption");
std::cout << "[SIM_DAEMON] information.description: "
<< information.description << endl;
std::cout << "[SIM_DAEMON] information.terms: " << information.terms << endl;
-
}
TAManifest::~TAManifest() {
-
}
*-----------------------------------------------------------------------------*/
class TAManifest {
-
public:
StructProperties properties;
StructPolicy policy;
bool processXML(const string &xmlManifest);
void printProcessedData() const;
virtual ~TAManifest();
-
};
#endif /* TAMANIFEST_H_ */
* Member functions
*-----------------------------------------------------------------------------*/
TAUnpack::TAUnpack() {
-
}
TAUnpack* TAUnpack::getInstance() {
}
void TAUnpack::fixHeaderEndianness(TAPackageHeaderV2* header) {
-
char* headerptr = (char*)header;
for (unsigned int i = 0; i < sizeof(TAPackageHeaderV2); i +=
sizeof(unsigned int)) {
headerptr[i + 3] = temp1;
headerptr[i + 2] = temp2;
}
-
}
/**
}
// Execute image
case 3: {
-
break;
}
// Test TA Binary Manager
break;
}
-
}
}
} catch (std::exception& e) {
* instance and return the instance else return the already created instance.
*/
TAFactory* TAFactory::getInstance() {
-
LOGD(SIM_DAEMON, "Entry");
pthread_mutex_lock(&instLock);
* with it
*/
TAInstancePtr TAFactory::getTAInstance(TEEC_UUID uuid, ISession* session) {
-
TAInstancePtr TAInst;
bool result;
LOGD(SIM_DAEMON, "Entry");
// 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))
* @param TAUUID TA UUID in string form
*/
bool TAFactory::checkIfTARunning(string TAUUID) {
-
LOGD(SIM_DAEMON, "Entry");
bool result = false;
*/
TAInstancePtr TAFactory::createUninitalizedTAInstance(string TAUUID,
ISession* session) {
-
LOGD(SIM_DAEMON, "Entry");
// Initialize PID to -1
* @param pid pointer to the PID of the launched TA
*/
void* TAFactory::waitForChild(void *pid) {
-
pid_t PID = *(pid_t*)pid;
int32_t childStatus;
* @param pid pointer to the PID of the exited TA
*/
void TAFactory::cleanupTAInstance(pid_t PID) {
-
LOGD(SIM_DAEMON, "Entry");
TAInstancePtr Inst;
* @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)
* @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;
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);
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",
* 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 */
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
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?
* @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");
* 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;
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;
// 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);
}
*/
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
* @param data data sent from TEECLib for InitContext
*/
TEEC_Result TEEContext::initContext(InitContextData* data) {
-
TEEC_Result result = TEEC_ERROR_GENERIC;
LOGD(SIM_DAEMON, "Entry");
* @param data data sent from TEECLib for FinalizeContext
*/
void TEEContext::finContext(FinalizeContextData data) {
-
TEEC_Result result = TEEC_ERROR_GENERIC;
LOGD(SIM_DAEMON, "Entry");
* @param data data sent from TEECLib for OpenSession
*/
TEEC_Result TEEContext::openSession(OpenSessionData data) {
-
TEEC_Result result = TEEC_ERROR_GENERIC;
LOGD(SIM_DAEMON, "Entry");
* @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;
* @param data data sent from TEECLib for RequestCancellation
*/
void TEEContext::reqCancel(ReqCancellationData data) {
-
TEEC_Result result = TEEC_ERROR_GENERIC;
LOGD(SIM_DAEMON, "Entry");
* @param data data sent from TEECLib for CloseSession
*/
TEEC_Result TEEContext::closeSession(CloseSessionData data) {
-
TEEC_Result result = TEEC_ERROR_GENERIC;
LOGD(SIM_DAEMON, "Entry");
* @param data data sent from SSFLib for OpenTASession
*/
TEEC_Result TEEContext::openTASession(IntTAOpenSessionData data) {
-
TEEC_Result result = TEEC_ERROR_GENERIC;
LOGD(SIM_DAEMON, "Entry");
* @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");
* @param data data sent from SSFLib for InvokeTACommand
*/
TEEC_Result TEEContext::invokeTACommand(IntTAInvokeCommandData data) {
-
TEEC_Result result = TEEC_ERROR_GENERIC;
LOGD(SIM_DAEMON, "Entry");
* @param data data sent from TEECLib for RegisterSharedMemory
*/
TEEC_Result TEEContext::registerSharedMemory(RegSharedMemData data) {
-
TEEC_Result result = TEEC_ERROR_GENERIC;
LOGD(SIM_DAEMON, "Entry");
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,
cc_u8* PUB_X_Data, cc_u32 PUB_X_Len,
cc_u8* PUB_Y_Data, cc_u32 PUB_Y_Len
);
-
} CryptoCoreContainer;
#ifdef __cplusplus
#endif
-/***************************** End of File *****************************/
\ No newline at end of file
+/***************************** End of File *****************************/
cc_u32 t;
cc_u32 endian; //0 if little endian, 1 if bigendian
-
} SDRM_SNOW2Context;
////////////////////////////////////////////////////////////////////////////
#endif
-/***************************** End of File *****************************/
\ No newline at end of file
+/***************************** End of File *****************************/
#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)
for (i = 0; i < (B); i++) { \
if (++A[i] != 0) break; \
} \
- } while(0) \
+ } while (0) \
////////////////////////////////////////////////////////////////////////////
// MACROs for cc_u32 Evaluation
#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
*/
#define SDRM_DWD_Copy(Dest, Src, Size) do { \
memcpy(Dest, Src, SDRM_SIZE_OF_DWORD * Size); \
- } while(0)
+ } while (0)
////////////////////////////////////////////////////////////////////////////
// MACROs for Big Number
* @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
break; \
else \
(BN)->Length--; \
- } while(0)
+ } while (0)
/*
* @fn SDRM_IS_BN_NEGATIVE(X)
* @brief check big number's sign
/*! @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
#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); \
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,
}
};
#endif
-/***************************** End of File *****************************/
\ No newline at end of file
+/***************************** End of File *****************************/
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)
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)) { \
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; \
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)
////////////////////////////////////////////////////////////////////////////
/* 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); \
* @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);
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
}
#endif // _MD5_H
-/***************************** End of File *****************************/
\ No newline at end of file
+/***************************** End of File *****************************/
////////////////////////////////////////////////////////////////////////////
#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
#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]); \
} \
#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"); \
#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]); \
/*! @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 *****************************/
* @return base path
*/
static void get_base_path(const char* filename, char* base_path);
-
};
#endif
unsigned int m_read_data_size;
bool m_file_path_ready;
-
};
#endif
unsigned long major;
unsigned long minor;
} version; /**< module version.*/
-
} ss_credential_s;
typedef uint8_t CBT_OCTET;
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;
}
#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");
{
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;
}
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;
}
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;
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.");
{
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;
}
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;
#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;
}
return (data_find ? SS_RET_SUCCESS : SS_RET_CANT_FIND_REQUESTED_DATA);
-
}
temp_ss_node* ss_temp_store::find_node(char* data_name) {
clock_gettime(CLOCK_REALTIME, &tspec);
time->seconds = tspec.tv_sec;
time->millis = tspec.tv_nsec / 1000000ULL;
- } else TEE_GetREETime(time);
+ }
+ else TEE_GetREETime(time);
}
/**
/*!\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;
unsigned int privatekey_len;
unsigned char* publickey;
unsigned int publickey_len;
-
} dh_key_s;
/**
* @brief imp key union.
#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 {
#define ucip_dh_prime uparam.udhp.prime
#define ucip_dh_generator uparam.udhp.generator
#define ucip_dh_len uparam.udhp.len
-
} uci_param_s;
/** @}*/
#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
#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 {
} ACCESS_PERMISSION;
typedef enum {
- TA_PRIVILEGE_PUBLIC=1,
+ TA_PRIVILEGE_PUBLIC = 1,
TA_PRIVILEGE_PARTNER,
TA_PRIVILEGE_PLATFORM,
} TA_PRIVILEGE;
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
\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
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
* @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;
bool bitValue = (bool)SDRM_BN_num_bits_index(objBn, index);
LOGD(TAG, "Success");
return bitValue;
-
}
/**
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);
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"); \
}
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:
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:
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:
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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;
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,
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)
{
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:
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:
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)
{
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:
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 */
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 */
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;
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;
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:
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;
}
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;
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 */
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;
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;
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;
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("--------------------------------------------------------------");
{
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);
}
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);
}
in_size -= remaining_number_of_bytes;
}
}
- }
- else
- {
+ } else {
if(crypto_update_engine(operation, in_data, in_size, out_data, &out_size)) {
goto 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("--------------------------------------------------------------");
{
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);
}
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;
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);
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;
}
}
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]);
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--) {
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]);
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;
}
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;
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;
}
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;
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;
{
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;
{
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;
}
}
}
/* get handle */
- if (crypto_internal_open(op)!=0) {
+ if (crypto_internal_open(op) != 0) {
rc = TEE_ERROR_NOT_SUPPORTED;
goto error;
}
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);
operationInfo->requiredKeyUsage = op->info.requiredKeyUsage;
}
-void TEE_ResetOperation( TEE_OperationHandle operation)
+void TEE_ResetOperation(TEE_OperationHandle operation)
{
PERMISSION_CHECK_RETURN_VOID(PERM_CRYPTO);
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);
{
LOGE(SSF_LIB, "op->info.operationClass == TEE_OPERATION_DIGEST\n");
return TEE_ERROR_BAD_PARAMETERS;
-
};
if (key == TEE_HANDLE_NULL)
{
LOGE(SSF_LIB, "(key->tr.info.objectUsage | ~(op->info.requiredKeyUsage)) != 0xffffffff\n");
return TEE_ERROR_BAD_PARAMETERS;
-
};
TEE_CopyObjectAttributes(op->key1, key);
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);
}
-void TEE_CopyOperation( TEE_OperationHandle dstOperation, TEE_OperationHandle srcOperation)
+void TEE_CopyOperation(TEE_OperationHandle dstOperation, TEE_OperationHandle srcOperation)
{
PERMISSION_CHECK_RETURN_VOID(PERM_CRYPTO);
if (crypto_internal_open(dstOp) != 0) {
CRYPTO_PANIC;
}
- }
- else {
+ } else {
dstOp->crypto = NULL;
}
return;
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;
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;
}
// 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;
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;
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;
}
// 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;
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;
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;
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;
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;
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);
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)) {
* Initializes SSF for use by TA
*/
__attribute__((constructor)) void initializeSSF() {
-
socketSimulatorDaemonFD = connecttoServer();
assert(socketSimulatorDaemonFD != -1);
LOGD(SIM_DAEMON, "Done");}
/*-----------------------------------------------------------------------------
* 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"
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
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] = '-';
} 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; \
}
void TEE_CloseTASession(TEE_TASessionHandle session) {
-
IntTACloseSessionData data;
data.session = *(uint32_t*)session;
pthread_mutex_lock(&socketLock);