/*!
* @file     Crypto_Impl.h
*
* @version  1.0.0
*
* @brief    AUTOSAR Crypto Driver header file
 *           
* @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.
*/

#ifndef CRYPTO_IMPL_H
#define CRYPTO_IMPL_H

#ifdef __cplusplus
extern "C"{
#endif

#include "SchM_Crypto.h"
#include "Crypto_Cse.h"
#include "Crypto_Cfg.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_IMPL_H_VENDOR_ID                         0x00C1U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CRYPTO_IMPL_H_AR_RELEASE_MAJOR_VERSION          0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CRYPTO_IMPL_H_AR_RELEASE_MINOR_VERSION          0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CRYPTO_IMPL_H_AR_RELEASE_REVISION_VERSION       0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CRYPTO_IMPL_H_SW_MAJOR_VERSION                  0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CRYPTO_IMPL_H_SW_MINOR_VERSION                  0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CRYPTO_IMPL_H_SW_PATCH_VERSION                  0x00U

/*******************************************************************************
                             VERSION CHECK
*******************************************************************************/
/* Make sure the vendor id is the same between Crypto_Impl.h and Crypto_Cfg.h */
#if (CRYPTO_IMPL_H_VENDOR_ID != CRYPTO_CFG_H_VENDOR_ID)
    #error "Vendor id mismatch between Crypto_Impl.h and Crypto_Cfg.h"
#endif
/* Make sure the AUTOSAR major version number is the same between Crypto_Impl.h and Crypto_Cfg.h */
#if (CRYPTO_IMPL_H_AR_RELEASE_MAJOR_VERSION != CRYPTO_CFG_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR major version number mismatch between Crypto_Impl.h and Crypto_Cfg.h"
#endif
/* Make sure the AUTOSAR minor version number is the same between Crypto_Impl.h and Crypto_Cfg.h */
#if (CRYPTO_IMPL_H_AR_RELEASE_MINOR_VERSION != CRYPTO_CFG_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR minor version number mismatch between Crypto_Impl.h and Crypto_Cfg.h"
#endif
/* Make sure the AUTOSAR revision version number is the same between Crypto_Impl.h and Crypto_Cfg.h */
#if (CRYPTO_IMPL_H_AR_RELEASE_REVISION_VERSION != CRYPTO_CFG_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR revision version number mismatch between Crypto_Impl.h and Crypto_Cfg.h"
#endif
/* Make sure the software major version number is the same between Crypto_Impl.h and Crypto_Cfg.h */
#if (CRYPTO_IMPL_H_SW_MAJOR_VERSION != CRYPTO_CFG_H_SW_MAJOR_VERSION)
    #error "Software major version number mismatch between Crypto_Impl.h and Crypto_Cfg.h"
#endif
/* Make sure the software minor version number is the same between Crypto_Impl.h and Crypto_Cfg.h */
#if (CRYPTO_IMPL_H_SW_MINOR_VERSION != CRYPTO_CFG_H_SW_MINOR_VERSION)
    #error "Software minor version number mismatch between Crypto_Impl.h and Crypto_Cfg.h"
#endif
/* Make sure the software patch version number is the same between Crypto_Impl.h and Crypto_Cfg.h */
#if (CRYPTO_IMPL_H_SW_PATCH_VERSION != CRYPTO_CFG_H_SW_PATCH_VERSION)
    #error "Software patch version number mismatch between Crypto_Impl.h and Crypto_Cfg.h"
#endif
/* Make sure the vendor id is the same between Crypto_Impl.h and Crypto_Cse.h */
#if (CRYPTO_IMPL_H_VENDOR_ID != CRYPTO_CSE_H_VENDOR_ID)
    #error "Vendor id mismatch between Crypto_Impl.h and Crypto_Cse.h"
#endif
/* Make sure the AUTOSAR major version number is the same between Crypto_Impl.h and Crypto_Cse.h */
#if (CRYPTO_IMPL_H_AR_RELEASE_MAJOR_VERSION != CRYPTO_CSE_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR major version number mismatch between Crypto_Impl.h and Crypto_Cse.h"
#endif
/* Make sure the AUTOSAR minor version number is the same between Crypto_Impl.h and Crypto_Cse.h */
#if (CRYPTO_IMPL_H_AR_RELEASE_MINOR_VERSION != CRYPTO_CSE_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR minor version number mismatch between Crypto_Impl.h and Crypto_Cse.h"
#endif
/* Make sure the AUTOSAR revision version number is the same between Crypto_Impl.h and Crypto_Cse.h */
#if (CRYPTO_IMPL_H_AR_RELEASE_REVISION_VERSION != CRYPTO_CSE_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR revision version number mismatch between Crypto_Impl.h and Crypto_Cse.h"
#endif
/* Make sure the software major version number is the same between Crypto_Impl.h and Crypto_Cse.h */
#if (CRYPTO_IMPL_H_SW_MAJOR_VERSION != CRYPTO_CSE_H_SW_MAJOR_VERSION)
    #error "Software major version number mismatch between Crypto_Impl.h and Crypto_Cse.h"
#endif
/* Make sure the software minor version number is the same between Crypto_Impl.h and Crypto_Cse.h */
#if (CRYPTO_IMPL_H_SW_MINOR_VERSION != CRYPTO_CSE_H_SW_MINOR_VERSION)
    #error "Software minor version number mismatch between Crypto_Impl.h and Crypto_Cse.h"
#endif
/* Make sure the software patch version number is the same between Crypto_Impl.h and Crypto_Cse.h */
#if (CRYPTO_IMPL_H_SW_PATCH_VERSION != CRYPTO_CSE_H_SW_PATCH_VERSION)
    #error "Software patch version number mismatch between Crypto_Impl.h and Crypto_Cse.h"
#endif

/*******************************************************************************
                            LOCAL DEFINES AND MACROS
*******************************************************************************/
/**
* Correct verification status for the MAC verification function.
* VERIFICATION_STATUS = (0 ~= (MAC calc - MAC ref))
*/
#define CSE_MAC_VERIFY_CORRECT       ((uint16)0x0000U)
/**@} end of group CRYPTO_Macros */
/*******************************************************************************
                            FUNCTION DECLARATIONS
*******************************************************************************/
/** @defgroup CRYPTO_Fuctions
  @{
*/
#define CRYPTO_START_SEC_CODE
#include "Crypto_MemMap.h"

FUNC(void, CRYPTO_CODE) Crypto_Impl_CallBackNotification(VAR(Crypto_Cse_ErrorCodeType, AUTOMATIC) ErrorCode);

#if (CRYPTO_KEY_GEN_CONFIGURED == STD_ON)
FUNC(Std_ReturnType, CRYPTO_CODE) Crypto_Impl_GenerateRandomKey(VAR(uint32, AUTOMATIC) KeyId);
#endif

FUNC(Crypto_KeyStatusType, CRYPTO_CODE) Crypto_Impl_CheckKeyId(VAR(uint32, AUTOMATIC) KeyId);

FUNC(Crypto_ElementStatusType, CRYPTO_CODE) Crypto_Impl_CheckKeyElementId(
    VAR(uint32, AUTOMATIC) KeyIndex,
    VAR(uint32, AUTOMATIC) KeyElementId);

FUNC(Std_ReturnType, CRYPTO_CODE) Crypto_Impl_ProcessJob(
    VAR(uint32, AUTOMATIC) ObjectIndex,
    P2VAR(Crypto_JobType, AUTOMATIC, CRYPTO_APPL_DATA) JobPtr);

FUNC(Std_ReturnType, CRYPTO_CODE) Crypto_Impl_CancelJob(
    VAR(uint32, AUTOMATIC) ObjectIndex,
    P2CONST(Crypto_JobInfoType, AUTOMATIC, CRYPTO_APPL_CONST) JobPtr);

FUNC(void, CRYPTO_CODE) Crypto_Impl_MainFunction(void);

FUNC(Std_ReturnType, CRYPTO_CODE) Crypto_Impl_Init(void);

#define CRYPTO_STOP_SEC_CODE
#include "Crypto_MemMap.h"
/**@} end of group CRYPTO_Fuctions */
/*******************************************************************************
                            GLOBAL VARIABLES
*******************************************************************************/
/** @defgroup CRYPTO_Variable
  @{
*/
#define CRYPTO_START_SEC_VAR_NO_INIT_UNSPECIFIED
#include "Crypto_MemMap.h"

extern P2FUNC(void, CRYPTO_CODE, Crypto_Callback) (const Crypto_JobType* job, Std_ReturnType result);
extern VAR(Crypto_Cse_HardwareStateType, CRYPTO_VAR) g_cseHardwareState;

#define CRYPTO_STOP_SEC_VAR_NO_INIT_UNSPECIFIED
#include "Crypto_MemMap.h"

#define CRYPTO_START_SEC_VAR_INIT_UNSPECIFIED
#include "Crypto_MemMap.h"

extern P2VAR(Crypto_ObjectType, AUTOMATIC, CRYPTO_APPL_DATA) Crypto_ListObject[CRYPTO_DRIVER_OBJECT_NUMBER];

#if (CRYPTO_KEY_EXPORT_CONFIGURED == STD_ON)

extern P2VAR(Crypto_Cse_ExportKeyType, AUTOMATIC, CRYPTO_APPL_DATA) Crypto_ListExportKey[CRYPTO_KEY_EXPROT_ELEMENTS_NUMBER];
#endif /* CRYPTO_KEY_EXPORT_CONFIGURED == STD_ON */

#if (CRYPTO_KEYS_CONFIGURED == 1U)

extern P2VAR(Crypto_KeyType, AUTOMATIC, CRYPTO_APPL_DATA) Crypto_KeyList[CRYPTO_KEYS_NUMBER];

extern P2VAR(Crypto_KeyElementType, AUTOMATIC, CRYPTO_APPL_DATA) Crypto_KeyElementList[CRYPTO_KEY_ELEMENTS_NUMBER];
#endif /* CRYPTO_KEYS_CONFIGURED == 1U */

#define CRYPTO_STOP_SEC_VAR_INIT_UNSPECIFIED
#include "Crypto_MemMap.h"
/**@} end of group CRYPTO_Variable */
#ifdef __cplusplus
}
#endif

#endif /* CRYPTO_IMPL_H */
/**@} end of group CRYPTO_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */
