类 ara::crypto::cryp::RandomGeneratorCtx
[SWS_CRYPT_22900] Upstream: RS_CRYPTO_02206
class RandomGeneratorCtx : public CryptoContext {...};
Interface of Random Number Generator Context.
| Header-Datei | #include "ara/crypto/cryp/random_generator_ctx.h" |
|---|
| Forwarding-Header | #include "ara/crypto/crypto_fwd.h" |
|---|
| Scope | namespace ara::crypto::cryp |
|---|
| Basisklasse(n) | CryptoContext |
|---|
用户指南人工智能生成
生成加密随机数据,并管理生成器的内部状态及其熵输入。
AI 生成
未审核
模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: ef81953cc5a7
来源
未决问题(1)
生成加密随机数据,并管理生成器的内部状态及其熵输入。
上下文
接口 ara::crypto::cryp::RandomGeneratorCtx 定义了 Adaptive 模块 crypto 内随机数生成器的加密上下文。作为 CryptoContext 的特化,该类用于生成加密安全的(伪)随机序列以及管理生成器的内部状态。应用程序服务通常访问此接口的实例,以获取用于安全相关协议的密钥材料、初始化向量或随机值。上下文实例的提供和交换主要通过共享智能指针进行,为此提供了类型别名 Sptr [SWS_CRYPT_22901]。
生命周期
随机数生成器上下文的生命周期通过经由 std::shared_ptr 的引用计数进行控制([SWS_CRYPT_22901])。在实例化之后,根据底层实现的不同,生成器要么已经处于就绪状态,要么需要由应用程序预先进行初始化。方法 Seed 用于初始化生成器的内部状态,它可以通过 ReadOnlyMemRegion [SWS_CRYPT_22911] 获取原始内存区域,或者通过类型为 SymmetricKey::Sptr [SWS_CRYPT_22912] 的对称密钥对象进行提供。根据规范,所有核心成员函数(Seed、AddEntropy 和 Generate)均被声明为异常安全(noexcept)且线程安全([SWS_CRYPT_22911]、[SWS_CRYPT_22912]、[SWS_CRYPT_22914]、[SWS_CRYPT_22915]),因此支持来自多个线程的并行调用而无需应用程序内部锁定。
使用路径
常规使用流程包括准备生成器状态、可选地混入更多熵以及随后获取随机数据:
时序图:RandomGeneratorCtx 上的状态初始化、熵供给与随机数生成的典型流程。来源:[SWS_CRYPT_22911]、[SWS_CRYPT_22912]、[SWS_CRYPT_22914]、[SWS_CRYPT_22915]
错误场景
这些操作在 ara::core::Result 中返回其结果,并在发生错误时具有已定义的回滚语义:
- 未初始化的上下文:尽管上下文强制要求预先播种,但应用程序仍调用了
Generate,则操作失败并返回 ara::crypto::CryptoErrc::kUninitializedContext [SWS_CRYPT_22915]。
- 熵不足:若因内部熵池耗尽而导致上下文暂时无法生成请求的字节量,则
Generate 报告错误 ara::crypto::CryptoErrc::kBusyResource [SWS_CRYPT_22915]。在这种情况下,应用程序可以在稍后时间重试调用或进行额外的播种。
- 不允许的密钥使用:若在
Seed 中传入了一个 SymmetricKey,且其配置的使用权限不包含标志 kAllowRngInit,则调用将被拒绝并返回 ara::crypto::CryptoErrc::kUsageViolation [SWS_CRYPT_22912]。
- 不支持的功能:若具体的上下文实现因原理原因不支持设置种子或随后混入熵,则
Seed([SWS_CRYPT_22911]、[SWS_CRYPT_22912])和 AddEntropy [SWS_CRYPT_22914] 会以错误码 ara::crypto::CryptoErrc::kUnsupported 确认此情况。
本指南基于 AUTOSAR Adaptive Platform R25-11 规范(crypto 模块),且完全依托所列出的规范要求。
成员图
类图
Hohle Dreieckspfeile = Vererbung (zeigt zur Basisklasse); Klicken öffnet die jeweilige Klassenseite.
详细视图
此版本没有元素数据
方法
Update the internal state of the RNG by mixing it with the provided additional entropy.
Fill the provided output buffer with a (pseudo)random sequence.
Set the internal state of the RNG using the provided seed.
重载 Seed 2
类型别名
Shared smart pointer of the interface.
方法文档
virtual ara::core::Result< void > AddEntropy (ReadOnlyMemRegion entropy) noexcept=0;
Update the internal state of the RNG by mixing it with the provided additional entropy.
AI 生成
未审核
模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: fa9161531f6a
来源
未决问题(1)
本使用说明基于规范自动生成。
实现者指南即将推出(复杂度 I1)
Parameter (in)
| Parameter | Beschreibung |
|---|
| entropy | a memory region with the additional entropy value |
Rückgabewert
| Typ | Beschreibung |
|---|
| ara::core::Result< void > | a result that is empty if the method is supported and the entropy has been added successfully, an error otherwise |
Fehler
Status: valid/unmigrated
Version: rel:R25-11#03de5ab1
Versionshistorie & Revisions (1 transition, 7 revision)
- Current State
valid/unmigrated
- Reason
- mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
- Campaign
2026-08-13-status-backfill
- Active Version
AUTOSAR/AP/record/SWS_CRYPT_22914@rel:R25-11#03de5ab1
Point-in-Time History:
Recorded Revisions (7):
- R25-11
rel:R25-11#c67920852026-09-30 - R20-11
rel:R20-11#79cd0e4d2026-10-14 - R21-11
rel:R21-11#79cd0e4d2026-10-14 - R22-11
rel:R22-11#ac415c9e2026-10-14 - R23-11
rel:R23-11#0440a4ee2026-10-14 - R24-11
rel:R24-11#75d73d2c2026-10-14 - R25-11
rel:R25-11#03de5ab12026-10-14 active
Historical Snapshot:
🚫
Requirement entfallen: Dieses Element ist im gewählten Release nicht mehr enthalten.
Requirement Text as-of this release:
Reachable Artifacts & Dependents:
| Date | Actor | Transition | Reason / Rationale | Campaign |
| 2026-08-13 | tool | none → valid/unmigrated | mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record | 2026-08-13-status-backfill |
virtual ara::core::Result< void > Generate (ReadWriteMemRegion output) noexcept=0;
Fill the provided output buffer with a (pseudo)random sequence.
AI 生成
未审核
模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: b447baebff9a
来源
接口 ara::crypto::cryp::RandomGeneratorCtx 的函数 Generate 用于使用(伪)随机序列填充提供的输出缓冲区 [SWS_CRYPT_22915]。作为传入参数,该方法接收类型为 ReadWriteMemRegion 的可写内存区域 output,生成的随机字节将直接写入其中 [SWS_CRYPT_22915]。
在执行安全性和并发性方面,该方法声明为 noexcept,被视为 Exception-safe,并明确指定为 thread-safe [SWS_CRYPT_22915]。这允许从多个线程进行并发调用。
错误处理
返回类型 ara::core::Result<void> 通过空结果指示操作成功,或者在发生错误时返回具有回滚语义的相应错误码 [SWS_CRYPT_22915]:
ara::crypto::CryptoErrc::kUninitializedContext:在上下文事先必须由应用程序初始化或注入熵(“seeded”)时发生 [SWS_CRYPT_22915]。
ara::crypto::CryptoErrc::kBusyResource:在上下文当前耗尽熵(“out-of-entropy”)从而无法提供请求数量的随机字节时返回 [SWS_CRYPT_22915]。
相互协作与区分
虽然 RandomGeneratorCtx::Generate 将原始随机数据字节写入缓冲区 [SWS_CRYPT_22915],但在模块 crypt 中还存在其他侧重点不同的生成函数:例如,CryptoProvider::GenerateSymmetricKey [SWS_CRYPT_20721] 用于实例化对称密钥,而 CryptoProvider::GeneratePrivateKey [SWS_CRYPT_20722] 用于生成非对称密钥对。此外,不应将该方法与 MessageAuthnCodeCtx 的同名函数 Generate 混淆,后者用于计算 MAC 摘要 [SWS_CRYPT_50029]。
本使用说明由 AI 基于规范创建。
Parameter (out)
| Parameter | Beschreibung |
|---|
| output | an output buffer the random sequence will be written into |
Rückgabewert
Fehler
Status: valid/unmigrated
Version: rel:R25-11#3fb7d1d3
Versionshistorie & Revisions (1 transition, 7 revision)
- Current State
valid/unmigrated
- Reason
- mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
- Campaign
2026-08-13-status-backfill
- Active Version
AUTOSAR/AP/record/SWS_CRYPT_22915@rel:R25-11#3fb7d1d3
Point-in-Time History:
Recorded Revisions (7):
- R25-11
rel:R25-11#f3af431f2026-09-30 - R20-11
rel:R20-11#2366a0852026-10-14 - R21-11
rel:R21-11#c128f5042026-10-14 - R22-11
rel:R22-11#8d39094f2026-10-14 - R23-11
rel:R23-11#31b6da982026-10-14 - R24-11
rel:R24-11#a6d941df2026-10-14 - R25-11
rel:R25-11#3fb7d1d32026-10-14 active
Historical Snapshot:
🚫
Requirement entfallen: Dieses Element ist im gewählten Release nicht mehr enthalten.
Requirement Text as-of this release:
Reachable Artifacts & Dependents:
| Date | Actor | Transition | Reason / Rationale | Campaign |
| 2026-08-13 | tool | none → valid/unmigrated | mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record | 2026-08-13-status-backfill |
virtual ara::core::Result< void > Seed (ReadOnlyMemRegion seed) noexcept=0;
Set the internal state of the RNG using the provided seed.
AI 生成
未审核
模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 1629638eb13a
来源
使用
接口 ara::crypto::cryp::RandomGeneratorCtx 的纯虚方法 Seed 用于通过提供的内存区域设置随机数生成器(RNG)的内部状态 [SWS_CRYPT_22911]。声明在头文件 ara/crypto/cryp/random_generator_ctx.h 中进行,签名如下:virtual ara::core::Result<void> Seed(ReadOnlyMemRegion seed) noexcept = 0; [SWS_CRYPT_22911]。
作为输入参数,该同步函数接收类型为 ReadOnlyMemRegion 的 seed,其中包含带有种子值的内存区域 [SWS_CRYPT_22911]。在成功执行且上下文支持的情况下,该方法返回一个空的 ara::core::Result<void> [SWS_CRYPT_22911]。
错误处理
出错时,返回的 ara::core::Result 包含相应的错误码 [SWS_CRYPT_22911]:
ara::crypto::CryptoErrc::kUnsupported:当具体的 RandomGeneratorCtx 不支持播种时发生;已为此错误情况指定回滚语义 [SWS_CRYPT_22911]。
并发性与限制
该接口声明为 noexcept,并在执行安全性方面被归类为 exception safe 以及 thread-safe [SWS_CRYPT_22911]。
相互作用
作为对此基于内存区域的函数的补充,[SWS_CRYPT_22912] 定义了一个重载 Seed(SymmetricKey::Sptr seed),其使用对称密钥初始化 RNG 的状态,并在此过程中评估如 kAllowRngInit 的使用限制。
本说明由 AI 生成,仅供参考。一切以官方 AUTOSAR 规范为准。
实现者指南即将推出(复杂度 I1)
Parameter (in)
| Parameter | Beschreibung |
|---|
| seed | a memory region with the seed value |
Rückgabewert
| Typ | Beschreibung |
|---|
| ara::core::Result< void > | a result that is empty if the method is supported and the state has been set successfully, an error otherwise |
Fehler
Status: valid/unmigrated
Version: rel:R25-11#2bcb8016
Versionshistorie & Revisions (1 transition, 8 revision)
- Current State
valid/unmigrated
- Reason
- mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
- Campaign
2026-08-13-status-backfill
- Active Version
AUTOSAR/AP/record/SWS_CRYPT_22911@rel:R25-11#2bcb8016
Point-in-Time History:
Recorded Revisions (8):
- R25-11
rel:R25-11#9fb457fe2026-09-30 - R19-11
rel:R19-11#193a3e4f2026-10-14 - R20-11
rel:R20-11#78f96a302026-10-14 - R21-11
rel:R21-11#78f96a302026-10-14 - R22-11
rel:R22-11#fba8b4f92026-10-14 - R23-11
rel:R23-11#95e124962026-10-14 - R24-11
rel:R24-11#3e5b43f12026-10-14 - R25-11
rel:R25-11#2bcb80162026-10-14 active
Historical Snapshot:
🚫
Requirement entfallen: Dieses Element ist im gewählten Release nicht mehr enthalten.
Requirement Text as-of this release:
Reachable Artifacts & Dependents:
| Date | Actor | Transition | Reason / Rationale | Campaign |
| 2026-08-13 | tool | none → valid/unmigrated | mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record | 2026-08-13-status-backfill |
virtual ara::core::Result< void > Seed (SymmetricKey::Sptr seed) noexcept=0;
Set the internal state of the RNG using the provided seed.
AI 生成
未审核
模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 13e7b6b96ba9
来源
未决问题(1)
此文本由 AI 系统基于规范数据生成。
实现者指南即将推出(复杂度 I1)
Parameter (in)
| Parameter | Beschreibung |
|---|
| seed | a SymmetricKey with the key used as seed value |
Rückgabewert
| Typ | Beschreibung |
|---|
| ara::core::Result< void > | a result that is empty if the method is supported and the state has been set successfully, an error otherwise |
Fehler
Status: valid/unmigrated
Version: rel:R25-11#54e43b09
Versionshistorie & Revisions (1 transition, 7 revision)
- Current State
valid/unmigrated
- Reason
- mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
- Campaign
2026-08-13-status-backfill
- Active Version
AUTOSAR/AP/record/SWS_CRYPT_22912@rel:R25-11#54e43b09
Point-in-Time History:
Recorded Revisions (7):
- R25-11
rel:R25-11#0427c1122026-09-30 - R20-11
rel:R20-11#5aeacae82026-10-14 - R21-11
rel:R21-11#5c22d3612026-10-14 - R22-11
rel:R22-11#1850986c2026-10-14 - R23-11
rel:R23-11#93854cda2026-10-14 - R24-11
rel:R24-11#ed5981cb2026-10-14 - R25-11
rel:R25-11#54e43b092026-10-14 active
Historical Snapshot:
🚫
Requirement entfallen: Dieses Element ist im gewählten Release nicht mehr enthalten.
Requirement Text as-of this release:
Reachable Artifacts & Dependents:
| Date | Actor | Transition | Reason / Rationale | Campaign |
| 2026-08-13 | tool | none → valid/unmigrated | mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record | 2026-08-13-status-backfill |
类型别名文档
using Sptr = std::shared_ptr<RandomGeneratorCtx>;
Shared smart pointer of the interface.
Status: valid/unmigrated
Version: rel:R25-11#7a09160c
Versionshistorie & Revisions (1 transition, 8 revision)
- Current State
valid/unmigrated
- Reason
- mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
- Campaign
2026-08-13-status-backfill
- Active Version
AUTOSAR/AP/record/SWS_CRYPT_22901@rel:R25-11#7a09160c
Point-in-Time History:
Recorded Revisions (8):
- R25-11
rel:R25-11#27c190352026-09-30 - R19-11
rel:R19-11#3a4f19922026-10-14 - R20-11
rel:R20-11#79345f482026-10-14 - R21-11
rel:R21-11#a390f4732026-10-14 - R22-11
rel:R22-11#7a7cdbaa2026-10-14 - R23-11
rel:R23-11#df7bd4af2026-10-14 - R24-11
rel:R24-11#c6c47a032026-10-14 - R25-11
rel:R25-11#7a09160c2026-10-14 active
Historical Snapshot:
🚫
Requirement entfallen: Dieses Element ist im gewählten Release nicht mehr enthalten.
Requirement Text as-of this release:
Reachable Artifacts & Dependents:
| Date | Actor | Transition | Reason / Rationale | Campaign |
| 2026-08-13 | tool | none → valid/unmigrated | mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record | 2026-08-13-status-backfill |
gemini-3.8-flash-low· 2026-10-13 · 德文原文