AM62Ax MCU+ SDK  10.01.00
crypto.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 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 
47 #ifndef CRYPTO_TOP_H_
48 #define CRYPTO_TOP_H_
49 
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
54 
55 /* ========================================================================== */
56 /* Include Files */
57 /* ========================================================================== */
58 
59 #include <stdint.h>
60 
61 /* ========================================================================== */
62 /* Macros & Typedefs */
63 /* ========================================================================== */
64 
66 #define CRYPTO_HMAC_SHA_MAX_KEYLEN_BYTES (128U)
67 
68 #define CRYPTO_HMAC_SHA512_KEYLEN_BYTES (128U)
69 
70 #define CRYPTO_HMAC_SHA1_KEYLEN_BYTES (64U)
71 
72 #define CRYPTO_HMAC_SHA256_KEYLEN_BYTES (64U)
73 
74 #define CRYPTO_HMAC_SHA_IPAD (0x36U)
75 
76 #define CRYPTO_HMAC_SHA_OPAD (0x5CU)
77 
79 #define CRYPTO_AES_CMAC_KEY_LENGTH (16U)
80 
81 #define CRYPTO_AES_BLOCK_LENGTH (16U)
82 
84 typedef void *Crypto_Handle;
85 
86 /* ========================================================================== */
87 /* Structure Declarations */
88 /* ========================================================================== */
89 
91 typedef struct
92 {
93  void *drvHandle;
96 
98 typedef struct
99 {
101  uint32_t authMode;
105  uint32_t keySizeInBytes;
111  uint8_t aesWithKeyAppliedToZeroInput[CRYPTO_AES_BLOCK_LENGTH];
116 } Crypto_Params;
117 
118 /* ========================================================================== */
119 /* Function Declarations */
120 /* ========================================================================== */
121 
125 void Crypto_init(void);
126 
130 void Crypto_deinit(void);
131 
138 
147 int32_t Crypto_close(Crypto_Handle handle);
148 
158 int32_t Crypto_hmacSha(Crypto_Params *params);
159 
169 /* ========================================================================== */
170 /* Static Function Definitions */
171 /* ========================================================================== */
172 
173 /* None */
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* CRYPTO_TOP_H_ */
180 
Crypto_Context
CRYPTO driver context.
Definition: crypto.h:92
CRYPTO_AES_BLOCK_LENGTH
#define CRYPTO_AES_BLOCK_LENGTH
Aes block length.
Definition: crypto.h:81
Crypto_Params::keySizeInBytes
uint32_t keySizeInBytes
Definition: crypto.h:105
Crypto_Params
CRYPTO Parameters for various operations.
Definition: crypto.h:99
Crypto_hmacSha
int32_t Crypto_hmacSha(Crypto_Params *params)
This function calculates oPad & iPad for HMAC.
Crypto_open
Crypto_Handle Crypto_open(Crypto_Context *ctx)
This function opens a Crypto module.
CRYPTO_HMAC_SHA_MAX_KEYLEN_BYTES
#define CRYPTO_HMAC_SHA_MAX_KEYLEN_BYTES
Key length for HMAC-SHA Process.
Definition: crypto.h:66
CRYPTO_AES_CMAC_KEY_LENGTH
#define CRYPTO_AES_CMAC_KEY_LENGTH
Aes Cmac key length.
Definition: crypto.h:79
Crypto_Params::authMode
uint32_t authMode
Definition: crypto.h:101
Crypto_close
int32_t Crypto_close(Crypto_Handle handle)
Function to close a Crypto module.
Crypto_Context::drvHandle
void * drvHandle
Definition: crypto.h:93
Crypto_deinit
void Crypto_deinit(void)
This function de-initializes the Crypto module.
Crypto_cmacGenSubKeys
int32_t Crypto_cmacGenSubKeys(Crypto_Params *params)
This function Generate Sub keys for CMAC calculation.
Crypto_Handle
void * Crypto_Handle
Handle to the Crypto driver returned by Crypto_open()
Definition: crypto.h:84
Crypto_init
void Crypto_init(void)
This function initializes the Crypto module.