SecOC(Secure Onboard Communication)提供车内通信的端到端认证与完整性保护。位于 PduR 与具体通信接口模块之间。应对 CAN/CAN FD/FlexRay/Ethernet 等总线上的 PDU 进行认证,检测伪造报文、重放攻击、损坏数据等攻击。R4.4 增强动态长度 PDU 支持 + 错误认证信息传输。
SecOC / MAC / CMAC / Freshness / FV / Data ID / PDU / PduR / CSM / CRY / KeyM / DEM / Wrong Authentication Info / Dynamic Length
[1] AUTOSAR SWS PduR
[2] AUTOSAR SWS Csm
[3] AUTOSAR SRS Secure Onboard Communication
SecOC 应:
SecOC 依赖:PduR(PDU 路由)/ CSM(加密服务)/ KeyM(密钥管理)/ StbM(时间戳,可选)/ Dem(错误上报)。
SecOC 位于 PduR 与具体通信接口模块之间。发送方向:在 PDU 末尾追加 MAC、FV;接收方向:验证 MAC、检查 FV,丢弃失败 PDU。
FV 构造:
当接收方验证失败时,可发送错误认证信息(Wrong Authentication Info)到发送方,通知发送方其密钥可能已泄漏。
void SecOC_Init(const SecOC_ConfigType* ConfigPtr):初始化。
void SecOC_DeInit(void):去初始化。
Std_ReturnType SecOC_Transmit(PduIdType TxPduId, const PduInfoType* PduInfoPtr):请求传输(认证 + 发送)。
void SecOC_RxIndication(PduIdType RxPduId, const PduInfoType* PduInfoPtr):接收指示。
BufReq_ReturnType SecOC_StartOfReception(PduIdType RxPduId, PduLengthType SduLength, PduLengthType* BufferSizePtr):TP 接收开始。
BufReq_ReturnType SecOC_CopyRxData(PduIdType RxPduId, const PduInfoType* PduInfoPtr, PduLengthType* BufferSizePtr):TP 接收数据复制。
void SecOC_TpRxIndication(PduIdType RxPduId, Std_ReturnType Result):TP 接收指示。
BufReq_ReturnType SecOC_CopyTxData(PduIdType TxPduId, PduInfoType* PduInfoPtr, RetryInfoType* RetryInfoPtr, PduLengthType* AvailableDataLengthPtr):TP 发送数据复制。
void SecOC_TxConfirmation(PduIdType TxPduId, Std_ReturnType Result):发送确认。
void SecOC_TpTxConfirmation(PduIdType TxPduId, Std_ReturnType Result):TP 发送确认。
Std_ReturnType SecOC_GetRxFreshness(NetworkHandleType NetworkHandle, uint64* FreshnessValuePtr, uint32* FreshnessValueLengthPtr, uint8* BufferPtr, uint32 BufferLength):获取接收 Freshness。
Std_ReturnType SecOC_GetTxFreshness(NetworkHandleType NetworkHandle, uint64* FreshnessValuePtr, uint32* FreshnessValueLengthPtr, uint8* BufferPtr, uint32 BufferLength):获取发送 Freshness。
void SecOC_RxIndicationFromPduR(PduIdType RxPduId, const PduInfoType* PduInfoPtr, boolean AuthenticationPassed):来自 PduR 的接收指示(含认证结果)。
void SecOC_MainFunctionRx(void):接收处理。
void SecOC_MainFunctionTx(void):发送处理。
SecOC 配置类:
SECOC_E_UNINIT:模块未初始化。
SECOC_E_PARAM_POINTER:参数指针为空。
SECOC_E_PARAM:参数无效。
SECOC_E_BUSY:模块忙。
SECOC_E_VERIFICATION_FAILED:认证失败(FV 或 MAC 错误)。
SECOC_E_FRESHNESS_FAILED:Freshness 验证失败。
校对轮次:L1 自动校对(2026-06-13)