DEENESPTFRRUARHIKOZHNL

AUTOSAR Classic Security & Intrusion Detection

Das Security-Cluster schützt vernetzte Fahrzeugfunktionen gegen Cyber-Bedrohungen durch Intrusion Detection (IdsM), kryptographische PDU-Authentifizierung und Freshness-Protection (SecOC) sowie Key- und Zertifikatsmanagement (KeyM).

集群指南人工智能生成

通过加密服务、PDU认证、密钥管理和事件检测来保障车载安全。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 2b0b830492f5 来源 未决问题(2)
因果锚点:R20-11 自 R20-11 起有效 为此规范版本重新合成。
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

通过加密服务、PDU认证、密钥管理和事件检测来保障车载安全。

Security & Intrusion Detection Cluster通过CSM、CryIf和Crypto Driver提供加密原语,通过SecOC利用认证数据保护I-PDU,并通过KeyM管理密钥与证书AUTOSAR_CP_SWS_CryptoServiceManager 第21页。安全事件作为Event上报至IdsM,在其中进行缓冲并被异步过滤[SWS_IdsM_00702]。在关闭(Shutdown)过程中,主动擦除RAM密钥数据可防止未经授权的泄露。

模块集群Security & Intrusion Detection整合了模块secoc、idsm、keym、csm、cryif和crypto,用于保护AUTOSAR Classic Platform中的车载通信并检测安全事件AUTOSAR_CP_SWS_IntrusionDetectionSystemManager 第21页。基础加密服务通过Crypto Service Manager (CSM)进行分层提供,CSM将任务封装在Crypto_JobType结构中[SWS_Csm_01013],并通过Crypto Interface (CryIf_ProcessJob [SWS_CryIf_91003])转发至Crypto Driver的具体硬件或软件驱动对象。

PDU通信由SecOC通过消息认证码(MAC)和新鲜度值进行保护([SWS_SecOC_91006]、[SWS_SecOC_00012]),而Key Manager (KeyM)则为CSM准备、更新和验证证书与密钥([SWS_KeyM_00052]、[SWS_KeyM_00059])。安全相关事件(如失败的PDU校验)作为安全事件(SEv)上报至IdsM[SWS_IdsM_91002],IdsM对它们进行同步缓冲[SWS_IdsM_00701]并通过可配置的过滤链进行异步鉴别[SWS_IdsM_01020]。

SecArch SWC Application SW-Cs / Sensors IdsM IdsM (Intrusion Detection System Manager) SWC->IdsM IdsM_SetSecurityEvent SecOC SecOC (Secure Onboard Communication) SecOC->IdsM Security Events CSM CSM (Crypto Service Manager) SecOC->CSM Csm_MacGenerate / Csm_MacVerify PduR PduR (PDU Router) SecOC->PduR Secured / Authentic I-PDUs KeyM KeyM (Key Manager) KeyM->CSM Csm_KeyElementSet / Primitives CryIf CryIf (Crypto Interface) CSM->CryIf CryIf_ProcessJob / Key APIs Crypto Crypto Driver (Hardware / Software) CryIf->Crypto Crypto_ProcessJob / Driver Objects PduR->SecOC PDU Reception / Transmission

架构图:Security与Intrusion Detection Cluster的分层架构与接口关系。来源:AUTOSAR_CP_SWS_IntrusionDetectionSystemManager 第21页、AUTOSAR_CP_SWS_CryptoServiceManager 第21页。

执行过程将同步API入口与IdsM_MainFunction、SecOC_MainFunctionTx[SWS_SecOC_00176]以及KeyM_MainBackgroundFunction[SWS_KeyM_00075]中计算密集的后台任务分离开来。在发生错误或系统过载(CRYPTO_E_BUSY)时,SecOC中的默认认证模式[SWS_SecOC_91013]和IdsM中的NvM回滚[SWS_IdsM_01702]等回退机制可确保整个系统的稳定性;在系统关闭时,KeyM会完全擦除活动的RAM密钥材料[SWS_KeyM_00047]。

系统架构 & 模块集群的角色

AUTOSAR Classic Platform(版本R20-11)的模块集群Security & Intrusion Detection提供了用于密码学、安全车载通信、密钥与证书管理以及入侵检测的标准化服务。在功能上,该集群划分贯穿AUTOSAR基础软件(Basic Software,BSW)的多个层级:在服务层,Crypto Service Manager (CSM)封装了与硬件无关的加密服务AUTOSAR_CP_SWS_CryptoServiceManager 第21页。通信层中的Secure Onboard Communication (SecOC)模块负责I-PDU的安全通信[SWS_SecOC_00162],而Key Manager (KeyM)作为安全服务编排加密密钥和证书的生命周期SWS_KeyManager 第31页。作为补充,Intrusion Detection System Manager (IdsM)作为整个系统中安全相关事件的中央聚合器与过滤器发挥作用AUTOSAR_CP_SWS_IntrusionDetectionSystemManager 第21页。

在CSM下方,Crypto Interface (CryIf)作为CryIf层抽象了对多个加密驱动对象的硬件或软件特定访问,并统一了任务与密钥的分发机制SWS_CryptoInterface 第1页。在MCAL与驱动层,Crypto Driver (Crypto)在软件中或硬件安全模块(HSM)上执行实际的计算[SWS_Crypto_91016]。这些层之间的协同工作确保了应用软件(SW-C)及通信模块与硬件特定加密加速器的完全解耦。

SecArch SWC Application SW-Cs / Sensors IdsM IdsM (Intrusion Detection System Manager) SWC->IdsM IdsM_SetSecurityEvent SecOC SecOC (Secure Onboard Communication) SecOC->IdsM Security Events CSM CSM (Crypto Service Manager) SecOC->CSM Csm_MacGenerate / Csm_MacVerify PduR PduR (PDU Router) SecOC->PduR Secured / Authentic I-PDUs KeyM KeyM (Key Manager) KeyM->CSM Csm_KeyElementSet / Primitives CryIf CryIf (Crypto Interface) CSM->CryIf CryIf_ProcessJob / Key APIs Crypto Crypto Driver (Hardware / Software) CryIf->Crypto Crypto_ProcessJob / Driver Objects PduR->SecOC PDU Reception / Transmission

架构图:Security与Intrusion Detection Cluster的分层架构与接口关系。来源:AUTOSAR_CP_SWS_IntrusionDetectionSystemManager 第21页、AUTOSAR_CP_SWS_CryptoServiceManager 第21页。

各模块之间的交互配合与交互路径

该集群的各模块通过定义明确的控制流与数据流路径相互连接。加密任务的处理主要通过CSM进行。应用模块或BSW模块(如SecOC和KeyM)通过CSM服务(如Csm_MacGenerate [SWS_Csm_00982]、Csm_Encrypt [SWS_Csm_00984]、Csm_AEADEncrypt [SWS_Csm_01023]、Csm_SignatureGenerate [SWS_Csm_00992]、Csm_Hash [SWS_Csm_00980]或Csm_RandomGenerate [SWS_Csm_01543])发起任务。这些任务被封装在标准化运行时结构Crypto_JobType中[SWS_Csm_01013],该结构通过运行模式(如CRYPTO_OPERATIONMODE_START、UPDATE、FINISH或SINGLECALL等Crypto_OperationModeType)进行控制[SWS_Csm_00802]。CSM将Job传递给CryIf_ProcessJob [SWS_CryIf_91003],后者将调用转发至负责的Crypto驱动对象。

SecOC模块保护PduR与通信总线之间的PDU传输。当通过SecOC_TpRxIndication [SWS_SecOC_00125]接收到安全PDU时,SecOC首先通过SecOC_GetRxFreshnessAuthData检索新鲜度值[SWS_SecOC_91006],并根据规范构建待认证数据SecOcProtocol 第19页。SecOC利用CSM进行MAC验证[SWS_SecOC_00012]。检查成功后,真实PDU被传递给上层。如果验证失败,结果将记录在状态SecOC_VerificationStatusType中[SWS_SecOC_00160]、[SWS_SecOC_91014];解读:此失败将作为安全事件上报给IdsMAUTOSAR_CP_SWS_IntrusionDetectionSystemManager 第21页。 问题 Q-8cfd1660757f3f1f (未决)

在Key Manager (KeyM)中准备并执行密钥和证书的更新。在证书验证时(例如通过KeyM_VerifyCertificates [SWS_KeyM_00059]或KeyM_VerifyCertificateChain [SWS_KeyM_00061]),KeyM使用CSM的加密原语进行签名检查,并使用StbM的外部时间基准进行有效性检查SWS_KeyManager 第119页。密钥更新(KeyM_Update [SWS_KeyM_00052])会集成用户自定义的处理程序(KeyM_KH_Update [SWS_KeyM_00069]、[SWS_KeyM_00055]),其中生成的密钥字节通过Csm_KeyElementSet [SWS_Csm_00957]和Csm_JobKeySetValid [SWS_Csm_91027]在Crypto驱动中激活。CryIf通过CryIf_KeyDerive [SWS_CryIf_91009]或CryIf_KeyElementCopy [SWS_CryIf_91015]将密钥派生和复制操作转发至驱动函数(如Crypto_KeyElementCopyPartial [SWS_Crypto_91015])。

