1 /***************************************************************************//** 2 * \file cy_crypto_core_cmac_v1.h 3 * \version 2.120 4 * 5 * \brief 6 * This file provides constants and function prototypes 7 * for the API for the CMAC method in the Crypto block driver. 8 * 9 ******************************************************************************** 10 * \copyright 11 * Copyright (c) (2020-2022), 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_CRYPTO_CORE_CMAC_V1_H) 30 #define CY_CRYPTO_CORE_CMAC_V1_H 31 32 #include "cy_crypto_common.h" 33 34 #if defined(CY_IP_MXCRYPTO) && defined(CY_CRYPTO_CFG_HW_V1_ENABLE) 35 36 #if defined(__cplusplus) 37 extern "C" { 38 #endif 39 40 #if (CPUSS_CRYPTO_AES == 1) && defined(CY_CRYPTO_CFG_CMAC_C) 41 42 /** \cond INTERNAL */ 43 44 /* The bit string used to generate sub-keys */ 45 #define CY_CRYPTO_CMAC_RB (0x87u) 46 47 /* The structure to store the AES-CMAC context */ 48 typedef struct 49 { 50 uint32_t *block; 51 uint32_t *k; 52 uint32_t *temp; 53 } cy_stc_crypto_v1_cmac_state_t; 54 55 /* The structure to define used memory buffers */ 56 typedef struct 57 { 58 uint32_t k[CY_CRYPTO_AES_BLOCK_SIZE_U32]; 59 uint32_t block0[CY_CRYPTO_AES_BLOCK_SIZE_U32]; 60 uint32_t block1[CY_CRYPTO_AES_BLOCK_SIZE_U32]; 61 cy_stc_crypto_v1_cmac_state_t cmacState; 62 } cy_stc_crypto_v1_cmac_buffers_t; 63 64 /* The function prototypes */ 65 void Cy_Crypto_Core_V1_Cmac_Init(cy_stc_crypto_v1_cmac_state_t *cmacState, 66 uint32_t *temp, 67 uint32_t *block, 68 uint32_t *k); 69 70 void Cy_Crypto_Core_V1_Cmac_Start(CRYPTO_Type *base, 71 cy_stc_crypto_aes_state_t *aesState, 72 cy_stc_crypto_v1_cmac_state_t *cmacState); 73 74 void Cy_Crypto_Core_V1_Cmac_Update(CRYPTO_Type *base, cy_stc_crypto_aes_state_t *aesState, 75 cy_stc_crypto_v1_cmac_state_t *cmacState, 76 uint8_t const *message, 77 uint32_t messageSize); 78 79 void Cy_Crypto_Core_V1_Cmac_Finish(CRYPTO_Type *base, 80 cy_stc_crypto_aes_state_t *aesState, 81 cy_stc_crypto_v1_cmac_state_t *cmacState, 82 uint8_t* cmac); 83 84 cy_en_crypto_status_t Cy_Crypto_Core_V1_Cmac(CRYPTO_Type *base, 85 uint8_t const *message, 86 uint32_t messageSize, 87 uint8_t const *key, 88 cy_en_crypto_aes_key_length_t keyLength, 89 uint8_t *cmac, 90 cy_stc_crypto_aes_state_t *aesState); 91 92 /** \endcond */ 93 94 95 #endif /* (CPUSS_CRYPTO_AES == 1) && defined(CY_CRYPTO_CFG_CMAC_C) */ 96 97 #if defined(__cplusplus) 98 } 99 #endif 100 101 #endif /* defined(CY_IP_MXCRYPTO) && defined(CY_CRYPTO_CFG_HW_V1_ENABLE) */ 102 103 #endif /* #if !defined (CY_CRYPTO_CORE_CMAC_V1_H) */ 104 105 106 /* [] END OF FILE */ 107