AESCMACLPF3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021-2023, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the 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 "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
55 #ifndef ti_drivers_aescmac_AESCMACLPF3__include
56 #define ti_drivers_aescmac_AESCMACLPF3__include
57 
58 #include <stdbool.h>
59 #include <stdint.h>
60 
61 #include <ti/drivers/AESCMAC.h>
64 
65 #include <ti/devices/DeviceFamily.h>
66 #include DeviceFamily_constructPath(inc/hw_types.h)
67 #include DeviceFamily_constructPath(driverlib/aes.h)
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
73 /*
74  * Default AES CMAC & CBC-MAC auto config:
75  * ECB SRC as TXTXBUF
76  * Trigger point for auto ECB as WRBUF3 (encryption starts by writing BUF3)
77  * BUSHALT enabled
78  */
79 #if DeviceFamily_PARENT == DeviceFamily_PARENT_CC23X0
80  #define AESCMACLPF3_DEFAULT_AUTOCFG \
81  ((uint32_t)AES_AUTOCFG_AESSRC_TXTXBUF | (uint32_t)AES_AUTOCFG_TRGAES_WRBUF3 | (uint32_t)AES_AUTOCFG_BUSHALT_EN)
82 #elif DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX
83  #define AESCMACLPF3_DEFAULT_AUTOCFG \
84  ((uint32_t)AES_AUTOCFG_ECBSRC_TXTXBUF | (uint32_t)AES_AUTOCFG_TRGECB_WRBUF3 | (uint32_t)AES_AUTOCFG_BUSHALT_EN)
85 #else
86  #error "Unsupported DeviceFamily_Parent for AESCMACLPF3!"
87 #endif
88 
89 /*
90  * AES CMAC DMA config:
91  * - ADRCHA = BUF0
92  * - TRGCHA = ECBSTART
93  */
94 #if DeviceFamily_PARENT == DeviceFamily_PARENT_CC23X0
95  #define AESCMACLPF3_DMA_CONFIG ((uint32_t)AES_DMA_ADRCHA_BUF0 | (uint32_t)AES_DMA_TRGCHA_AESSTART)
96 #elif DeviceFamily_PARENT == DeviceFamily_PARENT_CC27XX
97  #define AESCMACLPF3_DMA_CONFIG ((uint32_t)AES_DMA_ADRCHA_BUF0 | (uint32_t)AES_DMA_TRGCHA_ECBSTART)
98 #else
99  #error "Unsupported DeviceFamily_Parent for AESCMACLPF3!"
100 #endif
101 
102 #define AESCBCMACLPF3_DMA_CONFIG AESCMACLPF3_DMA_CONFIG
103 
111 
117 typedef struct
118 {
119  /* Common member first to allow struct to be cast to the common type */
121  volatile uint32_t intermediateTag[AES_TAG_LENGTH_BYTES / 4U];
122  uint32_t finalInputBlock[AES_BLOCK_SIZE_WORDS];
129 
140 void AESCMACLPF3_processBlocks(const uint8_t *input, size_t transactionLength);
141 
149 void AESCMACLPF3_readTag(uint32_t tagOut[AES_TAG_LENGTH_BYTES / 4U]);
150 
167 __STATIC_INLINE bool AESCMAC_acquireLock(AESCMAC_Handle handle, uint32_t timeout)
168 {
169  return CryptoResourceLPF3_acquireLock(timeout);
170 }
181 __STATIC_INLINE void AESCMAC_releaseLock(AESCMAC_Handle handle)
182 {
184 }
195 __STATIC_INLINE void AESCMAC_enableThreadSafety(AESCMAC_Handle handle)
196 {
197  AESCMACLPF3_Object *object = handle->object;
198  object->threadSafe = true;
199 }
213 __STATIC_INLINE void AESCMAC_disableThreadSafety(AESCMAC_Handle handle)
214 {
215  AESCMACLPF3_Object *object = handle->object;
216  object->threadSafe = false;
217 }
220 #ifdef __cplusplus
221 }
222 #endif
223 
224 #endif /* ti_drivers_aescmac_AESCMACLPF3__include */
bool CryptoResourceLPF3_acquireLock(uint32_t timeout)
AES Global configuration.
Definition: AESCommon.h:154
AESCMACLPF3 Object.
Definition: AESCMACLPF3.h:117
AESCMAC_OperationType
Enum for the operation types supported by the driver.
Definition: AESCMAC.h:715
AESCommonLPF3_Object common
Definition: AESCMACLPF3.h:120
void(* AESCMAC_CallbackFxn)(AESCMAC_Handle handle, int_fast16_t returnValue, AESCMAC_Operation *operation, AESCMAC_OperationType operationType)
The definition of a callback function used by the AESCMAC driver when used in AESCMAC_RETURN_BEHAVIOR...
Definition: AESCMAC.h:739
AESCMAC_OperationType operationType
Definition: AESCMACLPF3.h:125
AESCMAC_Operation * operation
Definition: AESCMACLPF3.h:124
AESCMAC_OperationalMode
Defines the operation modes for the AESCMAC driver.
Definition: AESCMAC.h:652
AESCMAC_CallbackFxn callbackFxn
Definition: AESCMACLPF3.h:123
AESCommonLPF3 Hardware Attributes.
Definition: AESCommonLPF3.h:80
void CryptoResourceLPF3_releaseLock(void)
AESCommon driver implementation for the Low Power F3 family.
bool threadSafe
Definition: AESCMACLPF3.h:127
Shared resources to arbitrate access to the AES engine.
AESCommonLPF3_HWAttrs AESCMACLPF3_HWAttrs
AESCMACLPF3 Hardware Attributes.
Definition: AESCMACLPF3.h:110
AESCMAC (CMAC and CBC-MAC) driver header.
void * object
Definition: AESCommon.h:157
Struct containing the parameters required for signing or verifying a message.
Definition: AESCMAC.h:661
AESCMAC_OperationalMode operationalMode
Definition: AESCMACLPF3.h:126
AESCommonLPF3 Object.
Definition: AESCommonLPF3.h:102
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale