/*!
* @file     Crypto_Aes256.h
*
* @version  1.0.0
*
* @brief    This file contains all the functions prototypes for the CRYP firmware library
 *          
* @attention
*
* Project Name      : AUTOSAR MCAL
*
* Platform          : Arm
*
* Autosar Standard  : Classic Platform 4.4.0
*
* Compiled Version  : G32A10xx_MCAL_1_0_0_15-Nov-25
*
* Copyright (C) 2026 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
*
* The program is only for reference, which is distributed in the hope
* that it will be usefull and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the Geehy Semiconductor Software License Agreement for the governing permissions
* and limitations under the License.
*/

/* Define to prevent recursive inclusion */
#ifndef CRYPTO_AES256_H
#define CRYPTO_AES256_H

#ifdef __cplusplus
  extern "C" {
#endif

/* Includes */
#include "StdRegMacros.h"
#include "Crypto_Cse.h"
#include "Crypto_Common.h"

/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup CRYPTO_Driver
  * @brief CRYPTO driver modules
  @{
*/

/** @defgroup CRYPTO_Macros
  @{
*/
/*******************************************************************************
                    VENDOR ID & AUTOSAR VERSION INFO
*******************************************************************************/
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define CRYPTO_AES256_H_VENDOR_ID                         0x00C1U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CRYPTO_AES256_H_AR_RELEASE_MAJOR_VERSION          0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CRYPTO_AES256_H_AR_RELEASE_MINOR_VERSION          0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CRYPTO_AES256_H_AR_RELEASE_REVISION_VERSION       0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CRYPTO_AES256_H_SW_MAJOR_VERSION                  0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CRYPTO_AES256_H_SW_MINOR_VERSION                  0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CRYPTO_AES256_H_SW_PATCH_VERSION                  0x00U
/**@} end of group CRYPTO_Macros */
/*******************************************************************************
                                ENUMS && STRUCT
*******************************************************************************/
/** @defgroup CRYPTO_Enumerations
  @{
*/
/**
 * @brief AES256 Algorithm endian
 */
typedef enum 
{
    AES256_LITTLE_ENDIAN   = 0,    //!< Encryption 
    AES256_BIT_ENDIAN      = 1     //!< Decryption 
} Crypto_Aes256_BitEndianType;

/**
 * @brief AES256 Algorithm Mode
 */
typedef enum
{
    AES256_ALGOMODE_AES_ECB  = 0x00,  //!< AES ECB Mode 
    AES256_ALGOMODE_AES_CBC  = 0x01,  //!< AES CBC Mode 
    AES256_ALGOMODE_AES_CMAC = 0x02,  //!< AES CMAC Mode 
    AES256_ALGOMODE_AES_MPC  = 0x03,  //!< AES MPC Mode 
    AES256_ALGOMODE_AES_CTR  = 0x04   //!< AES CTR Mode 
} Crypto_Aes256_AlgoModeType;

/**
 * @brief AES256 flag
 */
typedef enum
{
    AES256_FLAG_BUSY             =  0, //!< Busy Bit 
    AES256_FLAG_KEY_INT_FINISH   =  1, //!< Key expand finish interrupt flag
    AES256_FLAG_DATA_INT_FINISH  =  2  //!< Data finish interrupt flag 
} Crypto_Aes256_FlagType;

/**
 * @brief CRYP interrupt
 */
typedef enum
{
    AES256_INT_KEYEXPAND         = 0x01, //!<  Key expand finish interrupt enable
    AES256_INT_DATA              = 0x02 //!< encrypt or decrypt finish interrupt enable 
} Crypto_Aes256_InterruptType;

/**@} end of group CRYPTO_Enumerations */
/** @defgroup CRYPTO_Structure
  @{
*/
/**
 * @brief CRYP Config structure definition
 */
typedef struct
{
    Crypto_Aes256_OpcodeType       algoOpcode; //!< Algorithm Opcode Select 
    Crypto_Aes256_AlgoModeType     algoMode; //!< Algorithm Mode Select 
    Crypto_Aes256_KeySizeType      keySize; //!< Key Size Select 
} Crypto_Aes256_ConfigType;

/**
 * @brief   AES256 KeyConfig structure definition
 */
typedef struct
{
    uint32_t aes_key[8]; //!< key0-7 
} Crypto_Aes256_KeyConfigType;

/**
 * @brief  AES256 Initialization Vectors (IV) structure definition
 */
typedef struct
{
    uint32 IV[4]; //!< Initialization Vector 
} Crypto_Aes256_IvConfigType;
/**@} end of group CRYPTO_Structure */
/*******************************************************************************
                            FUNCTION DECLARATIONS
*******************************************************************************/
/** @defgroup CRYPTO_Fuctions
  @{
*/
/** CRYPTO Configuration */
FUNC(void, CRYPTO_CODE) Crypto_Aes256_Config(P2CONST(Crypto_Aes256_ConfigType, AUTOMATIC, CRYPTO_APPL_CONST) crypConfig);
FUNC(void, CRYPTO_CODE) Crypto_Aes256_Start(void);
/** CRYPTO Interrupt and flag */
FUNC(void, CRYPTO_CODE) Crypto_Aes256_EnableInterrupt(VAR(boolean, AUTOMATIC) Enstatus);
FUNC(void, CRYPTO_CODE) Crypto_Aes256_EnableKeyExpandInterrupt(VAR(boolean, AUTOMATIC) Enstatus);

FUNC(uint8, CRYPTO_CODE) Crypto_Aes256_ExpandInterruptStatus(void);

FUNC(void, CRYPTO_CODE) Crypto_Aes256_modeSet(VAR(Crypto_Aes256_OpcodeType, AUTOMATIC) modeCfg);

/** High Level AES */
FUNC(Crypto_Cse_ErrorCodeType, CRYPTO_CODE) Crypto_Aes256_GenerateEcb( VAR(Crypto_Aes256_OpcodeType, AUTOMATIC) mode, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) key, 
                       VAR(Crypto_Aes256_KeySizeType, AUTOMATIC) keysize, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) input,
                       VAR(uint32, AUTOMATIC) length, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) output,VAR(Crypto_ProcessingType, AUTOMATIC) syncmode);
                           
