1 /***************************************************************************//** 2 * \file cy_cryptolite_cmac.h 3 * \version 2.30 4 * 5 * \brief 6 * This file provides constants and function prototypes 7 * for the API for the CMAC method in the Cryptolite block driver. 8 * 9 ******************************************************************************** 10 * \copyright 11 * Copyright (c) (2020-2023), Cypress Semiconductor Corporation (an Infineon company) or 12 * an affiliate of Cypress Semiconductor Corporation. 13 * SPDX-License-Identifier: Apache-2.0 14 * 15 * Licensed under the Apache License, Version 2.0 (the "License"); 16 * you may not use this file except in compliance with the License. 17 * You may obtain a copy of the License at 18 * 19 * http://www.apache.org/licenses/LICENSE-2.0 20 * 21 * Unless required by applicable law or agreed to in writing, software 22 * distributed under the License is distributed on an "AS IS" BASIS, 23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 * See the License for the specific language governing permissions and 25 * limitations under the License. 26 *******************************************************************************/ 27 28 29 #if !defined (CY_CRYPTOLITE_CMAC_H) 30 #define CY_CRYPTOLITE_CMAC_H 31 32 #include "cy_device.h" 33 34 #if defined(CY_IP_MXCRYPTOLITE) 35 36 #include "cy_cryptolite_common.h" 37 38 #if defined(__cplusplus) 39 extern "C" { 40 #endif 41 42 #if (CRYPTOLITE_AES_PRESENT == 1) 43 #if defined(CY_CRYPTOLITE_CFG_CMAC_C) 44 45 #include "cy_cryptolite_aes.h" 46 47 /** 48 * \addtogroup group_cryptolite_lld_mac_functions 49 * \{ 50 */ 51 52 /******************************************************************************* 53 * Function Name: Cy_Cryptolite_Cmac_Init 54 ****************************************************************************//** 55 * 56 * The function for initialization of CMAC operation. 57 * 58 * \param base 59 * The pointer to the CRYPTOLITE instance. 60 * 61 * \param key 62 * The pointer to the CMAC key. 63 * 64 * \param cmacState 65 * The pointer to the AES state structure allocated by the user. The user 66 * must not modify anything in this structure. 67 * 68 * \param aesBuffers The buffers should be a SAHB mapped addresses. 69 * The pointer to the memory buffers storage. 70 * 71 * \return 72 * \ref cy_en_cryptolite_status_t 73 *******************************************************************************/ 74 cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Init(CRYPTOLITE_Type *base, 75 uint8_t const *key, 76 cy_stc_cryptolite_aes_state_t *cmacState, 77 cy_stc_cryptolite_aes_buffers_t *aesBuffers); 78 79 /******************************************************************************* 80 * Function Name: Cy_Cryptolite_Cmac_Start 81 ****************************************************************************//** 82 * 83 * Starts CMAC calculation. 84 * 85 * \param base 86 * The pointer to the CRYPTOLITE instance. 87 * 88 * \param cmacState 89 * The pointer to the structure which stores the CMAC context. 90 * 91 * \return 92 * \ref cy_en_cryptolite_status_t 93 *******************************************************************************/ 94 cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Start(CRYPTOLITE_Type *base, cy_stc_cryptolite_aes_state_t *cmacState); 95 96 /******************************************************************************* 97 * Function Name: Cy_Cryptolite_Cmac_Update 98 ****************************************************************************//** 99 * 100 * Performs cmac update for multi stage operation. 101 * 102 * \param base 103 * The pointer to the CRYPTOLITE instance. 104 * 105 * \param message 106 * The pointer to the message whose CMAC is being computed. 107 * 108 * \param messageSize 109 * The size of the message whose CMAC is being computed. 110 * 111 * \param cmacState 112 * The pointer to the structure which stores the CMAC context. 113 * 114 * \return 115 * \ref cy_en_cryptolite_status_t 116 *******************************************************************************/ 117 cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Update(CRYPTOLITE_Type *base, 118 uint8_t const *message, 119 uint32_t messageSize, 120 cy_stc_cryptolite_aes_state_t *cmacState); 121 122 /******************************************************************************* 123 * Function Name: Cy_Cryptolite_Cmac_Finish 124 ****************************************************************************//** 125 * 126 * Completes CMAC calculation. 127 * 128 * \param base 129 * The pointer to the CRYPTOLITE instance. 130 * 131 * \param cmac 132 * The pointer to the computed CMAC value. 133 * 134 * \param cmacState 135 * The pointer to the structure which stores the CMAC context. 136 * 137 * \return 138 * \ref cy_en_cryptolite_status_t 139 *******************************************************************************/ 140 cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Finish(CRYPTOLITE_Type *base, uint8_t* cmac, cy_stc_cryptolite_aes_state_t *cmacState); 141 142 143 /******************************************************************************* 144 * Function Name: Cy_Cryptolite_Cmac_Free 145 ****************************************************************************//** 146 * 147 * Clears CMAC operation context. 148 * 149 * \param base 150 * The pointer to the CRYPTOLITE instance. 151 * 152 * \param cmacState 153 * The pointer to the AES state structure allocated by the user. The user 154 * must not modify anything in this structure. 155 * 156 * \return 157 * \ref cy_en_cryptolite_status_t 158 *******************************************************************************/ 159 cy_en_cryptolite_status_t Cy_Cryptolite_Cmac_Free(CRYPTOLITE_Type *base, cy_stc_cryptolite_aes_state_t *cmacState); 160 161 162 /******************************************************************************* 163 * Function Name: Cy_Cryptolite_Cmac 164 ****************************************************************************//** 165 * 166 * Performs CMAC(Cipher-based Message Authentication Code) operation 167 * on a message to produce message authentication code using AES. 168 ** 169 * \param base 170 * The pointer to the CRYPTOLITE instance. 171 * 172 * \param message 173 * The pointer to a source plain text. 174 * 175 * \param messageSize 176 * The size of a source plain text. 177 * 178 * \param key 179 * The pointer to the encryption key. 180 * 181 * \param cmac 182 * The pointer to the calculated CMAC. 183 * 184 * \param cmacState 185 * The pointer to the AES state structure allocated by the user. The user 186 * must not modify anything in this structure. 187 * 188 * \return 189 * \ref cy_en_cryptolite_status_t 190 * 191 *******************************************************************************/ 192 cy_en_cryptolite_status_t Cy_Cryptolite_Cmac(CRYPTOLITE_Type *base, 193 uint8_t const *key, 194 uint8_t const *message, 195 uint32_t messageSize, 196 uint8_t *cmac, 197 cy_stc_cryptolite_aes_state_t *cmacState); 198 199 /** \} group_cryptolite_lld_mac_functions */ 200 201 #endif /*defined(CY_CRYPTOLITE_CFG_CMAC_C) */ 202 #endif /* CRYPTOLITE_AES_PRESENT */ 203 204 #if defined(__cplusplus) 205 } 206 #endif 207 208 #endif /* defined(CY_IP_MXCRYPTOLITE) */ 209 210 #endif /* #if !defined (CY_CRYPTOLITE_CMAC_H) */ 211 212 213 /* [] END OF FILE */ 214