/********************************************************************************************************************** * COPYRIGHT * ------------------------------------------------------------------------------------------------------------------- * \verbatim * Copyright (c) 2025 by Vector Informatik GmbH. All rights reserved. * * This software is copyright protected and proprietary to Vector Informatik GmbH. * Vector Informatik GmbH grants to you only those rights as set out in the license conditions. * All other rights remain with Vector Informatik GmbH. * \endverbatim * ------------------------------------------------------------------------------------------------------------------- * FILE DESCRIPTION * -----------------------------------------------------------------------------------------------------------------*/ /* \file CryIf.h * \brief MICROSAR Crypto Interface (CRYIF) * \details The Crypto Interface module provides a unique interface to manage different Crypto HW and SW * solutions. *********************************************************************************************************************/ /********************************************************************************************************************** * REVISION HISTORY * ------------------------------------------------------------------------------------------------------------------- * Version Date Author Change Id Description * ------------------------------------------------------------------------------------------------------------------- * 01.00.00 2016-12-01 vismss - Initial creation of Crypto Interface * 01.00.01 2016-12-06 visrpp ESCAN00093184 Renamed CryIf_KeyValidSet to CryIf_KeySetValid * 01.00.02 2016-12-16 vismss ESCAN00093334 Adapted CryIf_CallbackNotification * 01.00.03 2017-01-24 vismss ESCAN00093699 Correction of error and service id codes * 01.01.00 2017-02-14 visgut FEATC-815 Support CRYIF * Support CryIf_CancelJob * Fix Reference of Driver Object * 01.02.00 2017-05-05 visrpp FEATC-1228 FEAT-2902 Release of AR4.3 CryIf * 02.00.00 2017-05-12 vismaw ESCAN00095159 Validity of cryIfKeyId is not checked * Silent BSW * 04.00.00 2018-11-07 vismaw STORYC-6541 Support redirection of input/output buffers from/to key elements * STORYC-6546 Support partial key element copy * 04.01.00 2019-03-15 vismaw STORYC-7654 Release of CryIf 4.x * STORYC-5723 MISRA-C:2012 Compliance * 05.00.00 2019-12-04 visenc SEC-19 Asynchronous Key Handling * ESCAN00105151 Compiler error due to incompatible function pointer declaration and * function definition * 05.01.00 2020-08-18 vismxe SEC-1838 Migration to QAC Helix * vismxe ESCAN00105785 Fix comment before case label not recognized by compiler * 06.00.00 2023-02-28 rstemmler SEC-5474 Introduce APIs KeyGetStatus and KeySetInvalid * SEC-3020 Add stub functions for non-autosar services CertificateVerify and * CertificateParse * SEC-5682 Improve parameter checks in CryIf_KeyElementSet * SEC-3644 _MemMap migration * ESCAN00114084 Avoid possible endless loop when copying keys between crypto drivers * 07.00.00 2023-04-26 kwiedom HSM-3726 Multi Core support: remove CryIf_ModuleInitialized variable and checks * 07.01.00 2023-11-07 coechsler ESCAN00116074 CryIf_KeyCopy may not copy key elements as expected when copying from one driver to another * main-1 2024-04-23 viseag CRY-717 Change history is maintained in the global ChangeHistory.txt file starting with this release. *********************************************************************************************************************/ #if !defined (CRYIF_H) # define CRYIF_H /********************************************************************************************************************** * INCLUDES *********************************************************************************************************************/ # include "Std_Types.h" # include "Crypto_GeneralTypes.h" # include "CryIf_Cfg.h" # include "CryIf_Cbk.h" /********************************************************************************************************************** * GLOBAL CONSTANT MACROS *********************************************************************************************************************/ /* Vendor and module identification */ # define CRYIF_VENDOR_ID (30u) # define CRYIF_MODULE_ID (112u) /* AUTOSAR Software specification version information */ # define CRYIF_AR_RELEASE_MAJOR_VERSION (4u) # define CRYIF_AR_RELEASE_MINOR_VERSION (4u) # define CRYIF_AR_RELEASE_REVISION_VERSION (0u) /* ----- Component version information (decimal version of ALM implementation package) ----- */ # define CRYIF_SW_MAJOR_VERSION (9u) # define CRYIF_SW_MINOR_VERSION (1u) # define CRYIF_SW_PATCH_VERSION (0u) # define CRYIF_INSTANCE_ID_DET (0x00u) /* ----- API service IDs ----- */ # define CRYIF_SID_INIT (0x00u) /*!< Service ID: CryIf_Init() */ # define CRYIF_SID_GET_VERSION_INFO (0x01u) /*!< Service ID: CryIf_GetVersionInfo() */ # define CRYIF_SID_PROCESS_JOB (0x02u) /*!< Service ID: CryIf_ProcessJob() */ # define CRYIF_SID_CANCEL_JOB (0x03u) /*!< Service ID: CryIf_CancelJob() */ # define CRYIF_SID_KEY_ELEMENT_SET (0x04u) /*!< Service ID: CryIf_KeyElementSet() */ # define CRYIF_SID_KEY_SET_VALID (0x05u) /*!< Service ID: CryIf_KeySetValid() */ # define CRYIF_SID_KEY_ELEMENT_GET (0x06u) /*!< Service ID: CryIf_KeyElementGet() */ # define CRYIF_SID_KEY_ELEMENT_COPY (0x0fu) /*!< Service ID: CryIf_KeyElementCopy() */ # define CRYIF_SID_KEY_ELEMENT_COPY_PARTIAL (0x12u) /*!< Service ID: CryIf_KeyElementCopyPartial() */ # define CRYIF_SID_KEY_COPY (0x10u) /*!< Service ID: CryIf_KeyCopy() */ # define CRYIF_SID_RANDOM_SEED (0x07u) /*!< Service ID: CryIf_RandomSeed() */ # define CRYIF_SID_KEY_GENERATE (0x08u) /*!< Service ID: CryIf_KeyGenerate() */ # define CRYIF_SID_KEY_DERIVE (0x09u) /*!< Service ID: CryIf_KeyDerive() */ # define CRYIF_SID_KEY_EXCHANGE_CALC_PUB_VAL (0x0au) /*!< Service ID: CryIf_KeyExchangeCalcPubVal() */ # define CRYIF_SID_KEY_EXCHANGE_CALC_SECRET (0x0bu) /*!< Service ID: CryIf_KeyExchangeCalcSecret() */ # define CRYIF_SID_CERTIFICATE_PARSE (0x0cu) /*!< Service ID: CryIf_CertificateParse() */ # define CRYIF_SID_CERTIFICATE_VERIFY (0x11u) /*!< Service ID: CryIf_CertificateVerify() */ # define CRYIF_SID_KEY_GET_STATUS (0x13u) /*!< Service ID: CryIf_KeyGetStatus() */ # define CRYIF_SID_KEY_SET_INVALID (0x14u) /*!< Service ID: CryIf_KeySetInvalid() */ # define CRYIF_SID_CUSTOM_SYNC (0x15u) /*!< Service ID: CryIf_CustomSync()*/ /* ----- Error codes ----- */ # define CRYIF_E_NO_ERROR (0xFFu) /*!< used to check if no error occurred - use a value unequal to any error code */ # define CRYIF_E_UNINIT (0x00u) /*!< Error code: API service used without module initialization */ # define CRYIF_E_INIT_FAILED (0x01u) /*!< Error code: Initialisation of CRYIF module failed */ # define CRYIF_E_PARAM_POINTER (0x02u) /*!< Error code: API request called with invalid parameter (null pointer) */ # define CRYIF_E_PARAM_HANDLE (0x03u) /*!< Error code: API request called with invalid parameter (out of range) */ # define CRYIF_E_PARAM_VALUE (0x04u) /*!< Error code: API request called with invalid parameter (invalid value) */ # define CRYIF_E_ALREADY_INITIALIZED (0x11u) /*!< Error code: The service CryIf_Init() is called while the module is already initialized */ # define CRYIF_E_REQUEST_NOT_SUPPORTED (0x12u) /*!< Error code: API request called but request is not supported by Crypto */ /* ----- Modes ----- */ # define CRYIF_UNINIT (0x00u) /*!< State: Module was not initialized */ # define CRYIF_INIT (0x01u) /*!< State: Module is initialized */ /* ----- Other constants ----- */ # define CRYIF_UINT32_MAX (0xFFFFFFFFuL) /********************************************************************************************************************** * GLOBAL FUNCTION MACROS *********************************************************************************************************************/ # define CryIf_NoUInt32Overflow(Value1, Value2) (((Value2) <= (uint32)(CRYIF_UINT32_MAX - Value1)) ? TRUE:FALSE ) /********************************************************************************************************************** * GLOBAL FUNCTION PROTOTYPES *********************************************************************************************************************/ # define CRYIF_START_SEC_CODE # include "CryIf_MemMap.h" /* PRQA S 5087 */ /* MD_MSR_MemMap */ /********************************************************************************************************************** * CryIf_InitMemory() *********************************************************************************************************************/ /*! \brief Power-up memory initialization. * \details Initialize component variables at power up. No action is performed, CryIf is stateless. * \pre Module is uninitialized. * \context TASK * \reentrant FALSE * \synchronous TRUE *********************************************************************************************************************/ FUNC(void, CRYIF_CODE) CryIf_InitMemory(void); /********************************************************************************************************************** * CryIf_Init() *********************************************************************************************************************/ /*! \brief Initialization function. * \details This function initializes the module CryIf. No action is performed, CryIf is stateless. * \pre Interrupts are disabled. * \context TASK * \reentrant FALSE * \synchronous TRUE *********************************************************************************************************************/ FUNC(void, CRYIF_CODE) CryIf_Init(void); # if (CRYIF_VERSION_INFO_API == STD_ON) /********************************************************************************************************************** * CryIf_GetVersionInfo() *********************************************************************************************************************/ /*! \brief Returns the version information. * \details CryIf_GetVersionInfo() returns version information, vendor ID and AUTOSAR module ID of the component. * \param[out] versioninfo Pointer to where to store the version information. Parameter must not be NULL. * \pre - * \context TASK|ISR2 * \reentrant TRUE * \synchronous TRUE *********************************************************************************************************************/ FUNC(void, CRYIF_CODE) CryIf_GetVersionInfo(P2VAR(Std_VersionInfoType, AUTOMATIC, CRYIF_APPL_VAR) versioninfo); # endif /* (CRYIF_VERSION_INFO_API == STD_ON) */ /********************************************************************************************************************** * CryIf_ProcessJob() *********************************************************************************************************************/ /*! \brief Process the received job. * \details This interface dispatches the received jobs to the configured crypto driver object. * \param[in] channelId Holds the identifier of the crypto channel. * \param[in,out] job Pointer to the configuration of the job. Contains structures with user and * primitive relevant information. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \return CRYPTO_E_KEY_NOT_VALID Request failed, the key is not valid. * \return CRYPTO_E_KEY_NOT_AVAILABLE Request failed, the key is not available. * \return CRYPTO_E_QUEUE_FULL Request failed, the queue is full. * \return CRYPTO_E_SMALL_BUFFER Request failed, the provided buffer is too small to store the result. * \return CRYPTO_E_CUSTOM_ERROR Remote processing failed. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \spec requires job->jobPrimitiveInfo != NULL_PTR; * requires job->jobPrimitiveInfo->primitiveInfo != NULL_PTR; * \endspec *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_ProcessJob(uint32 channelId, P2VAR(Crypto_JobType, AUTOMATIC, CRYIF_APPL_VAR) job); /********************************************************************************************************************** * CryIf_CancelJob() *********************************************************************************************************************/ /*! \brief Cancels the received job. * \details This interface removes the provided job from the underlying Crypto Driver Object queue. * \param[in] channelId Holds the identifier of the crypto channel. * \param[in,out] job Pointer to the configuration of the job. Contains structures with user and * primitive relevant information. * \return E_OK Request successful, job has been removed. * \return E_NOT_OK Request failed, job could not be removed. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \trace CREQ-127561 * \spec requires job->jobPrimitiveInfo != NULL_PTR; * requires job->jobPrimitiveInfo->primitiveInfo != NULL_PTR; * requires job->jobInfo != NULL_PTR; * \endspec *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_CancelJob(uint32 channelId, P2VAR(Crypto_JobType, AUTOMATIC, CRYIF_APPL_VAR) job); /********************************************************************************************************************** * CryIf_KeyElementSet() *********************************************************************************************************************/ /*! \brief Sets a key element. * \details This function shall dispatch the set key element function to the configured crypto driver object. * \param[in] cryIfKeyId Holds the identifier of the key whose key element shall be set. * \param[in] keyElementId Holds the identifier of the key element which shall be set. * \param[in] keyPtr Holds the pointer to the key data which shall be set as key element. * \param[in] keyLength Contains the length of the key element in bytes. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \return CRYPTO_E_KEY_WRITE_FAIL Request failed, write access was denied. * \return CRYPTO_E_KEY_NOT_AVAILABLE Request failed, the key is not available. * \return CRYPTO_E_KEY_SIZE_MISMATCH Request failed, the key element size does not match size of provided * data. * \pre - * \note NULL_PTR check for P2CONST keyPtr is not executed to save runtime. * Zero value check for keyLength is not executed to be able to support key deletion. * \context TASK * \reentrant TRUE * \synchronous TRUE * \trace CREQ-127562 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeyElementSet(uint32 cryIfKeyId, uint32 keyElementId, P2CONST(uint8, AUTOMATIC, CRYIF_APPL_DATA) keyPtr, uint32 keyLength); /********************************************************************************************************************** * CryIf_KeySetValid() *********************************************************************************************************************/ /*! \brief Sets the key to valid. * \details This function shall dispatch the set key valid function to the configured crypto driver object. * \param[in] cryIfKeyId Holds the identifier of the key whose key elements shall be set to valid. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \trace CREQ-127563 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeySetValid(uint32 cryIfKeyId); /********************************************************************************************************************** * CryIf_KeyElementGet() *********************************************************************************************************************/ /*! \brief Exports the key element. * \details This function shall dispatch the get key element function to the configured crypto driver object. * \param[in] cryIfKeyId Holds the identifier of the key whose key element shall be set. * \param[in] keyElementId Holds the identifier of the key element which shall be set. * \param[in,out] resultPtr Holds the pointer to the key data which shall be set as key element. * \param[in,out] resultLengthPtr Contains the length of the key element in bytes. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \return CRYPTO_E_KEY_READ_FAIL Request failed, read access was denied. * \return CRYPTO_E_KEY_NOT_AVAILABLE Request failed, the key is not available. * \return CRYPTO_E_SMALL_BUFFER Request failed, the provided buffer is too small to store the result. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \trace CREQ-127564 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeyElementGet(uint32 cryIfKeyId, uint32 keyElementId, P2VAR(uint8, AUTOMATIC, CRYIF_APPL_VAR) resultPtr, P2VAR(uint32, AUTOMATIC, CRYIF_APPL_VAR) resultLengthPtr); /********************************************************************************************************************** * CryIf_KeyElementCopy() *********************************************************************************************************************/ /*! \brief Copy key element. * \details This function shall copy a key element from one key to a target key. * \param[in] cryIfKeyId Holds the identifier of the key whose key element shall be the source * element. * \param[in] keyElementId Holds the identifier of the key element which shall be the source for the * copy operation. * \param[in] targetCryIfKeyId Holds the identifier of the key whose key element shall be the destination * element. * \param[in] targetKeyElementId Holds the identifier of the key element which shall be the destination for * the copy operation. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \return CRYPTO_E_KEY_READ_FAIL Request failed, read access was denied. * \return CRYPTO_E_KEY_WRITE_FAIL Request failed, write access was denied. * \return CRYPTO_E_KEY_EXTRACT_DENIED Request failed, not allowed to extract key material. * \return CRYPTO_E_KEY_NOT_AVAILABLE Request failed, the key is not available. * \return CRYPTO_E_KEY_SIZE_MISMATCH Request failed, the key element sizes are not compatible. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \trace CREQ-127565 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeyElementCopy(uint32 cryIfKeyId, uint32 keyElementId, uint32 targetCryIfKeyId, uint32 targetKeyElementId); /********************************************************************************************************************** * CryIf_KeyElementCopyPartial() *********************************************************************************************************************/ /*! \brief Copies a key element partially. * \details This function copies a key element partially from one key to a target key. * \param[in] cryIfKeyId Holds the identifier of the key whose key element shall be the source * element. * \param[in] keyElementId Holds the identifier of the key element which shall be the source for the * copy operation. * \param[in] keyElementSourceOffset This is the offset of the source key element indicating the start index * of the copy operation. * \param[in] keyElementTargetOffset This is the offset of the destination key element indicating the start index * of the copy operation. * \param[in] keyElementCopyLength Specifies the number of bytes that shall be copied. * \param[in] targetCryIfKeyId Holds the identifier of the key whose key element shall be the destination * element. * \param[in] targetKeyElementId Holds the identifier of the key element which shall be the destination for * the copy operation. * \return E_OK Request successful * E_NOT_OK Request failed * CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy * CRYPTO_E_KEY_READ_FAIL Request failed because read access was denied * CRYPTO_E_KEY_WRITE_FAIL Request failed because write access was denied * CRYPTO_E_KEY_NOT_AVAILABLE Request failed because the key is not available * CRYPTO_E_KEY_SIZE_MISMATCH Request failed, key element size does not match size of provided data. * CRYPTO_E_KEY_EMPTY Request failed because of uninitialized source key element. * \context TASK * \reentrant TRUE, but not for the same cryIfKeyId * \synchronous TRUE * \pre - * \trace CREQ-188329 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeyElementCopyPartial(uint32 cryIfKeyId, uint32 keyElementId, uint32 keyElementSourceOffset, uint32 keyElementTargetOffset, uint32 keyElementCopyLength, uint32 targetCryIfKeyId, uint32 targetKeyElementId); /********************************************************************************************************************** * CryIf_KeyCopy() *********************************************************************************************************************/ /*! \brief Copy the key * \details This function shall copy all key elements from the source key to a target key. * \param[in] cryIfKeyId Holds the identifier of the key whose key element shall be the source * element. * \param[in] targetCryIfKeyId Holds the identifier of the key whose key element shall be the destination * element. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \return CRYPTO_E_KEY_READ_FAIL Request failed, read access was denied. * \return CRYPTO_E_KEY_WRITE_FAIL Request failed, write access was denied. * \return CRYPTO_E_KEY_NOT_AVAILABLE Request failed, the key is not available. * \return CRYPTO_E_KEY_SIZE_MISMATCH Request failed, the key element sizes are not compatible. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \trace CREQ-127566 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeyCopy(uint32 cryIfKeyId, uint32 targetCryIfKeyId); /********************************************************************************************************************** * CryIf_RandomSeed() *********************************************************************************************************************/ /*! \brief Initialize the seed * \details This function shall dispatch the random seed function to the configured crypto driver object. * \param[in] cryIfKeyId Holds the identifier of the key for which a new material shall be generated. * \param[in] seedPtr Holds a pointer to the memory location which contains the data to feed the * seed. * \param[in] seedLength Contains the length of the seed in bytes. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \trace CREQ-127567 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_RandomSeed(uint32 cryIfKeyId, P2CONST(uint8, AUTOMATIC, CRYIF_APPL_DATA) seedPtr, uint32 seedLength); /********************************************************************************************************************** * CryIf_KeyGenerate() *********************************************************************************************************************/ /*! \brief Generates a key. * \details This function shall dispatch the key generate function to the configured crypto driver object. * \param[in] cryIfKeyId Holds the identifier of the key which is to be updated with the generated * value. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \trace CREQ-127568 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeyGenerate(uint32 cryIfKeyId); /********************************************************************************************************************** * CryIf_KeyDerive() *********************************************************************************************************************/ /*! \brief Derives a key. * \details This function shall dispatch the key derive function to the configured crypto driver object. * \param[in] cryIfKeyId Holds the identifier of the key which is used for key derivation. * \param[in] targetCryIfKeyId Holds the identifier of the key which is used to store the derived key. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \trace CREQ-127569 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeyDerive(uint32 cryIfKeyId, uint32 targetCryIfKeyId); /********************************************************************************************************************** * CryIf_KeyExchangeCalcPubVal() *********************************************************************************************************************/ /*! \brief Calculation of the public value. * \details This function shall dispatch the key exchange public value calculation function to the configured * crypto driver object. * \param[in] cryIfKeyId Holds the identifier of the key which shall be used for the key exchange * protocol. * \param[out] publicValuePtr Contains the pointer to the data where the public value shall be stored. * \param[in,out] publicValueLengthPtr Holds a pointer to the memory location in which the public value length * information is stored. On calling this function, this parameter shall * contain the size of the buffer provided by publicValuePtr. When the request * has finished, the actual length of the returned value shall be stored. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \return CRYPTO_E_SMALL_BUFFER Request failed, the provided buffer is too small to store the result. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \trace CREQ-127570 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeyExchangeCalcPubVal(uint32 cryIfKeyId, P2VAR(uint8, AUTOMATIC, CRYIF_APPL_VAR) publicValuePtr, P2VAR(uint32, AUTOMATIC, CRYIF_APPL_VAR) publicValueLengthPtr); /********************************************************************************************************************** * CryIf_KeyExchangeCalcSecret() *********************************************************************************************************************/ /*! \brief Calculation of the secret. * \details This function shall dispatch the key exchange common shared secret calculation function to the * configured crypto driver object. * \param[in] cryIfKeyId Holds the identifier of the key which shall be used for the key exchange * protocol. * \param[in] partnerPublicValuePtr Holds the pointer to the memory location which contains the partners * public value. * \param[in] partnerPublicValueLength Contains the length of the partners public value in bytes. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \return CRYPTO_E_SMALL_BUFFER Request failed, the provided buffer is too small to store the result. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \trace CREQ-127571 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeyExchangeCalcSecret(uint32 cryIfKeyId, P2CONST(uint8, AUTOMATIC, CRYIF_APPL_DATA) partnerPublicValuePtr, uint32 partnerPublicValueLength); /********************************************************************************************************************** * CryIf_CertificateParse() *********************************************************************************************************************/ /*! \brief Parse stored certificate. * \details This function shall dispatch the certificate parse function to the configured crypto driver object. * \param[in] cryIfKeyId Holds the identifier of the key slot in which the certificate has been * stored. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \note If API support is disabled (/MICROSAR/CryIf/CryIfCryptoModule/CryIfSupportsCertificateAPI) * for a specific driver, the service will always return E_NOT_OK for this driver. * \trace CREQ-127572 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_CertificateParse(uint32 cryIfKeyId); /********************************************************************************************************************** * CryIf_CertificateVerify() *********************************************************************************************************************/ /*! \brief Certificate verification. * \details Verifies the certificate stored in the key referenced by verifyCryptoKeyId with the certificate * stored in the key referenced by cryIfKeyId. * \param[in] cryIfKeyId Holds the identifier of the key which shall be used to validate the * certificate. * \param[in] verifyCryIfKeyId Holds the identifier of the key containing the certificate, which shall be * verified. * \param[out] verifyPtr Holds a pointer to the memory location which will contain the result of the * certificate verification. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \note If API support is disabled (/MICROSAR/CryIf/CryIfCryptoModule/CryIfSupportsCertificateAPI) * for a specific driver, the service will always return E_NOT_OK for this driver. * \trace CREQ-127573 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_CertificateVerify(uint32 cryIfKeyId, uint32 verifyCryIfKeyId, P2VAR(Crypto_VerifyResultType, AUTOMATIC, CRYIF_APPL_VAR) verifyPtr); /********************************************************************************************************************** * CryIf_KeySetInvalid() *********************************************************************************************************************/ /*! \brief Set crypto key to invalid. * \details If no errors are detected by CryIf, the service calls Crypto_KeySetInvalid() of the configured * crypto driver for the crypto key which is mapped to cryIfKeyId and returns the service result. * \param[in] cryIfKeyId Holds the identifier of the key which shall be set to invalid. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \pre - * \context TASK * \reentrant TRUE * \synchronous TRUE * \note If API support is disabled (/MICROSAR/CryIf/CryIfCryptoModule/CryIfSupportsKeyStatusAPI) * for a specific driver, the service will always return E_NOT_OK for this driver. * \trace CREQ-324923 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeySetInvalid(uint32 cryIfKeyId); /********************************************************************************************************************** * CryIf_KeyGetStatus() *********************************************************************************************************************/ /*! \brief Get status of a key. * \details If no errors are detected by CryIf, the service calls Crypto_KeyGetStatus() of the configured * crypto driver for the crypto key which is mapped to cryIfKeyId. The driver writes the key status to * keyStatusPtr and returns the service result. * \param[in] cryIfKeyId Holds the identifier of the key of which the status shall be read. * \param[out] keyStatusPtr Holds a pointer to the memory where the key status shall be written to. * \return E_OK Request successful. * \return E_NOT_OK Request failed. * \return CRYPTO_E_BUSY Request failed, Crypto Driver Object is busy. * \pre All pointers need to be valid. * \context TASK * \reentrant TRUE * \synchronous TRUE * \note If API support is disabled (/MICROSAR/CryIf/CryIfCryptoModule/CryIfSupportsKeyStatusAPI) * for a specific driver, the service will always return E_NOT_OK for this driver. * \trace CREQ-324922 *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_KeyGetStatus(uint32 cryIfKeyId, P2VAR(Crypto_KeyStatusType, AUTOMATIC, CRYIF_APPL_VAR) keyStatusPtr); /********************************************************************************************************************** * CryIf_CustomSync() *********************************************************************************************************************/ /*! \brief Requests the execution of a function that is specified by the given dispatch id. * \details If no errors are detected by CryIf, the service calls Crypto_CustomSync() of the configured * crypto driver and passes on the return value. * The driver executes the custom cryptographic operation and returns the service result. * \param[in] dispatchId Unique id to identify the request. * \param[in] keyId Key Id (e.g. of the key in which the certificate is stored). * \param[in] keyElementId Key element id. * \param[in] targetKeyId Holds the target key id. * If the service does not require a target key, the targetKeyId still * must reference a valid key * \param[in] targetKeyElementId Key element id of target key. * \param[in] inputPtr Pointer to the input data. * \param[in] inputLength Contains the input length in bytes. * \param[out] outputPtr Pointer to the output data. * \param[out] outputLengthPtr Contains the output length in bytes. * \param[out] secondaryOutputPtr Pointer to the secondary output data. * \param[out] secondaryOutputLengthPtr Contains the secondary output length in bytes. * \return E_OK: Request successful. * \return E_NOT_OK: Request failed. * \return CRYPTO_E_BUSY: Request failed, Crypto Driver Object is busy. * \return CRYPTO_E_CUSTOM_ERROR: Custom processing failed. * \pre - * \context TASK * \reentrant FALSE * \synchronous TRUE * \note If API support is disabled (/MICROSAR/CryIf/CryIfCryptoModule/CryIfSupportsCustomSyncService) * for a specific driver, the service will always return E_NOT_OK for this driver. * If the service does not require a target key, the key referenced by targetKeyId will not be used. * However, its id must be valid. * \trace CREQ-CryIf-CustomSyncService *********************************************************************************************************************/ FUNC(Std_ReturnType, CRYIF_CODE) CryIf_CustomSync(uint32 dispatchId, uint32 keyId, uint32 keyElementId, uint32 targetKeyId, uint32 targetKeyElementId, P2CONST(uint8, AUTOMATIC, CRYIF_APPL_DATA) inputPtr, uint32 inputLength, P2VAR(uint8, AUTOMATIC, CRYIF_APPL_VAR) outputPtr, P2VAR(uint32, AUTOMATIC, CRYIF_APPL_VAR) outputLengthPtr, P2VAR(uint8, AUTOMATIC, CRYIF_APPL_VAR) secondaryOutputPtr, P2VAR(uint32, AUTOMATIC, CRYIF_APPL_VAR) secondaryOutputLengthPtr); # define CRYIF_STOP_SEC_CODE # include "CryIf_MemMap.h" /* PRQA S 5087 */ /* MD_MSR_MemMap */ #endif /* !defined (CRYIF_H) */ /********************************************************************************************************************** * END OF FILE: CryIf.h *********************************************************************************************************************/