FUNC(Crypto_Cse_ErrorCodeType, CRYPTO_CODE) Crypto_Aes256_GenerateCbc( VAR(Crypto_Aes256_OpcodeType, AUTOMATIC) mode, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) key,
                       VAR(Crypto_Aes256_KeySizeType, AUTOMATIC) keysize, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) IV, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) input,
                       VAR(uint32, AUTOMATIC) length, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) output,VAR(Crypto_ProcessingType, AUTOMATIC) syncmode);

FUNC(Crypto_Cse_ErrorCodeType, CRYPTO_CODE) Crypto_Aes256_GenerateCtr( VAR(Crypto_Aes256_OpcodeType, AUTOMATIC) mode, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) key,
                       VAR(Crypto_Aes256_KeySizeType, AUTOMATIC) keysize, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) IV, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) input,
                       VAR(uint32, AUTOMATIC) length, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) output,VAR(Crypto_ProcessingType, AUTOMATIC) syncmode);

FUNC(Crypto_Cse_ErrorCodeType, CRYPTO_CODE) Crypto_Aes256_GenerateCmac( P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) key, VAR(Crypto_Aes256_KeySizeType, AUTOMATIC) keysize, 
                       P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) IV, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) input,
                       VAR(uint32, AUTOMATIC) length, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) output,VAR(Crypto_ProcessingType, AUTOMATIC) syncmode);
                       
FUNC(Crypto_Cse_ErrorCodeType, CRYPTO_CODE) Crypto_Aes256_GenerateMpc(P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) input, VAR(uint32, AUTOMATIC) length, 
                       P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) output,VAR(Crypto_ProcessingType, CSM_CONST) syncmode);

FUNC(boolean, CRYPTO_CODE) Crypto_Aes256_IsBusy(void);

FUNC(void, CRYPTO_CODE) Crypto_Aes256_BlockProcessAsync(VAR(uint32, AUTOMATIC) blockNum, VAR(uint32, AUTOMATIC) dataLen,
                    P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) input);

FUNC(Crypto_Cse_ErrorCodeType, CRYPTO_CODE) Crypto_Aes256_BlockProcessContinueAsync(VAR(uint32, AUTOMATIC) curBlkCnt,VAR(uint32, AUTOMATIC) dataLen,
      VAR(uint32, AUTOMATIC) blockNum, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) input);

FUNC(Crypto_Cse_ErrorCodeType, CRYPTO_CODE) Crypto_Aes256_BlockProcessMacContinueAsync(VAR(uint32, AUTOMATIC) curBlkCnt,VAR(uint32, AUTOMATIC) dataLen,
      VAR(uint32, AUTOMATIC) blockNum, P2CONST(uint8, AUTOMATIC, CRYPTO_APPL_CONST) input);

FUNC(void, CRYPTO_CODE) Crypto_Aes256_ClearStatus(void);

/**@} end of group CRYPTO_Fuctions */
#ifdef __cplusplus
}
#endif
#endif 
/**@} end of group CRYPTO_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */





