Crypto Driver (Crypto)
Low-level driver executing cryptographic primitives on hardware security modules (HSM) or software libraries.
Funktionen — Übersicht
void Crypto_Init (const Crypto_ConfigType* configPtr);Initializes the Crypto Driver.void Crypto_GetVersionInfo (Std_VersionInfoType* versioninfo);Returns the version information of this module.Std_ReturnType Crypto_ProcessJob (uint32 objectId, Crypto_JobType* job);Service Crypto_ProcessJob.Std_ReturnType Crypto_CancelJob (uint32 objectId, Crypto_JobType* job);This interface removes the provided job from the queue and cancels the processing of the job if possible.Std_ReturnType Crypto_KeyElementSet (uint32 cryptoKeyId, uint32 keyElementId, const uint8* keyPtr, uint32 keyLength);Sets the given key element bytes to the key identified by crypto Key Id.Std_ReturnType Crypto_KeySetValid (uint32 cryptoKeyId);Sets the key state of the key identified by crypto Key Id to valid.Std_ReturnType Crypto_KeySetInvalid (uint32 cryptoKeyId);Sets invalid for the status of the key identifi ed by crypto Key Id.Std_ReturnType Crypto_KeyElementGet (uint32 cryptoKeyId, uint32 keyElementId, uint8* resultPtr, uint32* resultLengthPtr);This interface shall be used to get a key element of the key identified by the cryptoStd_ReturnType Crypto_KeyGetStatus (uint32 cryptoKeyId, Crypto_KeyStatusType* keyStatusPtr);Returns the key state of the key identified by crypto Key Id.Std_ReturnType Crypto_KeyElementCopy (uint32 cryptoKeyId, uint32 keyElementId, uint32 targetCryptoKeyId, uint32 targetKeyElementId);Service Crypto_KeyElementCopy.Std_ReturnType Crypto_KeyElementCopyPartial (uint32 cryptoKeyId, uint32 keyElementId, uint32 keyElementSourceOffset, uint32 keyElementTargetOffset, uint32 keyElementCopyLength, uint32 targetCryptoKeyId, uint32 targetKeyElementId);Service Crypto_KeyElementCopyPartial.Std_ReturnType Crypto_KeyCopy (uint32 cryptoKeyId, uint32 targetCryptoKeyId);Copies a key with all its elements to another key in the same crypto driver.Std_ReturnType Crypto_KeyElementIdsGet (uint32 cryptoKeyId, uint32* keyElementIdsPtr, uint32* keyElementIdsLengthPtr);Used to retrieve information which key elements are available in a given key.Std_ReturnType Crypto_RandomSeed (uint32 cryptoKeyId, const uint8* seedPtr, uint32 seedLength);This function generates the internal seed state using the pro vided entropy source.Std_ReturnType Crypto_KeyGenerate (uint32 cryptoKeyId);Generates new key material store it in the key identified by crypto Key Id.Std_ReturnType Crypto_KeyDerive (uint32 cryptoKeyId, uint32 targetCryptoKeyId);Derives a new key by using the key elements in the given key identified by the crypto Key Id.Std_ReturnType Crypto_KeyExchangeCalcPubVal (uint32 cryptoKeyId, uint8* publicValuePtr, uint32* publicValueLengthPtr);Calculates the public value for the key exchange a nd stores the public key in the memory location pointed by the public value...Std_ReturnType Crypto_KeyExchangeCalcSecret (uint32 cryptoKeyId, const uint8* partnerPublicValuePtr, uint32 partnerPublicValueLength);Calculates the shared secret key for the key exchange with the key material of the key identified by the crypto Key Id and the...void Crypto_MainFunction (void);If asynchronous job processing is configured and there are job queues, the function is called cyclically to process queued jobs.
Typen — Übersicht
struct Crypto_ConfigTypeConfiguration data structure of Cry If module
Funktionen & Typen — Detailansicht
函数 Crypto_Init [SWS_Crypto_91000] 📄 PDF
void Crypto_Init (const Crypto_ConfigType* configPtr);
Initializes the Crypto Driver.
函数 Crypto_Init 用于根据 [SWS_Crypto_91000] 初始化 Crypto Driver。该接口在头文件 Crypto.h 中声明,其服务 ID 为 0x00 [SWS_Crypto_91000]。
针对调用和接口参数指定了以下属性:
- 配置指针:通过类型为
const Crypto_ConfigType*的输入参数configPtr传递指向所选配置结构的指针 [SWS_Crypto_91000]。 - 返回值:该函数没有返回值(
void);既不存在输入/输出参数,也不存在单独的输出参数 [SWS_Crypto_91000]。 - 执行特性:初始化例程以同步方式执行(
Synchronous)[SWS_Crypto_91000]。 - 可重入性:该函数被定义为不可重入(
Non Reentrant)[SWS_Crypto_91000]。不允许并行或重叠调用。
由于被归类为不可重入,且规范未返回特定的错误代码,因此调用通常应在 ECU 启动阶段集中进行,且早于所有其他驱动程序访问(解释)。 问题 Q-008bb5a45b823891 (未决)调用方还应负责确保所引用的配置结构在内存中持续有效(解释)。 问题 Q-6271a86fad440121 (未决)
本使用说明由 AI 基于 AUTOSAR CP R20-11 规范生成。
实现者指南即将推出(复杂度 I1)
函数 Crypto_GetVersionInfo [SWS_Crypto_91001] 📄 PDF
void Crypto_GetVersionInfo (Std_VersionInfoType* versioninfo);
Returns the version information of this module.
函数 Crypto_ProcessJob [SWS_Crypto_91003] 📄 PDF
Std_ReturnType Crypto_ProcessJob (uint32 objectId, Crypto_JobType* job);
Service Crypto_ProcessJob.
函数 Crypto_ProcessJob 在由 objectId 引用的 Crypto Driver Object 上执行在参数 job 中配置的加密原语 [SWS_Crypto_91003]。该调用是可重入的,并根据作业配置以同步或异步方式工作 [SWS_Crypto_91003]。通过指向 Crypto_JobType 的指针,既传递原语的配置数据,也传递用于结果数据的缓冲区 [SWS_Crypto_91003]。
在实际执行作业之前,驱动程序会检查密钥标识符的有效性:如果 job->cryptoKeyId 或(在适用情况下)job->targetCryptoKeyId 超出允许范围,该函数将向 DET 报告错误 CRYPTO_E_PARAM_HANDLE 并返回 E_NOT_OK [SWS_Crypto_00217]。如果 job->targetCryptoKeyId 无效,这也同样适用于服务 CRYPTO_KEYDERIVE(job->jobPrimitiveInfo->primitiveInfo->service)[SWS_Crypto_00202]。
除了 E_OK 和 E_NOT_OK 之外,特定的错误代码也指示请求失败 [SWS_Crypto_91003]:
CRYPTO_E_BUSY,如果驱动程序对象被占用或其队列已满 [SWS_Crypto_91003],- 与密钥相关的错误,例如
CRYPTO_E_KEY_NOT_VALID、CRYPTO_E_KEY_SIZE_MISMATCH、CRYPTO_E_KEY_READ_FAIL、CRYPTO_E_KEY_WRITE_FAIL、CRYPTO_E_KEY_NOT_AVAILABLE或CRYPTO_E_KEY_EMPTY[SWS_Crypto_91003], CRYPTO_E_JOB_CANCELED,在同步作业被中止时 [SWS_Crypto_91003],以及CRYPTO_E_ENTROPY_EXHAUSTED,在随机数生成器的熵不足时;此时,该函数还会报告运行时错误CRYPTO_E_RE_ENTROPY_EXHAUSTED[SWS_Crypto_00141], [SWS_Crypto_91003]。
该文本由 AI 基于 AUTOSAR R20-11 规范数据生成。
实现者指南即将推出(复杂度 I1)
函数 Crypto_CancelJob [SWS_Crypto_00122] 📄 PDF
Std_ReturnType Crypto_CancelJob (uint32 objectId, Crypto_JobType* job);
This interface removes the provided job from the queue and cancels the processing of the job if possible.
使用
同步函数 Crypto_CancelJob 从队列中移除传入的作业,并尽可能中止其处理 [SWS_Crypto_00122]。调用时,会传递 Crypto Driver Object 的标识符(objectId)以及指向作业配置的指针(job)[SWS_Crypto_00122]。
返回值指示中止尝试的结果:
E_OK:请求成功,作业已被移除 [SWS_Crypto_00122]。如果驱动程序中不存在错误且该作业当前未被处理,则该服务同样返回E_OK,无需采取进一步操作 [SWS_Crypto_00214]。E_NOT_OK:请求失败,因为无法移除作业 [SWS_Crypto_00122]。CRYPTO_E_JOB_CANCELED:作业已被取消,但仍在继续执行;不会向应用程序返回任何结果 [SWS_Crypto_00122]。这适用于驱动程序工作正常,但(例如由于硬件限制)无法中止该作业的情况 [SWS_Crypto_00183]。
并发性与限制
该接口针对不同实例是可重入的,但不得针对同一个 Crypto Driver Object 同时调用 [SWS_Crypto_00122]。
该使用提示系自动生成,且完全基于 AUTOSAR R20-11 的规范数据。
实现者指南即将推出(复杂度 I1)
函数 Crypto_KeyElementSet [SWS_Crypto_91004] 📄 PDF
Std_ReturnType Crypto_KeyElementSet (uint32 cryptoKeyId, uint32 keyElementId, const uint8* keyPtr, uint32 keyLength);
Sets the given key element bytes to the key identified by crypto Key Id.
同步函数 Crypto_KeyElementSet 用于在加密驱动程序中为通过 cryptoKeyId 标识的密钥设置特定密钥元素的原始数据 [SWS_Crypto_91004]。
参数与返回值
通过 keyElementId 寻址目标密钥元素,而 keyPtr 指向数据缓冲区,keyLength 指向其字节大小 [SWS_Crypto_91004]。赋值成功时,接口返回 E_OK [SWS_Crypto_91004]。
错误处理
如果处理过程中出现错误,函数将返回特定的返回值 [SWS_Crypto_91004]:
CRYPTO_E_BUSY:关联的加密驱动程序对象被占用。CRYPTO_E_KEY_WRITE_FAIL:对密钥元素的写访问被拒绝。CRYPTO_E_KEY_NOT_AVAILABLE:请求的密钥元素或密钥不可用。CRYPTO_E_KEY_SIZE_MISMATCH:传入的数据长度与密钥元素的大小不匹配。E_NOT_OK:请求由于其他原因失败。
并发性
该函数被指定为不可重入(Non Reentrant)[SWS_Crypto_91004]。解释:调用方应负责对并行调用相互进行同步,以防止驱动程序中的数据不一致。 问题 Q-d7ef7a774052a212 (未决)
该使用提示基于规范 SWS_Crypto_91004 (R20-11) 自动生成。
实现者指南即将推出(复杂度 I1)
函数 Crypto_KeySetValid [SWS_Crypto_91014] 📄 PDF
Std_ReturnType Crypto_KeySetValid (uint32 cryptoKeyId);
Sets the key state of the key identified by crypto Key Id to valid.
同步函数 Crypto_KeySetValid 用于将通过标识符 cryptoKeyId 指定的密钥的状态设置为有效([SWS_Crypto_91014])。该接口可通过头文件 Crypto.h 获取,其服务 ID 为 0x05([SWS_Crypto_91014])。
使用时定义了以下参数和返回值([SWS_Crypto_91014]):
- 输入参数:通过
cryptoKeyId(类型uint32)传递要将其状态设置为有效的密钥的标识符([SWS_Crypto_91014])。不存在额外的输入或输出参数([SWS_Crypto_91014])。 - 返回值:类型为
Std_ReturnType的状态代码用于指示请求的结果([SWS_Crypto_91014]):E_OK:请求成功([SWS_Crypto_91014])。E_NOT_OK:请求失败([SWS_Crypto_91014])。CRYPTO_E_BUSY:执行失败,因为负责的 Crypto-Driver-Objekt 被占用([SWS_Crypto_91014])。
在并发性方面,该函数被指定为不可重入(“Non Reentrant”)([SWS_Crypto_91014])。Interpretation:调用方可能需要在任务之间外部协调并行调用以避免冲突,并且在收到 CRYPTO_E_BUSY 时应安排在稍后时间重试调用。 问题 Q-32d775a9e61e5731 (未决)
本文由 AI 生成,基于 AUTOSAR R20-11 规范版本。
实现者指南即将推出(复杂度 I1)
函数 Crypto_KeySetInvalid [SWS_Crypto_91020] 📄 PDF
Std_ReturnType Crypto_KeySetInvalid (uint32 cryptoKeyId);
Sets invalid for the status of the key identifi ed by crypto Key Id.
用法与语义
同步函数 Crypto_KeySetInvalid 将通过 cryptoKeyId 标识的密钥的状态设置为无效 [SWS_Crypto_91020]。该函数在头文件 Crypto.h 中定义,并通过服务 ID 0x15 进行调用 [SWS_Crypto_91020]。作为唯一的传递参数,输入值 cryptoKeyId(类型 uint32)包含目标密钥的唯一标识符;不存在输入/输出参数以及输出参数 [SWS_Crypto_91020]。
错误处理与返回值
函数执行的结果通过类型为 Std_ReturnType 的返回值发出指示 [SWS_Crypto_91020]:
E_OK:请求成功,且密钥状态已设置为无效 [SWS_Crypto_91020]。E_NOT_OK:请求的执行失败 [SWS_Crypto_91020]。CRYPTO_E_BUSY:请求失败,因为负责的加密驱动对象(Crypto Driver Object)当前被占用 [SWS_Crypto_91020]。
并发性与限制
该接口被指定为不可重入(Non Reentrant)[SWS_Crypto_91020]。因此不允许并发或中断调用。由于该函数是同步执行的,它仅在状态更改完成或确定错误后才会返回给调用方 [SWS_Crypto_91020]。
本使用说明基于规范自动生成。
实现者指南即将推出(复杂度 I1)
函数 Crypto_KeyElementGet [SWS_Crypto_91006] 📄 PDF
Std_ReturnType Crypto_KeyElementGet (uint32 cryptoKeyId, uint32 keyElementId, uint8* resultPtr, uint32* resultLengthPtr);
This interface shall be used to get a key element of the key identified by the crypto
同步且可重入的函数 Crypto_KeyElementGet 用于从密钥 cryptoKeyId 中读取由 keyElementId 标识的密钥元素,并保存在内存区域 resultPtr 中 [SWS_Crypto_91006]。该接口通过头文件 Crypto.h 提供,服务 ID 为 0x06 [SWS_Crypto_91006]。调用时,调用方通过输入输出参数 resultLengthPtr 传递缓冲区大小,或在配置了部分访问时传递所需的读取大小;执行完成后,驱动程序将在其中存放实际复制的数据量 [SWS_Crypto_91006]。
成功时,函数返回 E_OK [SWS_Crypto_91006]。如果操作失败,则通过特定的错误代码发出信号:在加密驱动程序对象被占用时返回 CRYPTO_E_BUSY,在密钥元素不可用时返回 CRYPTO_E_KEY_NOT_AVAILABLE,在读取访问被拒绝时返回 CRYPTO_E_KEY_READ_FAIL,在源元素未初始化时返回 CRYPTO_E_KEY_EMPTY,以及通用的 E_NOT_OK [SWS_Crypto_91006]。
尽管该接口被指定为可重入,但规范指出,在密钥元素直接映射到 Flash 存储器的情况下,同步执行期间可能会出现明显的延迟 [SWS_Crypto_91006]。解释:由于存在这些潜在的延迟,该调用主要应在任务上下文中进行,而不宜在时间关键的中断服务例程内调用。 问题 Q-ff4e2843b9aad46d (未决)
该使用提示系自动生成,并基于 AUTOSAR Classic R20-11 规范版本。
实现者指南即将推出(复杂度 I1)
函数 Crypto_KeyGetStatus [SWS_Crypto_91019] 📄 PDF
Std_ReturnType Crypto_KeyGetStatus (uint32 cryptoKeyId, Crypto_KeyStatusType* keyStatusPtr);
Returns the key state of the key identified by crypto Key Id.
同步函数 Crypto_KeyGetStatus 用于查询 Crypto 驱动程序 [SWS_Crypto_91019] 内特定密钥的当前状态。它通过头文件 Crypto.h 提供,并具有服务 ID 0x14 [SWS_Crypto_91019]。
用法与参数
该调用为同步执行,并需要两个参数 [SWS_Crypto_91019]:
cryptoKeyId:要确定其状态的密钥标识符。keyStatusPtr:指向类型为Crypto_KeyStatusType的存储区域的指针,状态将返回到该区域。
作为返回值,该接口返回 Std_ReturnType。成功执行时报告 E_OK,而出错时返回 E_NOT_OK [SWS_Crypto_91019]。
并发性与限制
该函数声明为不可重入(Non Reentrant)[SWS_Crypto_91019]。因此,调用方必须确保通过上层同步机制避免并发调用。未列出特定的 DET 错误消息;大概率错误的调用(例如无效指针或无效 ID)会直接导致返回 E_NOT_OK [SWS_Crypto_91019]。 问题 Q-5703fab02905e91a (未决)
此文本由 AI 创建,基于 AUTOSAR R20-11 规范。
实现者指南即将推出(复杂度 I1)
函数 Crypto_KeyElementCopy [SWS_Crypto_00148] 📄 PDF
Std_ReturnType Crypto_KeyElementCopy (uint32 cryptoKeyId, uint32 keyElementId, uint32 targetCryptoKeyId, uint32 targetKeyElementId);
Service Crypto_KeyElementCopy.
同步函数 Crypto_KeyElementCopy 用于在同一个加密驱动程序内将一个密钥元素复制到另一个密钥元素 [SWS_Crypto_00148]。传递的参数包括源密钥(cryptoKeyId)和源密钥元素(keyElementId)以及目标密钥(targetCryptoKeyId)和目标密钥元素(targetKeyElementId)的标识符 [SWS_Crypto_00148]。
在时序特性方面需要注意,对于直接映射在 Flash 存储器中的密钥元素,由于同步执行,函数调用时可能会产生较大的延迟 [SWS_Crypto_00148]。因此,尤其是在时间关键型上下文中,必须考虑运行时间特性。
该函数被设计为可重入的,但明确不能针对相同的 cryptoKeyId [SWS_Crypto_00148]。因此,使用相同源密钥的并发调用必须由调用方进行同步或排除。
成功时,函数返回 E_OK [SWS_Crypto_00148]。出现错误时,返回值指示具体原因 [SWS_Crypto_00148]:
CRYPTO_E_BUSY:加密驱动程序对象被占用 [SWS_Crypto_00148]。CRYPTO_E_KEY_NOT_AVAILABLE:至少一个密钥的所请求密钥元素不可用 [SWS_Crypto_00148]。CRYPTO_E_KEY_READ_FAIL或CRYPTO_E_KEY_WRITE_FAIL:不允许读取源元素或写入目标元素 [SWS_Crypto_00148]。CRYPTO_E_KEY_SIZE_MISMATCH:密钥元素的大小彼此不兼容 [SWS_Crypto_00148]。CRYPTO_E_KEY_EMPTY:源密钥元素未初始化 [SWS_Crypto_00148]。E_NOT_OK:请求发生一般性失败 [SWS_Crypto_00148]。
此使用说明基于 AUTOSAR Classic R20-11 规范自动生成。
实现者指南即将推出(复杂度 I1)
函数 Crypto_KeyElementCopyPartial [SWS_Crypto_91015] 📄 PDF
Std_ReturnType Crypto_KeyElementCopyPartial (uint32 cryptoKeyId, uint32 keyElementId, uint32 keyElementSourceOffset, uint32 keyElementTargetOffset, uint32 keyElementCopyLength, uint32 targetCryptoKeyId, uint32 targetKeyElementId);
Service Crypto_KeyElementCopyPartial.
同步函数 Crypto_KeyElementCopyPartial 用于将数据从源密钥元素部分复制到同一加密驱动程序内的目标密钥元素中 [SWS_Crypto_91015]。通过参数 keyElementSourceOffset 和 keyElementCopyLength 确定源元素中要复制的片段(cryptoKeyId、keyElementId),而 keyElementTargetOffset 确定目标元素中的起始位置(targetCryptoKeyId、targetKeyElementId)。若检查无误,驱动程序将同步执行复制过程并返回 E_OK [SWS_Crypto_00209]。
在执行之前,驱动程序会验证缓冲区状态和驱动程序状态:
- 若加密驱动程序未初始化且开发错误检测已启用,该函数将向 DET 报告
CRYPTO_E_UNINIT并返回E_NOT_OK[SWS_Crypto_00205]。 - 若源密钥元素的总长度小于
keyElementSourceOffset + keyElementCopyLength,则调用失败并返回CRYPTO_E_KEY_SIZE_MISMATCH[SWS_Crypto_00207]。 - 若目标密钥元素的最大缓冲区提供的空间少于
keyElementTargetOffset + keyElementCopyLength,同样会报告CRYPTO_E_KEY_SIZE_MISMATCH[SWS_Crypto_00208]。 - 其他指定的错误值包括
CRYPTO_E_BUSY(驱动对象被占用)、CRYPTO_E_KEY_EMPTY(未初始化的源元素)、CRYPTO_E_KEY_NOT_AVAILABLE以及读或写访问错误(CRYPTO_E_KEY_READ_FAIL、CRYPTO_E_KEY_WRITE_FAIL)等 [SWS_Crypto_91015]。
该函数是可重入的,但不得针对同一密钥 ID cryptoKeyId 同时调用 [SWS_Crypto_91015]。若某个密钥元素直接存储在闪存中,同步执行可能会导致明显的时延 [SWS_Crypto_91015]。
本使用说明基于 AUTOSAR 规范 R20-11 自动生成。
实现者指南即将推出(复杂度 I2)
函数 Crypto_KeyCopy [SWS_Crypto_00155] 📄 PDF
Std_ReturnType Crypto_KeyCopy (uint32 cryptoKeyId, uint32 targetCryptoKeyId);
Copies a key with all its elements to another key in the same crypto driver. Note: If the actual key element is directly mapped to flash memory, there could be a bigger delay when calling this function (synchronous operation)
使用
同步函数 Crypto_KeyCopy 将一个密钥连同其所有密钥元素复制到同一 Crypto 驱动程序内的目标密钥中 [SWS_Crypto_00155]。映射通过用于源密钥的输入参数 cryptoKeyId 以及用于目标密钥的 targetCryptoKeyId 进行 [SWS_Crypto_00155]。成功的复制过程将通过 E_OK 进行确认 [SWS_Crypto_00155]。
并发性与运行时行为
该接口设计为可重入,但不允许同时针对同一 cryptoKeyId 执行 [SWS_Crypto_00155]。由于执行是同步进行的,对于直接存储在闪存中的密钥元素,调用期间可能会出现明显的时延 [SWS_Crypto_00155]。
错误处理
在出错的情况下,该函数提供类型为 Std_ReturnType 的特定返回值 [SWS_Crypto_00155]:
CRYPTO_E_BUSY:关联的 Crypto Driver Object 正忙 [SWS_Crypto_00155]。CRYPTO_E_KEY_NOT_AVAILABLE:所请求的密钥中至少有一个不可用 [SWS_Crypto_00155]。CRYPTO_E_KEY_READ_FAIL:不允许读取源密钥元素 [SWS_Crypto_00155]。CRYPTO_E_KEY_WRITE_FAIL:不允许写入目标密钥元素 [SWS_Crypto_00155]。CRYPTO_E_KEY_SIZE_MISMATCH:密钥元素的大小彼此不兼容 [SWS_Crypto_00155]。CRYPTO_E_KEY_EMPTY:源密钥的密钥元素未初始化 [SWS_Crypto_00155]。E_NOT_OK:请求的执行失败 [SWS_Crypto_00155]。
本使用说明由 AI 基于 AUTOSAR CP R20-11 规范生成。
函数 Crypto_KeyElementIdsGet [SWS_Crypto_00160] 📄 PDF
Std_ReturnType Crypto_KeyElementIdsGet (uint32 cryptoKeyId, uint32* keyElementIdsPtr, uint32* keyElementIdsLengthPtr);
Used to retrieve information which key elements are available in a given key.
同步函数 Crypto_KeyElementIdsGet 用于查询给定密钥中存在哪些可用密钥元素的信息 [SWS_Crypto_00160]。通过输入参数 cryptoKeyId 传递要导出其可用元素 ID 的密钥标识符 [SWS_Crypto_00160]。确定的标识符将保存在由指针 keyElementIdsPtr 引用的数组中 [SWS_Crypto_00160]。
缓冲区大小的管理通过输入/输出参数 keyElementIdsLengthPtr 进行:调用时,该参数必须包含所提供缓冲区的大小 keyElementIdsPtr [SWS_Crypto_00160]。操作完成后,其中将存放现有密钥元素的实际数量 [SWS_Crypto_00160]。
作为返回值,服务在查询成功时返回 E_OK,如果请求失败则返回 E_NOT_OK [SWS_Crypto_00160]。若负责的加密驱动程序对象在调用时处于忙状态,则返回错误代码 CRYPTO_E_BUSY [SWS_Crypto_00160]。
关于并发性,该函数是可重入的,但不得针对相同的 cryptoKeyId 同时调用 [SWS_Crypto_00160]。声明可在头文件 Crypto.h 中获取 [SWS_Crypto_00160]。
此文本由 AI 基于 AUTOSAR 规范生成。
实现者指南即将推出(复杂度 I1)
函数 Crypto_RandomSeed [SWS_Crypto_91013] 📄 PDF
Std_ReturnType Crypto_RandomSeed (uint32 cryptoKeyId, const uint8* seedPtr, uint32 seedLength);
This function generates the internal seed state using the pro vided entropy source. Furthermore, this function can be used to update the seed state with new entropy
根据 [SWS_Crypto_91013],同步函数 Crypto_RandomSeed(服务 ID 0x0d)用于利用所提供的熵源生成以及更新密钥的内部种子状态。函数声明包含在头文件 Crypto.h 中。
用法和调用参数
根据 [SWS_Crypto_91013],除了初始生成之外,该函数还可用于使用新熵更新种子状态。该同步调用需要三个输入参数:
cryptoKeyId:传递要为其生成新种子的密钥标识符。seedPtr:保存指向包含用于注入种子的数据之存储区域的指针。seedLength:以字节为单位定义所传递种子数据的长度。
返回值与错误处理
作为返回值,Crypto_RandomSeed 根据 [SWS_Crypto_91013] 返回类型为 Std_ReturnType 的状态:
E_OK:请求已成功执行。E_NOT_OK:请求失败。CRYPTO_E_KEY_NOT_VALID:执行失败,因为由cryptoKeyId标识的密钥之密钥状态处于“invalid”状态。
并发性与限制
根据 [SWS_Crypto_91013],该函数被指定为可重入,但明确指出对于相同的 cryptoKeyId 不可重入。因此,调用方必须防止针对同一密钥的并行调用。
此文本由 AI 生成,且仅基于有效载荷中的规范数据。
实现者指南即将推出(复杂度 I1)
函数 Crypto_KeyGenerate [SWS_Crypto_91007] 📄 PDF
Std_ReturnType Crypto_KeyGenerate (uint32 cryptoKeyId);
Generates new key material store it in the key identified by crypto Key Id.
使用
通过头文件 Crypto.h 提供的函数 Crypto_KeyGenerate 生成新的密钥材料并更新通过标识符 cryptoKeyId 寻址的密钥 [SWS_Crypto_91007]。该函数完全同步工作,并定义在服务 ID 0x07 下 [SWS_Crypto_91007]。除密钥标识符外,不存在其他参数 [SWS_Crypto_91007]。
并发性与限制
关于并发性,Crypto_KeyGenerate 被指定为可重入,但明确有限制条件,即这不适用于相同的 cryptoKeyId [SWS_Crypto_91007]。如果针对同一个密钥提出多个请求,则必须在调用方进行同步,以避免驱动程序冲突。
返回值与错误处理
通过基本类型为 Std_ReturnType 的返回值,调用方可获得关于操作成功或特定错误原因的详细反馈 [SWS_Crypto_91007]:
E_OK:密钥生成成功执行 [SWS_Crypto_91007]。CRYPTO_E_BUSY:请求失败,因为负责的 Crypto Driver Object 当前处于占用状态 [SWS_Crypto_91007]。CRYPTO_E_KEY_EMPTY:生成失败,因为所需的源密钥元素未初始化 [SWS_Crypto_91007]。CRYPTO_E_KEY_NOT_VALID:操作失败,因为由cryptoKeyId引用的密钥的密钥状态被标记为无效 [SWS_Crypto_91007]。E_NOT_OK:密钥生成请求由于其他原因失败 [SWS_Crypto_91007]。
此使用说明基于 AUTOSAR Classic R20-11 规范自动生成。
函数 Crypto_KeyDerive [SWS_Crypto_91008] 📄 PDF
Std_ReturnType Crypto_KeyDerive (uint32 cryptoKeyId, uint32 targetCryptoKeyId);
Derives a new key by using the key elements in the given key identified by the crypto Key Id. The given key contains the key elements for the password, salt. The derived key is stored in the key element with the id 1 of the key identified by target Crypto Key Id. The number of iterations is given in the key element CRYPTO_ KE_ KEYDERIVATION_ ITERATIONS.
同步函数 Crypto_KeyDerive 从源密钥(cryptoKeyId)的密钥元素派生出新的加密密钥,并将其存储在目标密钥(targetCryptoKeyId)中 ID 为 1 的密钥元素中 [SWS_Crypto_91008]。源密钥必须包含用于密码和 Salt 的必要密钥元素;迭代次数通过密钥元素 CRYPTO_KE_KEYDERIVATION_ITERATIONS 指定 [SWS_Crypto_91008]。
调用与并发性
该接口是可重入的,但不得针对相同的 cryptoKeyId 同时调用 [SWS_Crypto_91008]。因此,调用方必须确保并行派生操作在不同的源密钥上进行。
返回值与错误处理
该函数通过类型为 Std_ReturnType 的已定义返回值指示结果 [SWS_Crypto_91008]:
E_OK:密钥派生成功执行。E_NOT_OK:派生失败。如果参数targetCryptoKeyId超出有效范围,且在开发错误检测激活时,该函数还会向 DET 报告CRYPTO_E_PARAM_HANDLE[SWS_Crypto_00180]。CRYPTO_E_BUSY:负责的 Crypto Driver Object 正忙 [SWS_Crypto_91008]。CRYPTO_E_KEY_EMPTY:所需的源密钥元素未初始化 [SWS_Crypto_91008]。CRYPTO_E_KEY_NOT_VALID:由cryptoKeyId引用的密钥状态无效 [SWS_Crypto_91008]。
本使用说明基于规范自动生成。
实现者指南即将推出(复杂度 I1)
函数 Crypto_KeyExchangeCalcPubVal [SWS_Crypto_91009] 📄 PDF
Std_ReturnType Crypto_KeyExchangeCalcPubVal (uint32 cryptoKeyId, uint8* publicValuePtr, uint32* publicValueLengthPtr);
Calculates the public value for the key exchange a nd stores the public key in the memory location pointed by the public value pointer.
使用
同步函数 Crypto_KeyExchangeCalcPubVal 计算密钥交换协议的公开值并将其保存在 publicValuePtr 的存储位置([SWS_Crypto_91009])。调用方通过 cryptoKeyId 传递用于该协议的密钥标识符。通过输入输出参数 publicValueLengthPtr,在调用时必须传递所提供存储区的缓冲区大小;执行完成后,将在其中存放计算出的公开值的实际长度([SWS_Crypto_91009])。
错误处理与返回值
执行成功时,函数返回 E_OK。如果发生错误,则返回 E_NOT_OK 或特定的错误代码([SWS_Crypto_91009]):
CRYPTO_E_BUSY:请求失败,因为 Crypto Driver Object 被占用。CRYPTO_E_KEY_EMPTY:请求失败,因为源密钥元素未初始化。CRYPTO_E_KEY_NOT_VALID:请求失败,因为通过cryptoKeyId引用的密钥状态无效。
并发性与系统集成
根据 [SWS_Crypto_91009],该函数是可重入的,但不能针对相同的 cryptoKeyId。如果加密驱动程序出于内部目的(如 Crypto_KeyExchangeCalcPubVal)需要随机数生成器(RNG)的服务,则必须将第一个 Crypto Driver Object(对象编号 0)配置用于此目的([SWS_Crypto_00224])。
该文本由 AI 生成。所有信息均基于 AUTOSAR Classic R20-11 规范。
实现者指南即将推出(复杂度 I1)
函数 Crypto_KeyExchangeCalcSecret [SWS_Crypto_91010] 📄 PDF
Std_ReturnType Crypto_KeyExchangeCalcSecret (uint32 cryptoKeyId, const uint8* partnerPublicValuePtr, uint32 partnerPublicValueLength);
Calculates the shared secret key for the key exchange with the key material of the key identified by the crypto Key Id and the partner public key. The shared secret key is stored as a key element in the same key.
同步函数 Crypto_KeyExchangeCalcSecret 用于计算密钥交换协议的共享密钥(Shared Secret Key)[SWS_Crypto_91010]。它处理通过 cryptoKeyId 指定的密钥的密钥材料以及通过 partnerPublicValuePtr 传递的伙伴公开值,后者的字节数通过 partnerPublicValueLength 指定 [SWS_Crypto_91010]。计算出的共享密钥直接作为密钥元素存储在同一个密钥内 [SWS_Crypto_91010]。
作为返回值,函数通过 Std_ReturnType 提供状态 [SWS_Crypto_91010]:
E_OK:密钥的计算和存储成功完成 [SWS_Crypto_91010]。E_NOT_OK:请求失败 [SWS_Crypto_91010]。CRYPTO_E_BUSY:执行失败,因为负责的 Crypto Driver Object 处于占用状态 [SWS_Crypto_91010]。CRYPTO_E_KEY_EMPTY:源密钥元素未初始化 [SWS_Crypto_91010]。CRYPTO_E_KEY_NOT_VALID:由cryptoKeyId引用的密钥状态无效 [SWS_Crypto_91010]。
该接口以可重入方式实现,但不得针对相同的 cryptoKeyId 并发调用 [SWS_Crypto_91010]。因此,调用方必须确保避免使用相同密钥 ID 进行并发调用,并预先初始化所引用的密钥材料且使其处于有效状态,以防止出现错误状态 [SWS_Crypto_91010]。
该使用提示基于 SWS_Crypto_91010 规范自动生成。
函数 Crypto_MainFunction [SWS_Crypto_91012] 📄 PDF
void Crypto_MainFunction (void);
If asynchronous job processing is configured and there are job queues, the function is called cyclically to process queued jobs. AUTOSAR CP R20 - of Document ID : AUTOSAR_SWS_CryptoDriver
函数 Crypto_MainFunction 用于周期性处理加密驱动程序的作业队列中排队的加密作业 [SWS_Crypto_91012]。使用该函数的前提条件是,模块中已配置了异步作业处理,并且存在相应的作业队列 [SWS_Crypto_91012]。
调用与语义
该函数的签名是 void Crypto_MainFunction(void),指定的服务 ID 为 0x0c [SWS_Crypto_91012]。它不接受任何输入参数,也不提供返回值。该接口通过头文件 SchM_Crypto.h 提供 [SWS_Crypto_91012]。这允许做出如下解释:周期性调用通常由 BSW 调度器(Schedule Manager)在操作系统周期任务的上下文中触发。
并发性与限制
该调用严格绑定到异步作业队列的配置 [SWS_Crypto_91012]。由于规范未指出 Crypto_MainFunction 具有可重入性,因此该函数应被视为不可重入;因此应避免从多个线程或任务中进行并行调用。 问题 Q-038d384305c8c5c3 (未决)
错误处理
在规范中,未为此函数定义特定的错误代码或 DET 条目 [SWS_Crypto_91012]。由于该函数不提供返回值,异步处理期间发生的任何错误大概率会通过状态查询或各作业的反馈通道传递给上层。 问题 (未决)
本使用说明由 AI 基于 AUTOSAR CP R20-11 规范生成。
类型 Crypto_ConfigType [SWS_Crypto_91016] 📄 PDF
Configuration data structure of Cry If module
Request a governed re-review of this record. The record is not changed immediately.
- Record
AUTOSAR/AP/record/CP_MOD_Crypto- Status
- unspecified
- Version
AUTOSAR/AP/record/CP_MOD_Crypto@rel:R20-11#bbe93190- Content hash
bbe93190- Source
- https://www.autosar.org/fileadmin/standards/R20-11/CP/AUTOSAR_SWS_CryptoDriver.pdf#nameddest=SWS_Crypto_91000
gemini-3.8-flash-low· 2026-10-13 · 德文原文