IdsM通过IdsM_SetSecurityEvent [SWS_IdsM_91002]或IdsM_SetSecurityEventWithCount [SWS_IdsM_91018]等接口从BSW传感器(包括SecOC)以及应用SW-C收集安全事件(Security Events,SEv)。这些Event被缓冲,通过过滤链(例如阻塞状态过滤器[SWS_IdsM_01020]或聚合过滤器AUTOSAR_CP_SWS_IntrusionDetectionSystemManager 第40页)进行鉴别,并最终通过PduR转发[SWS_IdsM_91009]、[SWS_IdsM_91010]。

SecOC 中使用加密栈和 IdsM 报告对安全 PDU 进行验证PduRSecOCCSMCryIfCryptoIdsMSecOC_TpRxIndication(id, result)PDU parsen & Freshness Value abrufenCsm_MacVerify(jobId, mode, ...)CryIf_ProcessJob(channelId, job)Crypto_ProcessJob(objectId, job)CryIf_CallbackNotification(job, result)Csm_CallbackNotification(job, result)带验证结果的回调altVerifikation erfolgreichPduR Weiterleitung (Authentic PDU)Verifikation fehlgeschlagenIdsM_SetSecurityEvent(SEV_VERIFICATION_FAILURE)在 Event Buffer 中缓冲及过滤

时序图:SecOC中利用加密栈对安全PDU的验证以及向IdsM上报安全事件。来源:[SWS_SecOC_00125]、[SWS_SecOC_00012]、[SWS_CryIf_91003]、[SWS_CryIf_91013]、[SWS_IdsM_91002]。

同步、重入性与任务上下文

加密计算和安全操作的执行需要严格分离同步调用路径与异步任务上下文。在CSM和CryIf中,执行行为取决于加密原语的配置:操作既可以同步阻塞运行,也可以异步运行[SWS_Csm_00982]、[SWS_CryIf_91003]。对于异步任务,Crypto驱动通过CryIf_CallbackNotification [SWS_CryIf_91013]报告完成情况,随后CSM调用调用方注册的回调函数[SWS_SecOC_00012]。针对可中断或长时间运行的计算,CSM提供了取消函数Csm_CancelJob[SWS_Csm_00968],该函数通过CryIf_CancelJob [SWS_CryIf_91014]委托给驱动。

SecOC模块中的传输采用时间控制解耦:在周期性循环中,SecOC_MainFunctionTx检查是否有新的真实PDU等待签名,计算认证符并发起PduR发送[SWS_SecOC_00176]。在IdsM中,上报事件的接收是在传感器上下文(Task或ISR)中通过IdsM_SetSecurityEvent [SWS_IdsM_91002]高性能完成的,此时Event首先被同步存放在可配置的事件缓冲区中[SWS_IdsM_00701]、[SWS_IdsM_00702]。耗时的过滤、上下文数据处理以及通过StbM或RTE的时间戳丰富完全在周期性IdsM_MainFunction的上下文中异步处理SWS_IntrusionDetectionSystemManager 第87页、AUTOSAR_CP_SWS_IntrusionDetectionSystemManager 第86页。

Key Manager区分时间关键型任务与计算密集型任务:标准状态查询和回调编排在KeyM_MainFunction中运行[SWS_KeyM_00074],而计算密集型同步处理程序流程(如KeyM_KH_Update)则计划在抢占式后台函数KeyM_MainBackgroundFunction中执行[SWS_KeyM_00075]。在多核架构中,CSM还支持特定分区的MainFunction和初始化[SWS_Csm_00646]、SWS_CryptoInterface 第1页;解读:这种分区与为每个处理器核心分配专用硬件驱动对象相对应。 问题 (未决)

典型的生命周期和操作模式

集群的初始化遵循自底向上的严格依赖层级。首先通过Crypto_Init配置底层驱动[SWS_Crypto_91016],随后是通过Csm_Init [SWS_Csm_00646]初始化的CryIf接口[SWS_CryIf_91118]和CSM。只有在此之后,才允许初始化依赖模块SecOC、KeyM和IdsM。通过初始化,SecOC从状态SECOC_UNINIT切换到SECOC_INIT [SWS_SecOC_00162]。在KeyM中,所有配置的证书初始均获得状态KEYM_CERTIFICATE_NOT_AVAILABLE [SWS_KeyM_00021]、[SWS_KeyM_91003],之后才从NvM中读取,或者通过KeyM_SetCertificate或诊断进行加载和验证SWS_KeyManager 第119页。

在运行时,车辆状态变化会影响IdsM的运行模式:Basic Software Manager (BswM)通过IdsM_BswM_StateChanged向IdsM通知状态变更[SWS_IdsM_91005]。这些状态控制阻塞状态过滤器[SWS_IdsM_01020]、[SWS_IdsM_91017],从而在特定运行阶段(例如编程模式或休眠阶段)抑制安全事件的转发。此外,Event的上报模式可以通过DCM进行诊断修改(IdsM_Dcm_SetReportingMode_Start [SWS_IdsM_91008]、[SWS_IdsM_91013])并持久保存在NvM中[SWS_IdsM_01700]、[SWS_IdsM_01701]。

在ECU关闭(Shutdown)时,各模块按顺序反初始化。SecOC_DeInit停止安全通信,清空所有内部缓冲区和变量,并将SecOC转换回状态SECOC_UNINIT [SWS_SecOC_00161]。出于安全考虑,在调用KeyM_Deinit [SWS_KeyM_00047]时,RAM中的所有加密密钥材料都会被主动销毁并覆写为初始值,以防止在静止状态下遭到未经授权的读取。

错误处理、DET 跟踪与降级

该模块集群实现了用于检测开发错误(Development Error Tracer,DET)和运行时问题的贯穿机制。所有模块均会检查自身初始化情况,并在未初始化调用时报告DET错误,例如CryIf接口中的CRYIF_E_UNINIT(如CryIf_RandomSeed [SWS_CryIf_91007]、CryIf_CancelJob [SWS_CryIf_91014]、CryIf_KeyDerive [SWS_CryIf_91009]或CryIf_CallbackNotification [SWS_CryIf_91013])。同样,错误的指针参数会导致DET报告,例如Crypto_GetVersionInfo [SWS_Crypto_91001]中的CRYPTO_E_PARAM_POINTER,而CSM中的初始化错误则通过CSM_E_INIT_FAILED进行报告[SWS_Csm_00646]。

当加密硬件对象过载或发生故障时,驱动程序会指示状态CRYPTO_E_BUSY [SWS_CryIf_91003]、[SWS_Csm_00957]。在发生此类降级的情况下,SecOC允许通过SecOC_SendDefaultAuthenticationInformation可配置地向底层发送未认证的替代PDU,以维持车辆可用性[SWS_SecOC_91013]。在IdsM中,配置的事件缓冲区耗尽将触发内部安全事件SEV_IDSM_NO_EVENT_BUFFER_AVAILABLE [SWS_IdsM_00703]。如果修改后的IdsM参数的NvM持久化失败,IdsM将自动回滚到先前状态[SWS_IdsM_01702]。如果在Csm_KeyElementSet中设置密钥时发生错误,则该密钥元素的状态视为未定义,必须通过Csm_KeyGetStatus [SWS_Csm_91047]和CryIf_KeyGetStatus [SWS_CryIf_91012]进行验证。

本指南基于Classic Platform的AUTOSAR规范(Release R20-11),并总结了Security & Intrusion Detection集群的架构。

主题图

详细视图

请在大纲中选择一个条目。

IdsM

This callback function is invoked by the BswM to indicate ECU state changes.

void IdsM_BswM_StateChanged (IdsM_Filters_BlockStateType state);

This function is called to acquire the transmit data of an I-PDU segment (N-PDU). Each call to this function provides the next part of the I-PDU data unless retry->TpDataState is TP_ DATARETRY. In this case the function restarts to copy the data beginning at the offset from the current position indicated by retry->TxTpDataCnt. The size of the remaining data is written to the position indicated by availableDataPtr.

BufReq_ReturnType IdsM_CopyTxData (PduIdType id, const PduInfoType* info, const RetryInfoType* retry, PduLengthType* availableDataPtr);

This function is a request from DCM to the IdsM to read the routine results triggered by function IdsM_Dcm_GetReportingMode_Start().

Std_ReturnType IdsM_Dcm_GetReportingMode_RequestResults (Dcm_OpStatusType OpStatus, uint8* Out_ReportingMode, Dcm_NegativeResponseCodeType* ErrorCode);

This function is a request from DCM to the IdsM to start the routine execution to request the current reporting mode of a specific Security Event ID.

Std_ReturnType IdsM_Dcm_GetReportingMode_Start (uint16 In_SecurityEventId, uint8 In_SensorInstanceId, Dcm_OpStatusType OpStatus, Dcm_NegativeResponseCodeType* ErrorCode);

This function is a request from DCM to the IdsM to start the routine execution to set the reporting mode of a specific Security Event ID.

Std_ReturnType IdsM_Dcm_SetReportingMode_Start (uint16 In_SecurityEventId, uint8 In_SensorInstanceId, uint8 In_ReportingMode, Dcm_OpStatusType OpStatus, Dcm_NegativeResponseCodeType* ErrorCode);

Returns version information, vendor ID and AUTOSAR module ID of the component.

void IdsM_GetVersionInfo (const Std_VersionInfoType* versionInfo);
IdsM_Init 函数

Service to initialize the module IdsM. It initializes all variables and sets the module state to initialized.

void IdsM_Init (const IdsM_ConfigType* configPtr);

This function is called periodically. It processes security events asynchronously which are queued during API function calls.

void IdsM_MainFunction (void);

