DEENESPTFRRUARHIKOZHNL

类 ara::crypto::Serializable

[SWS_CRYPT_10700] Upstream: RS_CRYPTO_02105

class Serializable {...};

Serializable object interface.

Header-Datei#include "ara/crypto/common/serializable.h"
Forwarding-Header#include "ara/crypto/crypto_fwd.h"
Scopenamespace ara::crypto

用户指南人工智能生成

定义用于大小确定和加密对象公开序列化的接口。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: dacacac17ff9 来源 未决问题(1)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

定义用于大小确定和加密对象公开序列化的接口。

接口 ara::crypto::Serializable 定义了将加密对象以公开方式导出为格式特定字节序列的统一标准。应用程序预先通过 GetExportSize() 确定所需的缓冲区大小,然后通过 ExportPublicly() 执行实际序列化并写入所提供的缓冲区 [SWS_CRYPT_10711]。所有操作均具有异常安全性与线程安全性,其中密钥的导出强制要求权限 kAllowPlaintextExport,且错误始终遵循回滚语义([SWS_CRYPT_50006])。

上下文

接口 ara::crypto::Serializable 为 crypto 模块中可转换为标准化字节表示的加密对象定义了抽象契约。作为纯接口,它封装了将对象序列化为由格式标识符(FormatId)指定的输出格式的能力 [SWS_CRYPT_10711]。典型的交互方包括需要持久存储加密工件(如密钥或证书)、通过通信信道传输或以明文交换加密工件的应用或平台组件。该接口确保导出在受控状态下进行,并考虑格式和安全限制。

生命周期

由于 ara::crypto::Serializable 是具有纯虚方法的纯虚接口,因此该类没有自己的实例化逻辑。生命周期和创建完全取决于实现该接口的派生具体加密类。接口的两个指定方法 GetExportSize() [SWS_CRYPT_50006] 以及 ExportPublicly() [SWS_CRYPT_10711] 均声明为 const,并且在序列化期间不会更改对象的内部状态。根据规范,这些操作被设计为异常安全(exception safe)和并发安全(thread-safe)[SWS_CRYPT_10711]、[SWS_CRYPT_50006],从而允许对同一对象实例进行并发读取访问。

使用路径

导出的常规流程分为大小确定和实际序列化这两个阶段的序列。为了避免缓冲区溢出或分配失败,调用方预先通过方法 GetExportSize() 查询所需目标格式精确需要的缓冲区字节大小 [SWS_CRYPT_50006]。成功收到反馈后,调用方提供 ReadWriteMemRegion 类型的可写内存区域。据推测,在大多数实现中,该内存区域是根据所确定的字节数动态分配的,或者是从预先保留的内存池中提供的。 问题 Q-0c04ba0a352f0a37 (未决)

在接下来的步骤中,应用程序调用 ExportPublicly(),并传入所提供的缓冲区以及先前选择的 FormatId [SWS_CRYPT_10711]。该对象将其有效负载序列化到传入的内存区域中,并在成功的情况下在返回类型 ara::core::Result<std::size_t> 内返回实际写入的字节数 [SWS_CRYPT_10711]。

通过 ara::crypto::Serializable 进行的序列化流程应用SerializableGetExportSize(format)Result<std::size_t>(缓冲区大小)Bereitstellung ReadWriteMemRegionExportPublicly(out, format)Result<std::size_t> (geschriebene Bytes)

时序图:通过大小查询并随后导出以序列化对象的典型调用顺序。来源:[SWS_CRYPT_50006]、[SWS_CRYPT_10711]

错误场景

该接口的操作通过返回类型 ara::core::Result 指示错误状态,其中所有指定的错误均保证严格的回滚语义(rollback_semantics)[SWS_CRYPT_10711]、[SWS_CRYPT_50006]。如果调用失败,整个系统将保持一致状态。定义了以下错误情况:

  • ara::crypto::CryptoErrc::kUnsupportedFormat:当指定的 FormatId 不被具体对象类型支持时,由 GetExportSize() [SWS_CRYPT_50006] 以及 ExportPublicly() [SWS_CRYPT_10711] 返回。
  • ara::crypto::CryptoErrc::kInsufficientCapacity:当传入的 ReadWriteMemRegion 缓冲区的容量不足以容纳序列化数据时,在 ExportPublicly() 中发生 [SWS_CRYPT_10711]。
  • ara::crypto::CryptoErrc::kUnsupported:如果原则上不支持导出该特定对象,则由 ExportPublicly() 报告 [SWS_CRYPT_10711]。
  • ara::crypto::CryptoErrc::kUsageViolation:当对象为密钥且其使用规则不允许明文导出时(允许的使用不包含 kAllowPlaintextExport),在 ExportPublicly() 中发生 [SWS_CRYPT_10711]。

本指南基于 AUTOSAR R25-11 规范。

UML 类图

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

G nara__crypto__Serializable855 Serializable + ExportPublicly() + GetExportSize() nara__crypto__cryp__CryptoObject679 CryptoObject nara__crypto__cryp__CryptoObject679->nara__crypto__Serializable855 nara__crypto__x509__CertSignRequest934 CertSignRequest nara__crypto__x509__CertSignRequest934->nara__crypto__Serializable855 nara__crypto__x509__Certificate240 Certificate nara__crypto__x509__Certificate240->nara__crypto__Serializable855 nara__crypto__x509__X509DN930 X509DN nara__crypto__x509__X509DN930->nara__crypto__Serializable855

方法

Serialize object using the provided format.

virtual ara::core::Result< std::size_t > ExportPublicly (ReadWriteMem Region out, FormatId format) const noexcept=0;

Get the size in bytes of the object when serialized in the provided format using ExportPublicly()

virtual ara::core::Result< std::size_t > GetExportSize (FormatId format) const noexcept=0;

方法文档

函数 ExportPublicly [SWS_CRYPT_10711] Upstream: RS_CRYPTO_02112

virtual ara::core::Result< std::size_t > ExportPublicly (ReadWriteMem Region out, FormatId format) const noexcept=0;

Serialize object using the provided format.

AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: 499fb38eb87a 来源 未决问题(1)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

使用

接口 ara::crypto::Serializable 的同步成员函数 ExportPublicly 以指定的输出格式序列化对象 [SWS_CRYPT_10711]。格式标识符 format(类型 FormatId)以及目标内存区域 out(类型 ReadWriteMem Region)作为参数传递。成功执行后,该函数在 ara::core::Result<std::size_t> 中返回实际写入的字节数 [SWS_CRYPT_10711]。

与相关函数的相互作用

该函数与 GetExportSize [SWS_CRYPT_50006] 直接相关,后者可用于确定特定格式所需的字节大小。调用方通常在提供输出缓冲区 out 之前首先查询 GetExportSize,以确保足够的缓冲区容量。 问题 Q-394ae08d9d7e6fa7 (未决)

错误处理

在出错情况下,将触发回滚语义并返回相应的错误码 [SWS_CRYPT_10711]:

  • ara::crypto::CryptoErrc::kInsufficientCapacity:所传入的输出缓冲区 out 尺寸过小 [SWS_CRYPT_10711]。
  • ara::crypto::CryptoErrc::kUnsupportedFormat:所传入的格式标识符不支持此对象类型 [SWS_CRYPT_10711]。
  • ara::crypto::CryptoErrc::kUnsupported:通常不支持导出该对象 [SWS_CRYPT_10711]。
  • ara::crypto::CryptoErrc::kUsageViolation:待导出的对象是一个密钥,其使用规则不允许明文导出(kAllowPlaintextExport)[SWS_CRYPT_10711]。

并发性与边界条件

该方法被指定为 const、noexcept、线程安全(“thread-safe”)和异常安全(“exception safe”)[SWS_CRYPT_10711]。因此,它可以并发执行且不抛出 C++ 异常。

本使用说明由 AI 基于 AUTOSAR 规范 R25-11 生成。

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

Header-Datei#include "ara/crypto/common/serializable.h"
Scopeclass ara::crypto::Serializable
Exception-Sicherheitexception safe
Thread-Sicherheitthread-safe

Parameter (in)

ParameterBeschreibung
formatidentifier of the output format

Parameter (out)

ParameterBeschreibung
outan output buffer that the serialized object will be written to

Rückgabewert

TypBeschreibung
ara::core::Result<std::size_t >A result containing the size in bytes of the serialized object or an error.

Fehler

FehlercodeBeschreibung
ara::crypto::CryptoErrc::kInsufficientCapacityrollback_semantics if the output buffer is too small
ara::crypto::CryptoErrc::kUnsupportedFormatrollback_semantics if the specified format ID is not supported for this object type
ara::crypto::CryptoErrc::kUnsupportedrollback_semantics if exporting the object is not supported
ara::crypto::CryptoErrc::kUsageViolationrollback_semantics if the object to be exported is a key and the allowed usage of the key does not include kAllowPlaintextExport

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

Record
AUTOSAR/AP/record/SWS_CRYPT_10711
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CRYPT_10711@rel:R25-11#3bfef152
Content hash
3bfef152
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Cryptography.pdf#nameddest=SWS_CRYPT_10711
Status: valid/unmigrated Version: rel:R25-11#c8dd72d0 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_10711@rel:R25-11#c8dd72d0
Point-in-Time History:
Recorded Revisions (8):
  • R25-11rel:R25-11#6e8a805e2026-09-30
  • R19-11rel:R19-11#fe62960e2026-10-14
  • R20-11rel:R20-11#4cac78d62026-10-14
  • R21-11rel:R21-11#13d51a182026-10-14
  • R22-11rel:R22-11#3bb1942d2026-10-14
  • R23-11rel:R23-11#ee143e792026-10-14
  • R24-11rel:R24-11#761192782026-10-14
  • R25-11rel:R25-11#c8dd72d02026-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

函数 GetExportSize [SWS_CRYPT_50006] Upstream: RS_CRYPTO_02112

virtual ara::core::Result< std::size_t > GetExportSize (FormatId format) const noexcept=0;

Get the size in bytes of the object when serialized in the provided format using ExportPublicly()

Header-Datei#include "ara/crypto/common/serializable.h"
Scopeclass ara::crypto::Serializable
Exception-Sicherheitexception safe
Thread-Sicherheitthread-safe

Parameter (in)

ParameterBeschreibung
formatidentifier of the output format

Rückgabewert

TypBeschreibung
ara::core::Result<std::size_t >A result containing the size in bytes of the serialized object or an error.

Fehler

FehlercodeBeschreibung
ara::crypto::CryptoErrc::kUnsupportedFormatrollback_semantics if the specified format ID is not supported for this object type

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

Record
AUTOSAR/AP/record/SWS_CRYPT_50006
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_CRYPT_50006@rel:R25-11#0c7240f6
Content hash
0c7240f6
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Cryptography.pdf#nameddest=SWS_CRYPT_50006
Status: valid/unmigrated Version: rel:R25-11#6c5e92f9 Versionshistorie & Revisions (1 transition)
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_50006@rel:R25-11#6c5e92f9
Point-in-Time History:
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