AM263Px MCU+ SDK: dthe_sha.h Source File

| AM263Px MCU+ SDK 26.00.00 |

dthe_sha.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2022 Texas Instruments Incorporated
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
48 #ifndef DTHE_SHA_H_
49 #define DTHE_SHA_H_
50
51 /* ========================================================================== */
52 /* Include Files */
53 /* ========================================================================== */
54 #include <stdint.h>
55 #include <security_common/drivers/crypto/dthe/dthe.h>
56 #include <kernel/dpl/SystemP.h>
57 #include <drivers/hw_include/cslr.h>
58 #include <security_common/drivers/crypto/dthe/hw_include/cslr_sha.h>
59
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63
64 /* ========================================================================== */
65 /* Macros & Typedefs */
66 /* ========================================================================== */
69 #define DTHE_SHA_ALGO_MD5 (0x1U)
70
71 #define DTHE_SHA_ALGO_SHA384 (0x2U)
72
73 #define DTHE_SHA_ALGO_SHA1 (0x3U)
74
75 #define DTHE_SHA_ALGO_SHA512 (0x4U)
76
77 #define DTHE_SHA_ALGO_SHA224 (0x5U)
78
79 #define DTHE_SHA_ALGO_SHA256 (0x6U)
80
82 #define DTHE_SHA_MAX_DIGEST_SIZE_BYTES (64U)
83 /* ========================================================================== */
84 /* Structure Declarations */
85 /* ========================================================================== */
94 typedef enum DTHE_SHA_Return_e
95 {
96 DTHE_SHA_RETURN_SUCCESS = 0x67A42DD1U,
97 DTHE_SHA_RETURN_FAILURE = 0x06C2B483U,
98 }DTHE_SHA_Return_t;
99
101 typedef struct DTHE_SHA_Params_t
102 {
104 uint32_t algoType;
106 uint32_t *ptrDataBuffer;
108 uint32_t dataLenBytes;
110 uint32_t *ptrKey;
112 uint32_t keySize;
114 uint32_t digest[DTHE_SHA_MAX_DIGEST_SIZE_BYTES/4U];
115 }DTHE_SHA_Params;
116
117 /* ========================================================================== */
118 /* Global Variables */
119 /* ========================================================================== */
120
121 /* ========================================================================== */
122 /* Function Declarations */
123 /* ========================================================================== */
124
133 DTHE_SHA_Return_t DTHE_SHA_open(DTHE_Handle handle);
134
147 DTHE_SHA_Return_t DTHE_SHA_compute(DTHE_Handle handle, DTHE_SHA_Params* ptrShaParams, Bool isLastBlock);
148
159 DTHE_SHA_Return_t DTHE_HMACSHA_compute(DTHE_Handle handle, DTHE_SHA_Params* ptrShaParams);
160
169 DTHE_SHA_Return_t DTHE_SHA_close(DTHE_Handle handle);
170
171 #ifdef __cplusplus
172 }
173 #endif
174
175 #endif
176
DTHE_SHA_Params::ptrKey
uint32_t * ptrKey
Pointer to the key for hmac processing.
Definition: dthe_sha.h:110
DTHE_SHA_Params::dataLenBytes
uint32_t dataLenBytes
Size of the data in bytes.
Definition: dthe_sha.h:108
DTHE_SHA_MAX_DIGEST_SIZE_BYTES
#define DTHE_SHA_MAX_DIGEST_SIZE_BYTES
The Maximum Digest Size is 64bytes for the SHA512.
Definition: dthe_sha.h:82
dthe.h
This file contains the prototype of DTHE driver APIs.
SystemP.h
DTHE_SHA_Params::algoType
uint32_t algoType
Algorithm to be performed by the SHA Driver.
Definition: dthe_sha.h:104
DTHE_SHA_Params::keySize
uint32_t keySize
Size of the key in bytes.
Definition: dthe_sha.h:112
DTHE_SHA_RETURN_FAILURE
@ DTHE_SHA_RETURN_FAILURE
Definition: dthe_sha.h:97
DTHE_SHA_RETURN_SUCCESS
@ DTHE_SHA_RETURN_SUCCESS
Definition: dthe_sha.h:96
DTHE_SHA_open
DTHE_SHA_Return_t DTHE_SHA_open(DTHE_Handle handle)
Function to Open DTHE SHA Driver.
DTHE_SHA_close
DTHE_SHA_Return_t DTHE_SHA_close(DTHE_Handle handle)
Function to close DTHE SHA Driver.
DTHE_HMACSHA_compute
DTHE_SHA_Return_t DTHE_HMACSHA_compute(DTHE_Handle handle, DTHE_SHA_Params *ptrShaParams)
The function is used to execute the HMAC SHA Operations with the specified parameters.
DTHE_Handle
void * DTHE_Handle
Handle to the DTHE driver.
Definition: dthe.h:85
DTHE_SHA_Params::ptrDataBuffer
uint32_t * ptrDataBuffer
Pointer to the Plain Text data buffer.
Definition: dthe_sha.h:106
DTHE_SHA_compute
DTHE_SHA_Return_t DTHE_SHA_compute(DTHE_Handle handle, DTHE_SHA_Params *ptrShaParams, Bool isLastBlock)
The function is used to execute the SHA Driver with the specified parameters.
DTHE_SHA_Params
Parameters required for SHA Driver.
Definition: dthe_sha.h:102
DTHE_SHA_Return_t
DTHE_SHA_Return_t
DTHE SHA Driver Error code.
Definition: dthe_sha.h:95