This API is the application interface to report security events to the IdsM.

void IdsM_SetSecurityEvent (IdsM_SecurityEventIdType securityEventId);

This API is the application interface to report security events with context data to the IdsM.

void IdsM_SetSecurityEventWithContextData (IdsM_SecurityEventIdType securityEventId, const uint8* contextData, uint16 contextDataSize);

This API is the application interface for Smart Sensors to report security events with a count value to the IdsM.

void IdsM_SetSecurityEventWithCount (IdsM_SecurityEventIdType securityEventId, uint16 count);

This API is the application interface for Smart Sensors to report security events with a count value and context data to the IdsM.

void IdsM_SetSecurityEventWithCountContextData (IdsM_SecurityEventIdType securityEventId, uint16 count, const uint8* contextData, uint16 contextDataSize);

This API is the application interface for Smart Sensors to report security events with a timestamp and a count value to the IdsM.

void IdsM_SetSecurityEventWithTimestampCount (IdsM_SecurityEventIdType securityEventId, IdsM_TimestampType timestamp, uint16 count);

This API is the application interface for Smart Sensors to report security events with a timestamp, a count value and context data to the IdsM.

void IdsM_SetSecurityEventWithTimestampCountContextData (IdsM_SecurityEventIdType securityEventId, IdsM_TimestampType timestamp, uint16 count, const uint8* contextData, uint16 contextDataSize);

This function is called after the I-PDU has been transmitted on its network, the result indicates whether the transmission was successful or not.

void IdsM_TpTxConfirmation (PduIdType id, Std_ReturnType result);

The lower layer communication interface module confirms the transmission of a PDU, or the failure to transmit a PDU.

void IdsM_TxConfirmation (PduIdType TxPduId, Std_ReturnType result);

Configuration data structure of IdsM module.

Data type used for "Block State" filter values (bit masks)

Reporting modes used by the reporting mode filter

Data type used for local IdsM Security Event IDs

Data type for IdsM timestamps

KeyM

Service KeyM_CertElementGet.

Std_ReturnType KeyM_CertElementGet (KeyM_CertificateIdType CertId, KeyM_CertElementIdType CertElementId, uint8* CertElementData, uint32* CertElementDataLength);

Service KeyM_CertElementGetFirst.

Std_ReturnType KeyM_CertElementGetFirst (KeyM_CertificateIdType CertId, KeyM_CertElementIdType CertElementId, KeyM_CertElementIteratorType* CertElementIterator, uint8* CertElementData, uint32* CertElementDataLength);

Service KeyM_CertElementGetNext.

Std_ReturnType KeyM_CertElementGetNext (KeyM_CertElementIteratorType* CertElementIterator, uint8* CertElementData, uint32* CertElementDataLength);

This function provides the sta tus of a certificate.

Std_ReturnType KeyM_CertGetStatus (KeyM_CertificateIdType CertId, KeyM_CertificateStatusType* Status);

Service KeyM_CertificateElementGetByIndex.

Std_ReturnType KeyM_CertificateElementGetByIndex (KeyM_CertificateIdType CertId, KeyM_CertElementIdType CertElementId, uint32 Index, uint8* CertElementDataPtr, uint32* CertElementDataLengthPtr);

This function provides the total number of data elements that a re available for the specified certificate element. Typically, only one data element is available. But in some cases, several data elements can be assigned to one certificate element in a row. This function retrieves the total number of elements. The indiv idual data elements can then accessed with Key M_ Certificate Element Get By Index(). It is similar to the functions Key M_ Cert Element Get First/ Key M_ Cert Element Get Next to retrieve a group of data elements of one certificate element. AUTOSAR CP R20 - of

Std_ReturnType KeyM_CertificateElementGetCount (KeyM_CertificateIdType CertId, KeyM_CertElementIdType CertElementId, uint16* CountPtr);

Notifies the application that a certificate verification has been finished. The function name is configurable by Key MCertificate Verify Callback Notification Func. Availabl e via Key M_ Externals.h

Std_ReturnType KeyM_CertificateVerifyCallbackNotification (KeyM_CertificateIdType CertId, KeyM_CertificateStatusType Result);

Service KeyM_CryptoKeyFinalizeCallbackNotification.

void KeyM_CryptoKeyFinalizeCallbackNotification (KeyM_ResultType Result, uint16 ResultDataLength, const uint8* ResultDataPtr);

Notifies the application that a crypto key update operation has been finished. This function is used by the key manager.

void KeyM_CryptoKeyUpdateCallbackNotification (KeyM_ResultType Result, uint16 ResultDataLength, const uint8* ResultDataPtr);

Notifies the application that a crypto key verify operation has been finished. This function is used by the key manager.

void KeyM_CryptoKeyVerifyCallbackNotification (KeyM_ResultType Result, uint32 KeyId, uint16 ResultDataLength, const uint8* ResultDataPtr);

