1 /* 2 * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/ 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the 14 * distribution. 15 * 16 * Neither the name of Texas Instruments Incorporated nor the names of 17 * its contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 */ 33 //***************************************************************************** 34 // 35 // shamd5.h 36 // 37 // Defines and Macros for the SHA/MD5. 38 // 39 //***************************************************************************** 40 41 #ifndef __DRIVERLIB_SHAMD5_H__ 42 #define __DRIVERLIB_SHAMD5_H__ 43 44 //***************************************************************************** 45 // 46 // If building with a C++ compiler, make all of the definitions in this header 47 // have a C binding. 48 // 49 //***************************************************************************** 50 #ifdef __cplusplus 51 extern "C" 52 { 53 #endif 54 55 //***************************************************************************** 56 // 57 // The following defines are used to specify the algorithm in use in the 58 // SHA/MD5 module. 59 // 60 //***************************************************************************** 61 #define SHAMD5_ALGO_MD5 0x00000000 // MD5 62 #define SHAMD5_ALGO_SHA1 0x00000002 // SHA-1 63 #define SHAMD5_ALGO_SHA224 0x00000004 // SHA-224 64 #define SHAMD5_ALGO_SHA256 0x00000006 // SHA-256 65 66 //***************************************************************************** 67 // 68 // The following definitions represent the number of bits to shift in order 69 // to configure the differnet bit fields in the SHAMD5_O_MODE register. 70 // 71 //***************************************************************************** 72 #define ALGO_CONSTANT_SHIFT 3 73 #define CLOSE_HASH_SHIFT 4 74 #define HMAC_KEY_PROC_SHIFT 5 75 #define HMAC_OUTER_HASH_SHIFT 7 76 77 //***************************************************************************** 78 // 79 // The following defines are used to represent the different interrupt sources 80 // in SHAMD5IntEnable(), SHAMD5IntDisable(), SHAMD5GetIntStatus(), and 81 // SHAMD5BlockOnIntStatus() functions. 82 // 83 //***************************************************************************** 84 #define SHAMD5_INT_CONTEXT_READY 0x00000008 85 #define SHAMD5_INT_PARTHASH_READY 0x00000004 86 #define SHAMD5_INT_INPUT_READY 0x00000002 87 #define SHAMD5_INT_OUTPUT_READY 0x00000001 88 #define SHAMD5_INT_DMA_CONTEXT_IN 0x00010000 89 #define SHAMD5_INT_DMA_DATA_IN 0x00020000 90 #define SHAMD5_INT_DMA_CONTEXT_OUT 0x00040000 91 92 //***************************************************************************** 93 // 94 // Function prototypes 95 // 96 //***************************************************************************** 97 extern void SHAMD5ConfigSet(uint32_t ui32Base, uint32_t ui32CryptoMode, uint8_t algConstFlag, uint8_t closeHashFlag, 98 uint8_t HMACKeyFlag, uint8_t HMACOuterHashFlag); 99 extern bool SHAMD5DataProcess(uint32_t ui32Base, uint8_t *pui8DataSrc, 100 uint32_t ui32DataLength, uint8_t *pui8HashResult); 101 extern void SHAMD5DataWrite(uint32_t ui32Base, uint8_t *pui8Src); 102 extern bool SHAMD5DataWriteNonBlocking(uint32_t ui32Base, uint8_t *pui8Src); 103 extern void SHAMD5DMADisable(uint32_t ui32Base); 104 extern void SHAMD5DMAEnable(uint32_t ui32Base); 105 extern void SHAMD5DataLengthSet(uint32_t ui32Base, uint32_t ui32Length); 106 extern void SHAMD5HMACKeySet(uint32_t ui32Base, uint8_t *pui8Src); 107 extern void SHAMD5HMACPPKeyGenerate(uint32_t ui32Base, uint8_t *pui8Key, 108 uint8_t *pui8PPKey); 109 extern void SHAMD5HMACPPKeySet(uint32_t ui32Base, uint8_t *pui8Src); 110 extern bool SHAMD5HMACProcess(uint32_t ui32Base, uint8_t *pui8DataSrc, 111 uint32_t ui32DataLength, uint8_t *pui8HashResult); 112 extern void SHAMD5IntClear(uint32_t ui32Base, uint32_t ui32IntFlags); 113 extern void SHAMD5IntDisable(uint32_t ui32Base, uint32_t ui32IntFlags); 114 extern void SHAMD5IntEnable(uint32_t ui32Base, uint32_t ui32IntFlags); 115 extern void SHAMD5IntRegister(uint32_t ui32Base, void(*pfnHandler)(void)); 116 extern uint32_t SHAMD5IntStatus(uint32_t ui32Base, bool bMasked); 117 extern void SHAMD5IntUnregister(uint32_t ui32Base); 118 extern void SHAMD5ResultRead(uint32_t ui32Base, uint8_t *pui8Dest); 119 extern void SHAMD5ResultWrite(uint32_t ui32Base, uint8_t *pui8Src); 120 extern void SHAMD5ReadDigestCount(uint32_t ui32Base, uint32_t *count); 121 extern void SHAMD5WriteDigestCount(uint32_t ui32Base, uint32_t count); 122 extern void SHAMD5DataWriteMultiple(uint32_t ui32Base, uint8_t *pui8DataSrc, uint32_t ui32DataLength); 123 124 //***************************************************************************** 125 // 126 // Mark the end of the C bindings section for C++ compilers. 127 // 128 //***************************************************************************** 129 #ifdef __cplusplus 130 } 131 #endif 132 133 #endif // __DRIVERLIB_SHAMD5_H__ 134