//***************************************************************************** // //! ReadFromUser - Populate the parameters from User //! //! \param uiConfig - Configuration Value //! \param uiDataLength- Datalength //! \param puiResult - CRC Result //! //! \return pointer to Input Data //! //***************************************************************************** unsigned int* ReadFromUser(unsigned int *uiConfig,unsigned int *uiDataLength, unsigned int *puiResult) { char ucCmdBuffer[INPUT_MESSAGE_SIZE],*pucMsgBuff; unsigned int *uiData; pucMsgBuff=( char*)&puiPlainMsg[0]; // // Get the Command // UsageDisplay(); UART_PRINT("cmd# "); GetCmd(ucCmdBuffer,INPUT_MESSAGE_SIZE); if(CRCParser(ucCmdBuffer,uiConfig)) { uiData=GetMsg(pucMsgBuff,uiDataLength,uiConfig); memset(puiResult,0,sizeof(unsigned int)); } else { return NULL; } return uiData; }
int main(int argc, char* argv[]) { if((minArgc != argc) && (maxArgc != argc)) { UsageDisplay(argv[0]); } else { int start; ServiceInit(argc, argv); while(service.upaUeNum <= service.upaUeNumEnd) { start = clock(); TestSetGeneratorMainFlow(); printf(" * Take Time: %f seconds.\n", (double)(clock()-start)/CLOCK_PER_SEC); service.upaUeNum += service.upaUeNumStep; } } return 0; }
//***************************************************************************** // //! ReadFromUser - Populates the parameters from User //! //! \param uiConfig Configuration Value //! \param uiHashLength is the Length of Hash Value //! \param uiKey is the Key Used //! \param uiDataLength is the Length of Data //! \param puiResult is the Result //! //! \return pointer to plain text //! //***************************************************************************** unsigned char * ReadFromUser(unsigned int *uiConfig,unsigned int *uiHashLength,unsigned char **uiKey,unsigned int *uiDataLength,unsigned char **puiResult) { char ucCmdBuffer[520],*pucKeyBuff,*pucMsgBuff; unsigned char *uiData; // // POinting KeyBuffer into appropriate Keys. // pucKeyBuff=(char*)&uiHMACKey[0]; *uiKey=(unsigned char*)&uiHMACKey[0]; pucMsgBuff=( char*)&puiPlainMsg[0]; // // Set Default Values // SetKeys(); // // Usage Display // UsageDisplay(); // // Get the Command // UART_PRINT("cmd# "); GetCmd(ucCmdBuffer,520); if(SHAMD5Parser(ucCmdBuffer,uiConfig,uiHashLength)) { if(GetKey(pucKeyBuff)) { uiData=GetMsg(pucMsgBuff,uiDataLength); *puiResult=(unsigned char *)malloc(64); memset(*puiResult,0,64); } else { UART_PRINT("\n\r Invalid Key \n\r"); return NULL; } } else { UART_PRINT("\n\r Wrong Input \n\r"); return NULL; } return uiData; }
unsigned char* ReadFromUser(unsigned int *uiConfig,unsigned int *uiKeySize,unsigned char **uiKey, unsigned int *uiDataLength,unsigned char **puiResult) { char ucCmdBuffer[BUFFER_LEN],*pucKeyBuff,*pucMsgBuff; unsigned char *uiData; pucMsgBuff=( char*)&pui32AESPlainMsg[0]; // // Usage Display // UsageDisplay(); // // Set keys // SetKeys(); // // Get the Command // UART_PRINT("cmd# "); GetCmd(ucCmdBuffer,BUFFER_LEN); if(DESParser(ucCmdBuffer,uiConfig,uiKeySize)) { // // Get Key Length // if(*uiKeySize==8) { // // KeyBuff is used when User inputs the Key // pucKeyBuff=(char*)&uiDESKey[0]; *uiKey=(unsigned char*)&uiDESKey[0]; } else if(*uiKeySize==24) { pucKeyBuff=( char*)&uiTDESKey[0]; *uiKey=(unsigned char*)&uiTDESKey[0]; } else { pucKeyBuff = (char *) malloc(BUFFER_LEN); } if(GetKey(*uiKeySize,pucKeyBuff)) { uiData=GetMsg(pucMsgBuff,uiDataLength); *puiResult=(unsigned char *)malloc(*uiDataLength); memset(*puiResult,0,*uiDataLength); } else { UART_PRINT("\n\r Invalid Key \n\r"); return NULL; } } else { return NULL; } return uiData; }
//***************************************************************************** // //! ReadFrom User Function //! //! This function //! 1. Gets Input from User //! \out uiConfig - Configuration Value //! \out uiKeySize - Key Size //! \out uiKey - Key Used //! \out uiDataLength - DataLength //! \out puiResult - Result //! //! \return pointer to Plain Text // //***************************************************************************** unsigned int* ReadFromUser(unsigned int *uiConfig,unsigned int *uiKeySize,unsigned int **uiKey ,unsigned int *uiDataLength,unsigned int **puiResult) { char ucCmdBuffer[520],*pucKeyBuff,*pucMsgBuff; unsigned int *uiData; pui32AESPlainMsg[0] = '\0'; pucMsgBuff=( char*)&pui32AESPlainMsg[0]; // //Set the default keys. // SetKeys(); UsageDisplay(); UART_PRINT("cmd# "); GetCmd(ucCmdBuffer,520); if(AESParser(ucCmdBuffer,uiConfig,uiKeySize)) { // // Get Key Length // if(*uiKeySize==AES_CFG_KEY_SIZE_128BIT) { pucKeyBuff=(char*)&uiKey128[0]; *uiKey=(unsigned int*)&uiKey128[0]; } else if(*uiKeySize==AES_CFG_KEY_SIZE_192BIT) { pucKeyBuff=( char*)&uiKey192[0]; *uiKey=(unsigned int*)&uiKey192[0]; } else if(*uiKeySize==AES_CFG_KEY_SIZE_256BIT) { pucKeyBuff=( char*)&uiKey256[0]; *uiKey=(unsigned int*)&uiKey256[0]; } else { pucKeyBuff = (char *) malloc(BUFFER_LEN); } if(GetKey(*uiKeySize,pucKeyBuff)) { uiData=GetMsg(pucMsgBuff,uiDataLength); if(uiData == 0) { return NULL; } *puiResult=(unsigned int *)malloc(*uiDataLength); memset(*puiResult,0,*uiDataLength); } else { UART_PRINT("\n\r Invalid Key \n\r"); return NULL; } } else { return NULL; } return uiData; }
//***************************************************************************** // //! ReadFrom User Function //! //! This function //! 1. Gets Input from User //! \out uiConfig - Configuration Value //! \out uiKeySize - Key Size //! \out uiKey - Key Used //! \out uiDataLength - DataLength //! \out puiResult - Result //! //! \return pointer to Plain Text // //***************************************************************************** unsigned int* ReadFromUser(unsigned int *uiConfig,unsigned int *uiKeySize,unsigned int **uiKey ,unsigned int *uiDataLength,unsigned int **puiResult) { char ucCmdBuffer[520],*pucKeyBuff,*pucMsgBuff; unsigned int *uiData; pui32AESPlainMsg[0] = '\0'; pucMsgBuff=( char*)&pui32AESPlainMsg[0]; // //Set the default keys. // SetKeys(); UsageDisplay(); UART_PRINT("cmd# "); GetCmd(ucCmdBuffer,520); if(AESParser(ucCmdBuffer,uiConfig,uiKeySize))//vrati ti duzinu i mode { // // Get Key Length // if(*uiKeySize==AES_CFG_KEY_SIZE_128BIT) { pucKeyBuff=(char*)&uiKey128[0]; *uiKey=(unsigned int*)&uiKey128[0]; } else if(*uiKeySize==AES_CFG_KEY_SIZE_192BIT) { pucKeyBuff=( char*)&uiKey192[0]; *uiKey=(unsigned int*)&uiKey192[0]; } else if(*uiKeySize==AES_CFG_KEY_SIZE_256BIT) { pucKeyBuff=( char*)&uiKey256[0]; *uiKey=(unsigned int*)&uiKey256[0]; } else { pucKeyBuff = (char *) malloc(BUFFER_LEN);//nisi nista odabrao od zeljenih duzina odjebi iz memorije } if(GetKey(*uiKeySize,pucKeyBuff))//unesem moju rec { uiData=GetMsg(pucMsgBuff,uiDataLength);//vraca rec koju zelim da kriptujem if(uiData == 0) { return NULL; } *puiResult=(unsigned int *)malloc(*uiDataLength); memset(*puiResult,0,*uiDataLength); } else { UART_PRINT("\n\r Invalid Key \n\r"); return NULL; } } else { return NULL; } return uiData; }