This function resets the key management module to the uninitialized state.

void KeyM_Deinit (void);

The function is used to finalize key update operations. It is typi cally used in conjunction with the Key M_

Std_ReturnType KeyM_Finalize (const uint8* RequestDataPtr, uint16 RequestDataLength, uint8* ResponseDataPtr, uint16 ResponseMaxDataLength);

This function provides the certificate data

Std_ReturnType KeyM_GetCertificate (KeyM_CertificateIdType CertId, KeyM_CertDataType* CertificateDataPtr);

Provides the version information of this module.

void KeyM_GetVersionInfo (Std_VersionInfoType* VersionInfo);
KeyM_Init 函数

This function initializes the key management module.

void KeyM_Init (const KeyM_ConfigType* ConfigPtr);

If Key MCrypto Key Start Finalize Function Enabled and Key MCrypto Key Handler Start Finalize Enabled is set to TRUE, this function will be called immediately when Key M_

Std_ReturnType KeyM_KH_Finalize (const uint8* RequestData, uint16 RequestDataLength, uint8* ResponseData, uint16* ResponseDataLength);

If the configuration parameters Key MCrypto Key Prepare Function Enabled and Key MCrypto Key Handler Prepare Enabled are both set to TRUE, then this function w ill be called immediately when Key M_ Prepare gets called. The function takes over the task to prepare a key management operation. The response data will be passed on as is to the caller of Key_ Prepare.

Std_ReturnType KeyM_KH_Prepare (const uint8* RequestData, uint16 RequestDataLength, uint8* ResponseDataPtr, uint16* ResponseDataLength);

If Key MCrypto Key Start Finalize Function Enabled and Key MCrypto Key

Std_ReturnType KeyM_KH_Start (KeyM_StartType StartType, const uint8* RequestData, uint16 RequestDataLength, uint8* ResponseData, uint16* ResponseDataLength);

Function is called from a pre - emptive operating system when no other task operation is needed. Can be used for calling time consuming synchronous functions such as Key M_ KH_ Update().

void KeyM_MainBackgroundFunction (void);

Function is called periodically according the specified time interval.

void KeyM_MainFunction (void);

This function is used to prepare a key update operation. The main intent is to provide information for the key operation to the key server. Other operations may start the negotiation for a common secret that is used further to derive key material. This function is only av ailable if Key MCrypto Key Prepare Function Enabled is set to TRUE.

Std_ReturnType KeyM_Prepare (const uint8* RequestData, uint16 RequestDataLength, uint8* ResponseData, uint16* ResponseDataLength);

Notifies the application that the certificate service operation has been finished. This function is used by the certificate submodule. Thi s callback is only provided if Key MService Certificate Function Enabled is set to TRUE. The function name is configurable by Key MService Certificate Callback Notification Func.

void KeyM_ServiceCertificateCallbackNotification (KeyM_CertificateIdType CertId, KeyM_ResultType Result, uint16 ResultDataLength, const uint8* ResultDataPtr);

This function provides the certificate data to the key managem ent module to temporarily store the certificate.

Std_ReturnType KeyM_SetCertificate (KeyM_CertificateIdType CertId, const KeyM_CertDataType* CertificateDataPtr);
KeyM_Start 函数

This function is optional and only used if the configuration item Key MCrypto Key Start Finalize Function Enabled is set to true. It intents to allow key update operation.

Std_ReturnType KeyM_Start (KeyM_StartType StartType, const uint8* RequestData, uint16 RequestDataLength, uint8* ResponseData, uint16* ResponseDataLength);

Service KeyM_VerifyCertificate.

Std_ReturnType KeyM_VerifyCertificate (KeyM_CertificateIdType CertId);

Service KeyM_VerifyCertificateChain.

Std_ReturnType KeyM_VerifyCertificateChain (KeyM_CertificateIdType CertId, const KeyM_CertDataType[] certChainData, uint8 NumberOfCertificates);

This function verifies two certificates that are stored and parsed internally against each other. The certificat e referenced with Cert Id was signed by the certificate referenced with cert Upper Id. Only these two certificates are validated against each other.

Std_ReturnType KeyM_VerifyCertificates (KeyM_CertificateIdType CertId, KeyM_CertificateIdType CertUpperId);

Byte - pointer to the data of the certificate

This structure is used to exchange certificate data through interface functions.

Certificate Element handle.

This structure is used to iterate through a number of elements of a certificate.

Array long enough to store data

Certificate handle.

Type KeyM_CertificateStatusType.

This structure is the base type to initialize the Key Manager module. A pointer to an instance of this structure will be used in the initialization of the Key Manager module.

Byte - pointer to the input or output data

Crypto key handle.

Specifies the type of key handler update operation that was performed in the callback.

