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