Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
sha1_gen.cpp
00001 //***************************************************************************** 00002 // Copyright (C) 2014 Texas Instruments Incorporated 00003 // 00004 // All rights reserved. Property of Texas Instruments Incorporated. 00005 // Restricted rights to use, duplicate or disclose this code are 00006 // granted through contract. 00007 // The program may not be used without the written permission of 00008 // Texas Instruments Incorporated or against the terms and conditions 00009 // stipulated in the agreement under which this program has been supplied, 00010 // and under no circumstances can it be used with non-TI connectivity device. 00011 // 00012 //***************************************************************************** 00013 00014 00015 /** 00016 * @addtogroup sha1 00017 * 00018 * @{ 00019 */ 00020 #include "mbed.h" 00021 #include <stdio.h> 00022 #include <stdlib.h> 00023 #include <stdint.h> 00024 #include <stdbool.h> 00025 #include <string.h> 00026 00027 #include "sha1_gen.h" 00028 #include "stm32f4xx_hal_hash.h" 00029 00030 #if !defined(POLARSSL_CONFIG_FILE) 00031 #include "polarssl/config.h" 00032 #else 00033 #include POLARSSL_CONFIG_FILE 00034 #endif 00035 00036 #if defined(POLARSSL_PLATFORM_C) 00037 #include "polarssl/platform.h" 00038 #else 00039 #include <stdio.h> 00040 #define polarssl_printf printf 00041 #endif 00042 00043 #if defined(POLARSSL_SHA1_C) && defined(POLARSSL_FS_IO) 00044 #include "polarssl/sha1.h" 00045 #endif 00046 00047 // 00048 // Flags to check that interrupts were successfully generated. 00049 // 00050 volatile bool g_bContextReadyFlag; 00051 volatile bool g_bParthashReadyFlag; 00052 volatile bool g_bInputReadyFlag; 00053 volatile bool g_bOutputReadyFlag; 00054 00055 00056 void SHAMD5IntHandler(void); 00057 void GenerateHash(unsigned int uiConfig,unsigned char *puiKey1,unsigned char *puiData, 00058 unsigned char *puiResult,unsigned int uiDataLength); 00059 00060 //***************************************************************************** 00061 // 00062 //! SHAMD5IntHandler - Interrupt Handler which handles different interrupts from 00063 //! different sources 00064 //! 00065 //! \param None 00066 //! 00067 //! \return None 00068 // 00069 //***************************************************************************** 00070 void 00071 SHAMD5IntHandler(void) 00072 { 00073 uint32_t ui32IntStatus; 00074 00075 } 00076 00077 //***************************************************************************** 00078 // 00079 //! GenerateHash - Generates the Hash value of the Plain Text 00080 //! 00081 //! \param uiConfig - Configuration Value 00082 //! \param puiKey1 - Key Used 00083 //! \param puiData - Plain Text used 00084 //! \param puiResult - Hash Value Generated 00085 //! \param uiDataLength - DataLength Used 00086 //! 00087 //! \return None 00088 // 00089 //***************************************************************************** 00090 00091 void 00092 GenerateHash(unsigned int uiConfig,unsigned char *puiKey1,unsigned char *puiData, 00093 unsigned char *puiResult,unsigned int uiDataLength) 00094 { 00095 // SHA1ctx_stt SHA1ctx_st; 00096 // SHA1_Init(&SHA1ctx_st); 00097 00098 // int32_t HHH_Init (HHHctx_stt *P_pHHHctx); 00099 // 00100 // Step1: Reset the Module 00101 // Step2: Enable Interrupts 00102 // Step3: Wait for Context Ready Inteerupt 00103 // Step4: Set the Configuration Parameters (Hash Algorithm) 00104 // Step5: Set Key depends on Algorithm 00105 // Step7: Start Hash Generation 00106 // 00107 00108 // 00109 // Clear the flags 00110 // 00111 g_bContextReadyFlag = false; 00112 g_bInputReadyFlag = false; 00113 00114 // 00115 // Perform the hashing operation 00116 // 00117 sha1( (unsigned char *) puiData, strlen((const char *)puiData), puiResult ); 00118 // HAL_HASH_SHA1_Start(puiData, strlen((const char *)puiData), puiResult ); 00119 00120 // for(int i = 0; i < 16; i++ ){ 00121 // polarssl_printf( "%02x", puiResult[i] ); 00122 // } 00123 // polarssl_printf( "\r\n" ); 00124 // SHA1_Finish(); 00125 00126 } 00127 00128 int SHA1(unsigned char *puiInData,unsigned char *puiOutData) 00129 { 00130 00131 GenerateHash(SHAMD5_ALGO_SHA1,NULL,puiInData,puiOutData,strlen((const char *)puiInData)); 00132 00133 return 1; 00134 00135 } 00136 00137 /// @} 00138
Generated on Tue Jul 12 2022 22:22:38 by
 1.7.2
 1.7.2