Specifies the result type of an asynchronous key management fu nction.

This type specifies the requested service operation and what information is provided with this function.

This type specifies in which mode the key operation will start. The OEM production mode provides higher privileges compared to workshop mode.

Max 类型

Array long enough to store the key or certificate name. base Type Encoding = UTF -

SecOC

This function is called to provide the received data of an I - PDU segment (N - PDU) to the upper layer. Each call to this function provides the next part of the I - PDU data. The si ze of the remaining buffer is written to the position indicated by buffer Size Ptr.

BufReq_ReturnType SecOC_CopyRxData (PduIdType id, const PduInfoType* info, PduLengthType* bufferSizePtr);

Service SecOC_CopyTxData.

BufReq_ReturnType SecOC_CopyTxData (PduIdType id, const PduInfoType* info, const RetryInfoType* retry, PduLengthType* availableDataPtr);

This service stops the secure onboard communication. All buffered I - PDU are removed and have to be obtained again, if needed, after Sec OC_ Init has been called. By a call to Sec OC_ De Init the AUTOSAR Sec OC module is put into a not in itialized state (Sec OC_ UNINIT).

void SecOC_DeInit (void);

Service SecOC_GetRxFreshness.

Std_ReturnType SecOC_GetRxFreshness (uint16 SecOCFreshnessValueID, const uint8* SecOCTruncatedFreshnessValue, uint32 SecOCTruncatedFreshnessValueLength, uint16 SecOCAuthVerifyAttempts, uint8* SecOCFreshnessValue, uint32* SecOCFreshnessValueLength);

Service SecOC_GetRxFreshnessAuthData.

Std_ReturnType SecOC_GetRxFreshnessAuthData (uint16 SecOCFreshnessValueID, const uint8* SecOCTruncatedFreshnessValue, uint32 SecOCTruncatedFreshnessValueLength, const uint8* SecOCAuthDataFreshnessValue, uint16 SecOCAuthDataFreshnessValueLength, uint16 SecOCAuthVerifyAttempts, uint8* SecOCFreshnessValue, uint32* SecOCFreshnessValueLength);

This API returns th e freshness value from the Most Significant Bits in the first byte in the array (Sec OCFreshness Value), in big endian format.

Std_ReturnType SecOC_GetTxFreshness (uint16 SecOCFreshnessValueID, uint8* SecOCFreshnessValue, uint32* SecOCFreshnessValueLength);

Service SecOC_GetTxFreshnessTruncData.

Std_ReturnType SecOC_GetTxFreshnessTruncData (uint16 SecOCFreshnessValueID, uint8* SecOCFreshnessValue, uint32* SecOCFreshnessValueLength, uint8* SecOCTruncatedFreshnessValue, uint32* SecOCTruncatedFreshnessValueLength);

Returns the version information of this module.

void SecOC_GetVersionInfo (Std_VersionInfoType* versioninfo);

Requests cancellation of an ongoing transmission of a PDU in a lower layer communication module.

Std_ReturnType SecOC_IfCancelTransmit (PduIdType TxPduId);

Requests transmission of a PDU.

Std_ReturnType SecOC_IfTransmit (PduIdType TxPduId, const PduInfoType* PduInfoPtr);
SecOC_Init 函数

