DEENESPTFRRUARHIKOZHNL

类 ara::crypto::cryp::PrivateKey

[SWS_CRYPT_22500] Upstream: RS_CRYPTO_02002, RS_CRYPTO_02403

class PrivateKey :         public CryptoObject {...};

Generalized Asymmetric Private Key interface.

Header-Datei#include "ara/crypto/cryp/cryobj/private_key.h"
Forwarding-Header#include "ara/crypto/crypto_fwd.h"
Scopenamespace ara::crypto::cryp
Basisklasse(n)CryptoObject

用户指南人工智能生成

封装非对称私钥并提供对应的公钥。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: cbfbff2bb90c 来源 未决问题(3)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

封装非对称私钥并提供对应的公钥。

接口 ara::crypto::cryp::PrivateKey 定义了 AUTOSAR Adaptive 中非对称私钥的通用接口,主要通过共享指针别名 PrivateKey::Sptr 进行管理 [SWS_CRYPT_22501]。其核心函数 GetPublicKey() 允许将关联的公钥作为 PublicKey::Sptr 获取,以便为加密对接操作提供该公钥 [SWS_CRYPT_22511]。此获取操作被指定为线程安全且异常安全,没有标准化错误码,其中潜在错误可能以实现特定的方式通过返回类型 ara::core::Result 指示(解释)。 问题 (未决)

上下文

接口 ara::crypto::cryp::PrivateKey 在 AUTOSAR Adaptive Platform 中充当 crypto 模块内非对称私钥的泛化接口。它在头文件 ara/crypto/cryp/cryobj/private_key.h 中声明,并直接继承自基接口 CryptoObject。作为非对称密码系统的核心组件,PrivateKey 封装了用于生成数字签名或非对称解密过程等加密操作所需的机密密钥材料。

除了基类 CryptoObject 之外,主要交互方尤其包括对应的公钥接口 PublicKey 以及消费加密服务和应用例程。虽然私钥必须始终保密,但该接口允许通过成员函数 GetPublicKey() 直接提供关联的公钥 [SWS_CRYPT_22511]。通过这种方式,实现了私钥与其数学对等物之间固定的类型关联关系。

PrivateKeyContext Anwendung Anwendung PrivateKey PrivateKey Anwendung->PrivateKey nutzt Sptr PublicKey PublicKey Anwendung->PublicKey empfaengt Sptr CryptoObject CryptoObject PrivateKey->CryptoObject erbt von PrivateKey->PublicKey 通过 GetPublicKey() 提供

上下文图:PrivateKey 在加密对象模型中的嵌入及其与对应 PublicKey 的关系。来源:[SWS_CRYPT_22501]、[SWS_CRYPT_22511]

生命周期

接口 PrivateKey 的实例通过类型化智能指针 PrivateKey::Sptr 进行管理和传递,该智能指针被定义为 std::shared_ptr<PrivateKey> 的类型别名 [SWS_CRYPT_22501]。该共享指针确保了共享所有权并通过引用计数实现自动资源管理,从而在最后一个引用失效时立即释放受保护的密钥材料。

由于 PrivateKey 是包含如 GetPublicKey() 等纯虚方法的抽象接口 [SWS_CRYPT_22511],应用程序无法直接实例化该类。PrivateKey::Sptr 具体实例的创建和提供大概率通过 Adaptive 系统的专用工厂、密钥管理组件或加密提供程序进行(解释)。 问题 Q-f0f9fe2258fac168 (未决)该接口本身没有定义离散的内部状态或状态转换。

在并发方面,接口为其核心成员函数 GetPublicKey() 显式指定了线程安全性(thread-safe)[SWS_CRYPT_22511]。这允许多个执行流并发、免同步地读取访问同一密钥实例以获取对应的公钥。

使用路径

PrivateKey 的典型使用路径包括接收私钥以及随后提取对应的公钥以用于验证、注册或通信目的:

  1. 获取密钥:消费软件组件以 PrivateKey::Sptr 形式接收非对称私钥的有效实例 [SWS_CRYPT_22501]。
  2. 检索配对密钥:如果下游工作流需要对应的公钥,则组件在该实例上调用成员函数 GetPublicKey() [SWS_CRYPT_22511]。
  3. 处理结果:该调用返回 ara::core::Result<PublicKey::Sptr> [SWS_CRYPT_22511]。应用程序检查结果对象是否成功,并在成功执行时解包指针 PublicKey::Sptr。
  4. 后续使用:获取的公钥随后可以传输给外部通信伙伴或传递给本地验证例程。据推测,公钥的派生在内部可能直接根据私钥的数学密钥参数进行(解释)。 问题 Q-464000dc5d638649 (未决)

错误场景

对于无误的集成,GetPublicKey() 的错误特性和边界条件具有决定性意义:

  • 标准化错误:根据规范,函数 GetPublicKey() 未定义标准化错误码 [SWS_CRYPT_22511]。
  • 错误通道:尽管未指定标准化错误,返回类型 ara::core::Result 仍会传递潜在的失败。如果在内部密钥派生或对象创建期间发生错误,结果对象大概率可能包含底层加密驱动程序的实现特定错误码(解释)。 问题 Q-4af6390594d9c5e1 (未决)
  • 异常安全性:该函数被显式归类为异常安全(exception safe),并带有标识符 noexcept [SWS_CRYPT_22511]。因此,调用方无需捕获 C++ 异常。
  • 前置与后置条件:成功调用的前置条件是有效且未释放的 PrivateKey 实例。在成功的情况下,接口保证返回在数学上与私钥完全对应的 PublicKey::Sptr 作为后置条件 [SWS_CRYPT_22511]。

