//***************************************************************************** // //! 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; }