Initializes the the Sec OC module. Successful initialization leads to state Sec OC_ INIT. In configurations, in which Sec OC is assigned to more than one partition (i.e. Sec OC_ Main Functions are mapped to partition s), Sec OC may provide one init AUTOSAR CP R20 - of Document ID : AUTOSAR_SWS_SecureOnboardCommunication function per partition. The decision on whether a single Sec OC_ Init() function or one per partition is provided is implementation - specific. In case a given implementation provides one Sec OC_ Init() function per partition, it is up to the implementation to devise a naming pattern that prevents name clashes among the different Sec OC_ Init() functions (e.g., by adding a suffix containing short name the Ecuc Partition.

void SecOC_Init (const SecOC_ConfigType* config);

This function performs the processing of the Sec OC module's authentication and verification processing for the Rx path. Per configured Sec OCMain Function Rx instance one Sec OC_ Main Function Rx_ shall be implemented. Hereby is the short name of the Sec OCMain Function Rx configuration container in the ECU configuration.

void SecOC_MainFunctionRx (void);

This function performs the processing of the Sec OC module's authentication and verification processing for the Tx path. Per configured Sec OCMain Function Tx instance one Sec OC_ Main Function Tx_ shall be implemented. Hereby is t he short name of the Sec OCMain Function Tx configuration container in the ECU configuration.

void SecOC_MainFunctionTx (void);

Indication of a received PDU from a lower layer communication interface module.

void SecOC_RxIndication (PduIdType RxPduId, const PduInfoType* PduInfoPtr);

The service provides the ability to enable the sending of un - authenticated PDU to lower layer. (example: in case authentication build counter has reached the configuration value Sec OCAuthentication Build Attempts or the query of the freshness function returns E_ NOT_ OK or the calculation of the authenticator has returned a non - recoverable error such as returning E_ NOT_ OK or KEY_ FAILURE). T his service is optional (the service is available only if Sec OCDefault Authentication Information Pattern is configured). If the service is not available or the service is available but the service was called with send Default

Std_ReturnType SecOC_SendDefaultAuthenticationInformation (uint16 FreshnessValueID, boolean sendDefaultAuthenticationInformation);

This interface is used by the Sec OC to indicate that the Secured I - PDU has been initiated for transmission.

void SecOC_SPduTxConfirmation (uint16 SecOCFreshnessValueID);

Service SecOC_StartReception.

BufReq_ReturnType SecOC_StartOfReception (PduIdType id, const PduInfoType* info, PduLengthType TpSduLength, PduLengthType* bufferSizePtr);

Requests cancellation of an ongoing reception of a PDU in a lower layer transport protocol module.

Std_ReturnType SecOC_TpCancelReceive (PduIdType RxPduId);

Requests cancellation of an ongoing transmission of a PDU in a lower layer communication module.

Std_ReturnType SecOC_TpCancelTransmit (PduIdType TxPduId);

Called after an I - PDU has been received via the TP API, the result indicates whether the transmission was successful or not.

void SecOC_TpRxIndication (PduIdType id, Std_ReturnType result);

Requests transmission of a PDU.

Std_ReturnType SecOC_TpTransmit (PduIdType TxPduId, const PduInfoType* PduInfoPtr);

This function is called after the I - PDU has been transmitted on its network, the result indicates whether the transmission was successful or not.

void SecOC_TpTxConfirmation (PduIdType id, Std_ReturnType result);

Within this API , the upper layer module (called module) shall check whether the available data fits into the buffer size reported by Pdu Info Ptr - >Sdu Length. If it fits, it shall copy its data into the buffer provided by Pdu Info Ptr - >Sdu Data Ptr and update the length of the actual copied data in Pdu Info Ptr - >Sdu Length. If not, it returns E_ NOT_ OK without changing Pdu Info Ptr.

Std_ReturnType SecOC_TriggerTransmit (PduIdType TxPduId, PduInfoType* PduInfoPtr);

The lower layer communication interface module confirms the transmission of a PDU, or the failure to transmit a PDU.

void SecOC_TxConfirmation (PduIdType TxPduId, Std_ReturnType result);

Service is used to propagate the status of each verification attempt from the Sec OC module to other modules. This service can be configured such that:  Only: "False" Verifica tion Status is propagated to modules  Both: "True" and "False" Verification Status are propagated to modules  None: No Verification Status is propagated

void SecOC_VerificationStatusCallout (SecOC_VerificationStatusType verificationStatus);

This s ervice provides the ability to inform the application about the result of the verification attempt of a received PDU by the Sec OC module.

void SecOC_VerifyStatus (SecOC_VerificationStatusType verificationStatus);

Service SecOC_VerifyStatusOverride.

Std_ReturnType SecOC_VerifyStatusOverride (uint16 ValueID, SecOC_OverrideStatusType overrideStatus, uint8 numberOfMessagesToOverride);

Configuration data structure of Sec OC module

Type SecOC_OverrideStatusType.

States of the Sec OC module

Enumeration to indicate veri fication results.

Data structure to bundle the status of a verification attempt for a specific Freshness Value and Data ID

Module im Cluster

Firewall (Fw)

AUTOSAR Classic Communication Services-Modul Firewall (Fw, Spezifikation: AUTOSAR_CP_SWS_Firewall.pdf).

BSW ID 111 Keine C-API · 0 Records #include "Fw.h"

Intrusion Detection System Manager (IdsM)

Collects and reports onboard security events to detect threats.

BSW ID 108 21 APIs (16 Funktionen, 5 Typen) #include "IdsM.h"

Key Manager (KeyM)

Manages lifecycle, storage, and distribution of cryptographic keys and certificates.

BSW ID 109 42 APIs (27 Funktionen, 15 Typen) #include "KeyM.h"

MACsec Key Agreement (Mka)

AUTOSAR Classic Communication Services-Modul MACsec Key Agreement (Mka, Spezifikation: AUTOSAR_CP_SWS_MACsecKeyAgreement.pdf, AUTOSAR_SWS_MACsecKeyAgreement.pdf).

BSW ID 151 Keine C-API · 0 Records #include "Mka.h"

Secure Onboard Communication (SecOC)

Provides cryptographic authentication and freshness protection for critical communication PDUs.

BSW ID 150 33 APIs (27 Funktionen, 6 Typen) #include "SecOC.h"