本类指南由 AI 基于 AUTOSAR Adaptive R25-11 规范生成。

UML 类图

Hohle Dreieckspfeile = Vererbung (zeigt zur Basisklasse); Klicken öffnet die jeweilige Klassenseite.

G nara__crypto__cryp__PrivateKey762 PrivateKey + GetPublicKey() nara__crypto__cryp__CryptoObject679 CryptoObject nara__crypto__cryp__PrivateKey762->nara__crypto__cryp__CryptoObject679 nara__crypto__Serializable855 Serializable nara__crypto__cryp__CryptoObject679->nara__crypto__Serializable855

方法

The interface shall return the public key correspondent to this private key.

virtual ara::core::Result< PublicKey::Sptr > GetPublicKey () const noexcept=0;

类型别名

Sptr 类型别名

shared smart pointer of the interface.

方法文档

函数 GetPublicKey [SWS_CRYPT_22511] Upstream: RS_CRYPTO_02108, RS_CRYPTO_02115

virtual ara::core::Result< PublicKey::Sptr > GetPublicKey () const noexcept=0;

The interface shall return the public key correspondent to this private key.

AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 9b62fab60fc4 来源
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

使用

类 ara::crypto::cryp::PrivateKey 的方法 GetPublicKey 用于同步检索与私钥对应的公钥 [SWS_CRYPT_22511]。在 PrivateKey 的现有实例上无参数地进行调用。作为返回值,该接口提供一个 ara::core::Result<PublicKey::Sptr>,其在成功执行时提供指向关联 PublicKey 对象的共享指针 [SWS_CRYPT_22511]。

错误处理与并发

规范中未为此方法定义标准化错误码 [SWS_CRYPT_22511]。错误处理通过类型为 ara::core::Result 的返回对象进行。由于该操作声明为 noexcept,因此它被视为异常安全(exception safe)[SWS_CRYPT_22511]。此外,该方法限定为 const 并被指定为线程安全(thread-safe),从而允许跨多个线程的并发读取访问 [SWS_CRYPT_22511]。

相互作用

在典型的加密流程中,GetPublicKey 在通过 GeneratePrivateKey 生成非对称密钥对后使用 [SWS_CRYPT_20722]。在此过程中,生成的私钥的允许使用标志将转移至对应的公钥(例如,从签名生成转移签名验证权限)[SWS_CRYPT_20722]。该函数应与 ProtectedKeyImportCtx 中同名的接口区分开来,后者用于解包导入的公钥 [SWS_CRYPT_50211]。

本使用说明基于 AUTOSAR R25-11 自动生成。

实现者指南即将推出(复杂度 I1)

Header-Datei#include "ara/crypto/cryp/cryobj/private_key.h"
Scopeclass ara::crypto::cryp::PrivateKey
Exception-Sicherheitexception safe
Thread-Sicherheitthread-safe

Rückgabewert

TypBeschreibung
ara::core::Result< PublicKey::Sptr >A result containing a shared pointer to the public key correspondent to this private key

Fehler

FehlercodeBeschreibung
This function does not specify any standardized errors.

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CRYPT_22511
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CRYPT_22511@rel:R25-11#4b808117
Content hash
4b808117
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Cryptography.pdf#nameddest=SWS_CRYPT_22511
Status: valid/unmigrated Version: rel:R25-11#e5f0457b 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_22511@rel:R25-11#e5f0457b
Point-in-Time History:
Recorded Revisions (8):
  • R25-11rel:R25-11#f0d041e72026-09-30
  • R19-11rel:R19-11#bb931c232026-10-14
  • R20-11rel:R20-11#85846a1e2026-10-14
  • R21-11rel:R21-11#85846a1e2026-10-14
  • R22-11rel:R22-11#99b114f02026-10-14
  • R23-11rel:R23-11#6fdc19552026-10-14
  • R24-11rel:R24-11#a752dbfc2026-10-14
  • R25-11rel:R25-11#e5f0457b2026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill

类型别名文档

类型别名 Sptr [SWS_CRYPT_22501] Upstream: RS_CRYPTO_02306

using Sptr = std::shared_ptr<PrivateKey>;

shared smart pointer of the interface.

Header-Datei#include "ara/crypto/cryp/cryobj/private_key.h"
Scopeclass ara::crypto::cryp::PrivateKey
SymbolSptr

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_CRYPT_22501
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CRYPT_22501@rel:R25-11#4b96e17d
Content hash
4b96e17d
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Cryptography.pdf#nameddest=SWS_CRYPT_22501
Status: valid/unmigrated Version: rel:R25-11#48b56da1 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_22501@rel:R25-11#48b56da1
Point-in-Time History:
Recorded Revisions (8):
  • R25-11rel:R25-11#568a064f2026-09-30
  • R19-11rel:R19-11#c428ba2c2026-10-14
  • R20-11rel:R20-11#fb4c3bbd2026-10-14
  • R21-11rel:R21-11#fb4c3bbd2026-10-14
  • R22-11rel:R22-11#6e7979fe2026-10-14
  • R23-11rel:R23-11#d106cca42026-10-14
  • R24-11rel:R24-11#5eb65ced2026-10-14
  • R25-11rel:R25-11#48b56da12026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill