/***************************************************************************//** * \file cy_crypto_core_cmac.h * \version 2.40 * * \brief * This file provides constants and function prototypes * for the API for the CMAC method in the Crypto block driver. * ******************************************************************************** * Copyright 2016-2020 Cypress Semiconductor Corporation * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ #if !defined (CY_CRYPTO_CORE_CMAC_H) #define CY_CRYPTO_CORE_CMAC_H #include "cy_device.h" #if defined (CY_IP_MXCRYPTO) #include "cy_crypto_common.h" #if defined(__cplusplus) extern "C" { #endif #if (CPUSS_CRYPTO_AES == 1) #include "cy_crypto_core_cmac_v1.h" #include "cy_crypto_core_cmac_v2.h" /** \cond INTERNAL */ typedef cy_en_crypto_status_t (*cy_crypto_cmac_func_t)(CRYPTO_Type *base, uint8_t const *src, uint32_t srcSize, uint8_t const *key, cy_en_crypto_aes_key_length_t keyLength, uint8_t *dst, cy_stc_crypto_aes_state_t *aesState); /** \endcond */ /** * \addtogroup group_crypto_lld_mac_functions * \{ */ /******************************************************************************* * Function Name: Cy_Crypto_Core_Cmac ****************************************************************************//** * * Calculates the AES Cipher-based Message Authentication Code (CMAC) on the input * message with the provided key. * * \param base * The pointer to the CRYPTO instance. * * \param message * The pointer to the source plain text. Must be 4-byte aligned. * * \param messageSize * The size of the source plain text in bytes. * * \param key * The pointer to the encryption key. Must be 4-byte aligned. * * \param keyLength * \ref cy_en_crypto_aes_key_length_t * * \param cmac * The pointer to the calculated CMAC. * * \param aesState * The pointer to the AES state structure allocated by the user. The user * must not modify anything in this structure. * * \return * \ref cy_en_crypto_status_t * *******************************************************************************/ __STATIC_INLINE cy_en_crypto_status_t Cy_Crypto_Core_Cmac(CRYPTO_Type *base, uint8_t const *message, uint32_t messageSize, uint8_t const *key, cy_en_crypto_aes_key_length_t keyLength, uint8_t *cmac, cy_stc_crypto_aes_state_t *aesState) { cy_en_crypto_status_t tmpResult; if (CY_CRYPTO_V1) { tmpResult = Cy_Crypto_Core_V1_Cmac(base, message, messageSize, key, keyLength, cmac, aesState); } else { tmpResult = Cy_Crypto_Core_V2_Cmac(base, message, messageSize, key, keyLength, cmac, aesState); } return tmpResult; } /** \} group_crypto_lld_mac_functions */ #endif /* (CPUSS_CRYPTO_AES == 1) */ #if defined(__cplusplus) } #endif #endif /* CY_IP_MXCRYPTO */ #endif /* #if !defined (CY_CRYPTO_CORE_CMAC_H) */ /* [] END OF FILE */